├── .gitignore ├── README.md ├── core ├── pom.xml └── src │ └── main │ └── java │ ├── ro │ └── fortsoft │ │ └── wicket │ │ └── dashboard │ │ ├── AbstractWidget.java │ │ ├── Dashboard.java │ │ ├── DashboardContextInitializer.java │ │ ├── DashboardPersister.java │ │ ├── DashboardUtils.java │ │ ├── DefaultDashboard.java │ │ ├── DefaultWidgetActionsFactory.java │ │ ├── DefaultWidgetFactory.java │ │ ├── DefaultWidgetRegistry.java │ │ ├── Widget.java │ │ ├── WidgetAction.java │ │ ├── WidgetActionsFactory.java │ │ ├── WidgetComparator.java │ │ ├── WidgetDescriptor.java │ │ ├── WidgetFactory.java │ │ ├── WidgetLocation.java │ │ ├── WidgetRegistry.java │ │ ├── XStreamDashboardPersister.java │ │ ├── web │ │ ├── AbstractWidgetAction.java │ │ ├── DashboardColumnPanel.html │ │ ├── DashboardColumnPanel.java │ │ ├── DashboardContext.java │ │ ├── DashboardContextAware.java │ │ ├── DashboardContextInjector.java │ │ ├── DashboardEvent.java │ │ ├── DashboardPanel.html │ │ ├── DashboardPanel.java │ │ ├── DashboardResourcesBehavior.java │ │ ├── DashboardSettings.java │ │ ├── DefaultWidgetActions.java │ │ ├── SortableAjaxBehavior.java │ │ ├── WidgetActionsPanel.html │ │ ├── WidgetActionsPanel.java │ │ ├── WidgetHeaderPanel.html │ │ ├── WidgetHeaderPanel.java │ │ ├── WidgetModel.java │ │ ├── WidgetPanel.html │ │ ├── WidgetPanel.java │ │ ├── WidgetView.html │ │ ├── WidgetView.java │ │ ├── res │ │ │ ├── dashboard-rtl.css │ │ │ ├── dashboard.css │ │ │ ├── dashboard.js │ │ │ ├── delete.gif │ │ │ ├── down.png │ │ │ ├── edit.png │ │ │ ├── jquery-1.8.3.min.js │ │ │ ├── jquery-ui-1.9.2.min.js │ │ │ ├── jquery.json-2.2.min.js │ │ │ ├── refresh.gif │ │ │ ├── sort-behavior.template.js │ │ │ └── up.png │ │ └── util │ │ │ ├── AjaxConfirmLink.java │ │ │ ├── CascadingLoadableDetachableModel.java │ │ │ └── ConfirmAjaxCallListener.java │ │ ├── wicket-package.properties │ │ ├── wicket-package_de.properties │ │ ├── wicket-package_fr.properties │ │ ├── wicket-package_ro.properties │ │ └── wicket-package_ru.properties │ └── wicket.properties ├── demo ├── pom.xml └── src │ ├── main │ ├── java │ │ └── ro │ │ │ └── fortsoft │ │ │ └── wicket │ │ │ └── dashboard │ │ │ └── demo │ │ │ ├── AddWidgetPage.html │ │ │ ├── AddWidgetPage.java │ │ │ ├── AddWidgetPanel$WidgetDescriptorPanel.html │ │ │ ├── AddWidgetPanel.html │ │ │ ├── AddWidgetPanel.java │ │ │ ├── DemoWidgetActionsFactory.java │ │ │ ├── DetachWidgetAction.java │ │ │ ├── HomePage.html │ │ │ ├── HomePage.java │ │ │ ├── WicketApplication.java │ │ │ ├── WicketApplication.properties │ │ │ ├── WicketApplication_de.properties │ │ │ ├── WicketApplication_fr.properties │ │ │ ├── WicketApplication_ro.properties │ │ │ ├── WidgetPage.html │ │ │ ├── WidgetPage.java │ │ │ ├── detach.png │ │ │ ├── jqplot │ │ │ └── DemoChartFactory.java │ │ │ ├── justgage │ │ │ └── DemoJustGageFactory.java │ │ │ ├── ofchart │ │ │ ├── DemoChartDataFactory.java │ │ │ └── DemoChartFactory.java │ │ │ └── wickedCharts │ │ │ └── DemoHighChartsFactory.java │ ├── resources │ │ └── log4j.properties │ └── webapp │ │ ├── WEB-INF │ │ └── web.xml │ │ ├── css │ │ └── style.css │ │ ├── images │ │ └── edit.png │ │ └── index.html │ └── test │ └── java │ └── ro │ └── fortsoft │ └── wicket │ └── dashboard │ └── demo │ └── Start.java ├── pom.xml ├── screenshots ├── wicket-dashboard-gauge.png └── wicket-dashboard.png └── widgets ├── jqplot ├── pom.xml └── src │ └── main │ └── java │ └── ro │ └── fortsoft │ └── wicket │ └── dashboard │ └── widget │ └── jqplot │ ├── ChartContainer.java │ ├── ChartFactory.java │ ├── JqPlotSettingsPanel.html │ ├── JqPlotSettingsPanel.java │ ├── JqPlotWidget.java │ ├── JqPlotWidgetDescriptor.java │ ├── JqPlotWidgetView.html │ └── JqPlotWidgetView.java ├── justgage ├── pom.xml └── src │ └── main │ └── java │ └── ro │ └── fortsoft │ └── wicket │ └── dashboard │ └── widget │ └── justgage │ ├── JustGage.java │ ├── JustGageFactory.java │ ├── JustGageWidget.java │ ├── JustGageWidgetDescriptor.java │ ├── JustGageWidgetView.html │ ├── JustGageWidgetView.java │ ├── option │ ├── JavaScriptOptionsRenderer.java │ └── Option.java │ └── res │ ├── justgage.1.0.1.js │ ├── justgage.1.0.1.min.js │ └── raphael.2.1.0.min.js ├── loremipsum ├── pom.xml └── src │ └── main │ └── java │ └── ro │ └── fortsoft │ └── wicket │ └── dashboard │ └── widget │ └── loremipsum │ ├── LoremIpsumWidget.java │ ├── LoremIpsumWidgetDescriptor.java │ ├── LoremIpsumWidgetView.html │ └── LoremIpsumWidgetView.java ├── ofchart ├── pom.xml └── src │ └── main │ └── java │ ├── ro │ └── fortsoft │ │ └── wicket │ │ └── dashboard │ │ └── widget │ │ └── ofchart │ │ ├── ChartDataFactory.java │ │ ├── ChartSettingsPanel.html │ │ ├── ChartSettingsPanel.java │ │ ├── ChartWidget.java │ │ ├── ChartWidgetDescriptor.java │ │ ├── ChartWidgetView.html │ │ ├── ChartWidgetView.java │ │ ├── DataResource.java │ │ ├── DataResourceReference.java │ │ ├── Initializer.java │ │ ├── OpenFlashChart.html │ │ ├── OpenFlashChart.java │ │ ├── SWFObject.java │ │ └── res │ │ ├── expressInstall.swf │ │ ├── open-flash-chart.swf │ │ ├── open-flash-chart.swf.bad │ │ ├── saveChartImage.js │ │ └── swfobject-2.2.js │ └── wicket.properties ├── pom.xml └── wicked-charts ├── pom.xml └── src └── main └── java └── ro └── fortsoft └── wicket └── dashboard └── widgets └── wicked └── charts ├── HighChartsFactory.java ├── HighChartsWidget.java ├── HighChartsWidgetDescriptor.java ├── HighChartsWidgetView.html ├── HighChartsWidgetView.java ├── options ├── AngularGaugeOptions.java ├── AreaRangeOptions.java ├── AreaSplineOptions.java ├── BasicAreaOptions.java ├── BasicBarOptions.java ├── BasicLineOptions.java ├── BubbleChart3DOptions.java ├── ColumnRangeOptions.java ├── PieWithLegendOptions.java ├── ScatterPlotOptions.java ├── ShowcaseOptions.java ├── SplineUpdatingOptions.java └── StackedAndGroupedColumnOptions.java └── settings ├── HighChartsSettingsPanel.html ├── HighChartsSettingsPanel.java └── Settings.java /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | .project 3 | .classpath 4 | .settings 5 | .idea/ 6 | *.iml -------------------------------------------------------------------------------- /core/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ro.fortsoft.wicket.dashboard 6 | wicket-dashboard-parent 7 | 0.14.0-SNAPSHOT 8 | 9 | 10 | 4.0.0 11 | wicket-dashboard-core 12 | 0.14.0-SNAPSHOT 13 | jar 14 | Wicket Dashboard Core 15 | 16 | 17 | 2.2.2 18 | 1.4.3 19 | 20 | 21 | 22 | 23 | 24 | com.google.code.gson 25 | gson 26 | ${gson.version} 27 | 28 | 29 | 30 | 31 | com.thoughtworks.xstream 32 | xstream 33 | ${xstream.version} 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/AbstractWidget.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard; 14 | 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | 18 | import org.apache.wicket.markup.html.panel.Panel; 19 | 20 | /** 21 | * Abstract stub implementation for {@link Widget} to simplify defining of actual widgets 22 | * @author Decebal Suiu 23 | */ 24 | public abstract class AbstractWidget implements Widget { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | protected String id; 29 | protected String title; 30 | protected boolean collapsed; 31 | protected Map settings; 32 | protected WidgetLocation location; 33 | 34 | public AbstractWidget() { 35 | settings = new HashMap(); 36 | location = new WidgetLocation(); 37 | } 38 | 39 | @Override 40 | public String getId() { 41 | return id; 42 | } 43 | 44 | @Override 45 | public void setId(String id) { 46 | this.id = id; 47 | } 48 | 49 | @Override 50 | public String getTitle() { 51 | return title; 52 | } 53 | 54 | @Override 55 | public void setTitle(String title) { 56 | this.title = title; 57 | } 58 | 59 | @Override 60 | public boolean isCollapsed() { 61 | return collapsed; 62 | } 63 | 64 | @Override 65 | public void setCollapsed(boolean collapsed) { 66 | this.collapsed = collapsed; 67 | // getInternalSettings().put(COLLAPSED, Boolean.toString(collapsed)); 68 | } 69 | 70 | @Override 71 | public WidgetLocation getLocation() { 72 | return location; 73 | } 74 | 75 | @Override 76 | public void setLocation(WidgetLocation location) { 77 | this.location = location; 78 | } 79 | 80 | public void init() { 81 | // do nothing 82 | } 83 | 84 | @Override 85 | public boolean hasSettings() { 86 | return false; 87 | } 88 | 89 | @Override 90 | public Map getSettings() { 91 | return settings; 92 | } 93 | 94 | @Override 95 | public void setSettings(Map settings) { 96 | this.settings = settings; 97 | } 98 | 99 | @Override 100 | public Panel createSettingsPanel(String settingsPanelId) { 101 | return null; 102 | } 103 | 104 | @Override 105 | public boolean equals(Object o) { 106 | if (this == o) { 107 | return true; 108 | } 109 | 110 | if (o == null || getClass() != o.getClass()) { 111 | return false; 112 | } 113 | 114 | AbstractWidget widget = (AbstractWidget) o; 115 | 116 | if (!title.equals(widget.title)) { 117 | return false; 118 | } 119 | 120 | if (!id.equals(widget.id)) { 121 | return false; 122 | } 123 | 124 | return true; 125 | } 126 | 127 | @Override 128 | public int hashCode() { 129 | int result; 130 | result = id.hashCode(); 131 | result = 31 * result + title.hashCode(); 132 | return result; 133 | } 134 | 135 | } 136 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/Dashboard.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard; 14 | 15 | import java.io.Serializable; 16 | import java.util.List; 17 | 18 | /** 19 | * Dashboards stores collection of {@link Widget}s and allow to manipulatet them 20 | * @author Decebal Suiu 21 | */ 22 | public interface Dashboard extends Serializable { 23 | 24 | public String getId(); 25 | 26 | public String getTitle(); 27 | 28 | public void setTitle(String title); 29 | 30 | public int getColumnCount(); 31 | 32 | public void setColumnCount(int columnCount); 33 | 34 | public List getWidgets(); 35 | 36 | public List getWidgets(int column); 37 | 38 | public Widget getWidget(String widgetId); 39 | 40 | public void addWidget(Widget widget); 41 | 42 | public void deleteWidget(String widgetId); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/DashboardContextInitializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard; 14 | 15 | import org.apache.wicket.Application; 16 | import org.apache.wicket.IInitializer; 17 | import org.apache.wicket.MetaDataKey; 18 | 19 | import ro.fortsoft.wicket.dashboard.web.DashboardContext; 20 | import ro.fortsoft.wicket.dashboard.web.DashboardContextInjector; 21 | 22 | /** 23 | * Wicket-dashboard {@link IInitializer}. 24 | * Initialize {@link DashboardContext} and assign it to {@link MetaDataKey} {@link DashboardContextInitializer}.DASHBOARD_CONTEXT_KEY 25 | * @author Decebal Suiu 26 | */ 27 | public class DashboardContextInitializer implements IInitializer { 28 | 29 | @SuppressWarnings("serial") 30 | public static MetaDataKey DASHBOARD_CONTEXT_KEY = new MetaDataKey() {}; 31 | 32 | @Override 33 | public void init(Application application) { 34 | // create dashboard context 35 | DashboardContext dashboardContext = new DashboardContext(); 36 | 37 | // store dashboard context in application 38 | application.setMetaData(DASHBOARD_CONTEXT_KEY, dashboardContext); 39 | 40 | // add dashboard context injector 41 | DashboardContextInjector dashboardContextInjector = new DashboardContextInjector(dashboardContext); 42 | application.getComponentInstantiationListeners().add(dashboardContextInjector); 43 | } 44 | 45 | @Override 46 | public void destroy(Application application) { 47 | // does noting 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/DashboardPersister.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard; 14 | 15 | /** 16 | * {@link DashboardPersister} is an service which allow to save current {@link Dashboard} and load from underling storage 17 | * @author Decebal Suiu 18 | */ 19 | public interface DashboardPersister { 20 | 21 | public Dashboard load(); 22 | 23 | public void save(Dashboard dashboard); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/DashboardUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard; 14 | 15 | import java.util.List; 16 | import java.util.Map; 17 | 18 | import ro.fortsoft.wicket.dashboard.web.DashboardEvent; 19 | 20 | /** 21 | * @author Decebal Suiu 22 | */ 23 | public class DashboardUtils { 24 | 25 | @SuppressWarnings("unchecked") 26 | public static void updateWidgetLocations(Dashboard dashboard, DashboardEvent dashboardEvent) { 27 | DashboardEvent.EventType eventType = dashboardEvent.getType(); 28 | if (DashboardEvent.EventType.WIDGET_ADDED == eventType) { 29 | List widgets = dashboard.getWidgets(0); 30 | for (Widget widget : widgets) { 31 | widget.getLocation().incrementRow(); 32 | } 33 | } else if (DashboardEvent.EventType.WIDGET_REMOVED == eventType) { 34 | Widget widgetRemoved = (Widget) dashboardEvent.getDetail(); 35 | WidgetLocation widgetRemovedLocation = widgetRemoved.getLocation(); 36 | List widgets = dashboard.getWidgets(widgetRemovedLocation.getColumn()); 37 | for (Widget widget : widgets) { 38 | WidgetLocation widgetLocation = widget.getLocation(); 39 | if (widgetLocation.getRow() > widgetRemovedLocation.getRow()) { 40 | widget.getLocation().decrementRow(); 41 | } 42 | } 43 | } else if (DashboardEvent.EventType.WIDGETS_SORTED == eventType) { 44 | Map widgetLocations = (Map) dashboardEvent.getDetail(); 45 | List widgets = dashboard.getWidgets(); 46 | for (Widget widget : widgets) { 47 | String id = widget.getId(); 48 | WidgetLocation location = widgetLocations.get(id); 49 | if (!location.equals(widget.getLocation())) { 50 | widget.setLocation(location); 51 | } 52 | } 53 | } 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/DefaultDashboard.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard; 14 | 15 | import java.util.ArrayList; 16 | import java.util.Collections; 17 | import java.util.List; 18 | 19 | /** 20 | * Default {@link Dashboard} implementation. 21 | * In most of cases this implementation will be enough 22 | * @author Decebal Suiu 23 | */ 24 | public class DefaultDashboard implements Dashboard { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | private String id; 29 | private String title; 30 | private int columnCount; 31 | private List widgets; 32 | 33 | public DefaultDashboard(String id, String title) { 34 | this.id = id; 35 | this.title = title; 36 | columnCount = 2; 37 | widgets = new ArrayList(); 38 | } 39 | 40 | @Override 41 | public String getId() { 42 | return id; 43 | } 44 | 45 | @Override 46 | public String getTitle() { 47 | return title; 48 | } 49 | 50 | @Override 51 | public void setTitle(String title) { 52 | this.title = title; 53 | } 54 | 55 | @Override 56 | public int getColumnCount() { 57 | return columnCount; 58 | } 59 | 60 | @Override 61 | public void setColumnCount(int columnCount) { 62 | this.columnCount = columnCount; 63 | } 64 | 65 | @Override 66 | public List getWidgets() { 67 | return widgets; 68 | } 69 | 70 | @Override 71 | public List getWidgets(int column) { 72 | List columnWidgets = new ArrayList(); 73 | for (Widget widget : widgets) { 74 | if (column == widget.getLocation().getColumn()) { 75 | columnWidgets.add(widget); 76 | } 77 | } 78 | 79 | // sort widgets by row 80 | Collections.sort(columnWidgets, new WidgetComparator()); 81 | 82 | return columnWidgets; 83 | } 84 | 85 | @Override 86 | public Widget getWidget(String widgetId) { 87 | for (Widget widget : widgets) { 88 | if (widget.getId().equals(widgetId)) { 89 | return widget; 90 | } 91 | } 92 | 93 | return null; 94 | } 95 | 96 | public void setWidgets(List widgets) { 97 | this.widgets = widgets; 98 | } 99 | 100 | @Override 101 | public void addWidget(Widget widget) { 102 | widgets.add(widget); 103 | } 104 | 105 | @Override 106 | public void deleteWidget(String widgetId) { 107 | Widget widget = getWidget(widgetId); 108 | if (widget != null) { 109 | widgets.remove(widget); 110 | } 111 | } 112 | 113 | @Override 114 | public String toString() { 115 | StringBuffer buffer = new StringBuffer(); 116 | buffer.append("DefaultDashboard["); 117 | buffer.append("id = ").append(id); 118 | buffer.append(" title = ").append(title); 119 | buffer.append(" widgets = ").append(widgets); 120 | buffer.append("]"); 121 | 122 | return buffer.toString(); 123 | } 124 | 125 | } 126 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/DefaultWidgetActionsFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard; 14 | 15 | import ro.fortsoft.wicket.dashboard.web.DefaultWidgetActions; 16 | 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | /** 21 | * Default {@link WidgetActionsFactory} which provide common actions like: 22 | *
    23 | *
  • Refresh
  • 24 | *
  • View settings
  • 25 | *
  • Delete an widget from a dashboard
  • 26 | *
27 | * @author Decebal Suiu 28 | */ 29 | public class DefaultWidgetActionsFactory implements WidgetActionsFactory { 30 | 31 | @Override 32 | public List createWidgetActions(Widget widget) { 33 | List widgetActions = new ArrayList(); 34 | widgetActions.add(new DefaultWidgetActions.Refresh(widget)); 35 | if (widget.hasSettings()) { 36 | widgetActions.add(new DefaultWidgetActions.Settings(widget)); 37 | } 38 | widgetActions.add(new DefaultWidgetActions.Delete(widget)); 39 | 40 | return widgetActions; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/DefaultWidgetFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard; 14 | 15 | import java.lang.reflect.Constructor; 16 | import java.util.UUID; 17 | 18 | /** 19 | * Default {@link WidgetFactory} which creates a widget by specified widget class name 20 | * @author Decebal Suiu 21 | */ 22 | public class DefaultWidgetFactory implements WidgetFactory { 23 | 24 | @SuppressWarnings("unchecked") 25 | public Widget createWidget(WidgetDescriptor widgetDescriptor) { 26 | String widgetClassName = widgetDescriptor.getWidgetClassName(); 27 | try { 28 | Class widgetClass = (Class) Class.forName(widgetClassName); 29 | Constructor constructor = widgetClass.getConstructor(); 30 | Widget widget = constructor.newInstance(); 31 | String widgetId = createWidgetId(widgetDescriptor, widget); 32 | widget.setId(widgetId); 33 | widget.init(); 34 | 35 | return widget; 36 | } catch (ClassNotFoundException e) { 37 | e.printStackTrace(); 38 | } catch (NoSuchMethodException e) { 39 | e.printStackTrace(); 40 | } catch (Exception e) { 41 | e.printStackTrace(); 42 | } 43 | 44 | return null; 45 | } 46 | 47 | protected String createWidgetId(WidgetDescriptor widgetDescriptor, Widget widget) { 48 | return UUID.randomUUID().toString(); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/DefaultWidgetRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard; 14 | 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | /** 19 | * Default {@link WidgetRegistry} implementation. 20 | * Override this class if you need to tire registry with some underling storage 21 | * 22 | * @author Decebal Suiu 23 | */ 24 | public class DefaultWidgetRegistry implements WidgetRegistry { 25 | 26 | private List widgetDescriptors; 27 | 28 | public DefaultWidgetRegistry() { 29 | widgetDescriptors = new ArrayList(); 30 | } 31 | 32 | @Override 33 | public List getWidgetDescriptors() { 34 | return widgetDescriptors; 35 | } 36 | 37 | public void setWidgetDescriptors(List widgetDescriptors) { 38 | this.widgetDescriptors = widgetDescriptors; 39 | } 40 | 41 | @Override 42 | public WidgetRegistry registerWidget(WidgetDescriptor widgetDescriptor) { 43 | if (widgetDescriptor != null) { 44 | widgetDescriptors.add(widgetDescriptor); 45 | } 46 | 47 | return this; 48 | } 49 | 50 | @Override 51 | public WidgetDescriptor getWidgetDescriptorByClassName(String widgetClassName) { 52 | for (WidgetDescriptor widgetDescriptor : widgetDescriptors) { 53 | if (widgetDescriptor.getWidgetClassName().equals(widgetClassName)) { 54 | return widgetDescriptor; 55 | } 56 | } 57 | 58 | return null; 59 | } 60 | 61 | @Override 62 | public WidgetDescriptor getWidgetDescriptorByTypeName(String widgetTypeName) { 63 | for (WidgetDescriptor widgetDescriptor : widgetDescriptors) { 64 | if (widgetDescriptor.getTypeName().equals(widgetTypeName)) { 65 | return widgetDescriptor; 66 | } 67 | } 68 | 69 | return null; 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/Widget.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard; 14 | 15 | import java.io.Serializable; 16 | import java.util.Map; 17 | 18 | import org.apache.wicket.markup.html.panel.Panel; 19 | 20 | import ro.fortsoft.wicket.dashboard.web.WidgetView; 21 | 22 | /** 23 | * @author Decebal Suiu 24 | */ 25 | public interface Widget extends Serializable { 26 | 27 | public String getId(); 28 | 29 | public void setId(String id); 30 | 31 | public String getTitle(); 32 | 33 | public void setTitle(String title); 34 | 35 | public WidgetLocation getLocation(); 36 | 37 | public void setLocation(WidgetLocation location); 38 | 39 | public WidgetView createView(String viewId); 40 | 41 | public boolean isCollapsed(); 42 | 43 | public void setCollapsed(boolean collapsed); 44 | 45 | public void init(); 46 | 47 | public boolean hasSettings(); 48 | 49 | public Map getSettings(); 50 | 51 | public void setSettings(Map settings); 52 | 53 | public Panel createSettingsPanel(String settingsPanelId); 54 | 55 | } 56 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/WidgetAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard; 14 | 15 | import org.apache.wicket.markup.html.image.Image; 16 | import org.apache.wicket.markup.html.link.AbstractLink; 17 | import org.apache.wicket.model.IModel; 18 | 19 | import java.io.Serializable; 20 | 21 | /** 22 | * Interface for actions that can be performed over a widget 23 | * @author Decebal Suiu 24 | */ 25 | public interface WidgetAction extends Serializable { 26 | 27 | public AbstractLink getLink(String id); 28 | 29 | public Image getImage(String id); 30 | 31 | public IModel getTooltip(); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/WidgetActionsFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard; 14 | 15 | import java.util.List; 16 | 17 | /** 18 | * Interface for a service which can provide a list of {@link WidgetAction} per widget 19 | * @author Decebal Suiu 20 | */ 21 | public interface WidgetActionsFactory { 22 | 23 | public List createWidgetActions(Widget widget); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/WidgetComparator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard; 14 | 15 | import java.util.Comparator; 16 | 17 | /** 18 | * @author Decebal Suiu 19 | */ 20 | public class WidgetComparator implements Comparator { 21 | 22 | @Override 23 | public int compare(Widget o1, Widget o2) { 24 | WidgetLocation l1 = o1.getLocation(); 25 | WidgetLocation l2 = o2.getLocation(); 26 | if (l1.getColumn() != l2.getColumn()) { 27 | return (l1.getColumn() - l2.getColumn()); 28 | } else { 29 | return (l1.getRow() - l2.getRow()); 30 | } 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/WidgetDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard; 14 | 15 | import java.io.Serializable; 16 | 17 | /** 18 | * Widget definition descriptor. 19 | * Define the nature of a widget. 20 | * 21 | * @author Decebal Suiu 22 | */ 23 | public interface WidgetDescriptor extends Serializable { 24 | 25 | /** 26 | * Returns a UUID string that represents the widget type name. 27 | */ 28 | public String getTypeName(); 29 | 30 | /** 31 | * Returns the widget name that user will see in the list of available widgets. 32 | */ 33 | public String getName(); 34 | 35 | public String getProvider(); 36 | 37 | public String getDescription(); 38 | 39 | /** 40 | * Returns the classname of the widget. 41 | */ 42 | public String getWidgetClassName(); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/WidgetFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard; 14 | 15 | /** 16 | * Factory to create a widget according to {@link WidgetDescriptor} 17 | * @author Decebal Suiu 18 | */ 19 | public interface WidgetFactory { 20 | 21 | public Widget createWidget(WidgetDescriptor widgetDescriptor); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/WidgetLocation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard; 14 | 15 | import java.io.Serializable; 16 | 17 | /** 18 | * Container for a widget location on a screen: column + row 19 | * @author Decebal Suiu 20 | */ 21 | public class WidgetLocation implements Serializable { 22 | 23 | private static final long serialVersionUID = 1L; 24 | 25 | private int column; 26 | private int row; 27 | 28 | public WidgetLocation() { 29 | } 30 | 31 | public WidgetLocation(int column, int row) { 32 | this.column = column; 33 | this.row = row; 34 | } 35 | 36 | public int getColumn() { 37 | return column; 38 | } 39 | 40 | public void setColumn(int column) { 41 | this.column = column; 42 | } 43 | 44 | public int getRow() { 45 | return row; 46 | } 47 | 48 | public void setRow(int row) { 49 | this.row = row; 50 | } 51 | 52 | public void incrementRow() { 53 | row++; 54 | } 55 | 56 | public void decrementRow() { 57 | row--; 58 | } 59 | 60 | @Override 61 | public int hashCode() { 62 | final int prime = 31; 63 | int result = 1; 64 | result = prime * result + column; 65 | result = prime * result + row; 66 | 67 | return result; 68 | } 69 | 70 | @Override 71 | public boolean equals(Object obj) { 72 | if (this == obj) { 73 | return true; 74 | } 75 | 76 | if (obj == null) { 77 | return false; 78 | } 79 | 80 | if (getClass() != obj.getClass()) { 81 | return false; 82 | } 83 | 84 | WidgetLocation other = (WidgetLocation) obj; 85 | if (column != other.column) { 86 | return false; 87 | } 88 | if (row != other.row) { 89 | return false; 90 | } 91 | 92 | return true; 93 | } 94 | 95 | @Override 96 | public String toString() { 97 | StringBuffer buffer = new StringBuffer(); 98 | buffer.append("WidgetLocation["); 99 | buffer.append("column = ").append(column); 100 | buffer.append(" row = ").append(row); 101 | buffer.append("]"); 102 | 103 | return buffer.toString(); 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/WidgetRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard; 14 | 15 | import java.util.List; 16 | 17 | /** 18 | * Central registry for {@link WidgetDescriptor}s 19 | * @author Decebal Suiu 20 | */ 21 | public interface WidgetRegistry { 22 | 23 | /** 24 | * Register new type of widgets described by {@link WidgetDescriptor} 25 | * @param widgetDescriptor descriptor to be registered 26 | * @return this {@link WidgetRegistry} 27 | */ 28 | public WidgetRegistry registerWidget(WidgetDescriptor widgetDescriptor); 29 | 30 | /** 31 | * Returns a list of registered widgets 32 | * @return list of registered widget descriptors 33 | */ 34 | public List getWidgetDescriptors(); 35 | 36 | /** 37 | * Lookup {@link WidgetDescriptor} by widget class 38 | * @param widgetClassName widget class name 39 | * @return registered {@link WidgetDescriptor} with specified widget class or null if {@link WidgetDescriptor} was not found 40 | */ 41 | public WidgetDescriptor getWidgetDescriptorByClassName(String widgetClassName); 42 | 43 | /** 44 | * Lookup {@link WidgetDescriptor} by widget type 45 | * @param widgetTypeName widget type 46 | * @return registered {@link WidgetDescriptor} with specified widget type or null if {@link WidgetDescriptor} was not found 47 | */ 48 | public WidgetDescriptor getWidgetDescriptorByTypeName(String widgetTypeName); 49 | 50 | } 51 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/XStreamDashboardPersister.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard; 14 | 15 | import java.io.File; 16 | import java.io.FileInputStream; 17 | import java.io.FileNotFoundException; 18 | import java.io.FileOutputStream; 19 | import java.util.Collections; 20 | 21 | import com.thoughtworks.xstream.XStream; 22 | import com.thoughtworks.xstream.io.xml.DomDriver; 23 | 24 | /** 25 | * Default {@link DashboardPersister} 26 | * Persists a dashboard in specified file. 27 | * If you need to have different logic for storing and loading of {@link Dashboard}s: implement your own {@link DashboardPersister} 28 | * @author Decebal Suiu 29 | */ 30 | public class XStreamDashboardPersister implements DashboardPersister { 31 | 32 | private File file; 33 | private XStream xstream; 34 | 35 | public XStreamDashboardPersister(File file) { 36 | this.file = file; 37 | 38 | xstream = new XStream(new DomDriver("UTF-8")); 39 | xstream.setMode(XStream.NO_REFERENCES); 40 | xstream.alias("dashboard", DefaultDashboard.class); 41 | // xstream.alias("textWidget", TextWidget.class); 42 | // xstream.alias("chartWidget", ChartWidget.class); 43 | } 44 | 45 | @Override 46 | public Dashboard load() { 47 | if (!file.exists() || !file.isFile()) { 48 | return null; 49 | } 50 | 51 | try { 52 | return (Dashboard) xstream.fromXML(new FileInputStream(file)); 53 | } catch (FileNotFoundException e) { 54 | e.printStackTrace(); 55 | return null; 56 | } 57 | } 58 | 59 | @Override 60 | public void save(Dashboard dashboard) { 61 | // sort widgets 62 | Collections.sort(dashboard.getWidgets(), new WidgetComparator()); 63 | 64 | try { 65 | xstream.toXML(dashboard, new FileOutputStream(file)); 66 | } catch (FileNotFoundException e) { 67 | e.printStackTrace(); 68 | } 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/web/AbstractWidgetAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.web; 14 | 15 | import org.apache.wicket.markup.html.image.Image; 16 | import org.apache.wicket.model.IModel; 17 | import org.apache.wicket.request.resource.ContextRelativeResource; 18 | import org.apache.wicket.request.resource.PackageResourceReference; 19 | import org.apache.wicket.util.lang.Args; 20 | import ro.fortsoft.wicket.dashboard.Widget; 21 | import ro.fortsoft.wicket.dashboard.WidgetAction; 22 | 23 | /** 24 | * @author Decebal Suiu 25 | */ 26 | public abstract class AbstractWidgetAction implements WidgetAction { 27 | 28 | protected Widget widget; 29 | protected IModel tooltip; 30 | private Class imageScope; 31 | private String imageName; 32 | 33 | public AbstractWidgetAction(Widget widget) { 34 | this.widget = widget; 35 | } 36 | 37 | public Widget getWidget() { 38 | return widget; 39 | } 40 | 41 | @Override 42 | public IModel getTooltip() { 43 | return tooltip; 44 | } 45 | 46 | public void setTooltip(IModel tooltip) { 47 | this.tooltip = tooltip; 48 | } 49 | 50 | /** 51 | * If you use this method than the image name is relative to scope. 52 | * 53 | * @param scope 54 | * @param name 55 | */ 56 | public void setImage(Class scope, String name) { 57 | imageScope = scope; 58 | imageName = name; 59 | } 60 | 61 | /** 62 | * If you use this method than the image name is relative to context. 63 | * 64 | * @param name 65 | */ 66 | public void setImage(String name) { 67 | setImage(null, name); 68 | } 69 | 70 | @Override 71 | public Image getImage(String id) { 72 | Args.notNull(imageName, "imageName"); 73 | 74 | if (imageScope != null) { 75 | return new Image(id, new PackageResourceReference(imageScope, imageName)); 76 | } 77 | 78 | return new Image(id, new ContextRelativeResource(imageName)); 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/web/DashboardColumnPanel.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
    5 |
  • 6 |
    7 |
  • 8 |
9 |
10 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/web/DashboardContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.web; 14 | 15 | import java.io.File; 16 | 17 | import ro.fortsoft.wicket.dashboard.DashboardContextInitializer; 18 | import ro.fortsoft.wicket.dashboard.DashboardPersister; 19 | import ro.fortsoft.wicket.dashboard.DefaultWidgetActionsFactory; 20 | import ro.fortsoft.wicket.dashboard.DefaultWidgetFactory; 21 | import ro.fortsoft.wicket.dashboard.DefaultWidgetRegistry; 22 | import ro.fortsoft.wicket.dashboard.WidgetActionsFactory; 23 | import ro.fortsoft.wicket.dashboard.WidgetFactory; 24 | import ro.fortsoft.wicket.dashboard.WidgetRegistry; 25 | import ro.fortsoft.wicket.dashboard.XStreamDashboardPersister; 26 | 27 | /** 28 | * {@link DashboardContext} is an central for dashboard related services: 29 | *
    30 | *
  • {@link WidgetFactory}
  • 31 | *
  • {@link WidgetRegistry}
  • 32 | *
  • {@link DashboardPersister}
  • 33 | *
  • {@link WidgetActionsFactory}
  • 34 | *
35 | * 36 | * Instance is being created by {@link DashboardContextInitializer} during application startup and can't be replaced. 37 | * If you need customzation: just set your own services listed before by corresponding methods. 38 | * 39 | * @author Decebal Suiu 40 | */ 41 | public class DashboardContext { 42 | 43 | private WidgetFactory widgetFactory; 44 | private WidgetRegistry widgetRegistry; 45 | private DashboardPersister dashboardPersister; 46 | private WidgetActionsFactory widgetActionsFactory; 47 | 48 | public DashboardContext() { 49 | setWidgetFactory(new DefaultWidgetFactory()); 50 | setWidgetRegistry(new DefaultWidgetRegistry()); 51 | setDashboardPersister(new XStreamDashboardPersister(new File("dashboard.xml"))); 52 | setWidgetActionsFactory(new DefaultWidgetActionsFactory()); 53 | } 54 | 55 | public WidgetFactory getWidgetFactory() { 56 | return widgetFactory; 57 | } 58 | 59 | public void setWidgetFactory(WidgetFactory widgetFactory) { 60 | this.widgetFactory = widgetFactory; 61 | } 62 | 63 | public WidgetRegistry getWidgetRegistry() { 64 | return widgetRegistry; 65 | } 66 | 67 | public void setWidgetRegistry(WidgetRegistry widgetRegistry) { 68 | this.widgetRegistry = widgetRegistry; 69 | } 70 | 71 | /** 72 | * @deprecated use {@link #getDashboardPersister()} instead 73 | */ 74 | @Deprecated 75 | public DashboardPersister getDashboardPersiter() { 76 | return dashboardPersister; 77 | } 78 | 79 | public DashboardPersister getDashboardPersister() { 80 | return dashboardPersister; 81 | } 82 | 83 | /** 84 | * @deprecated use {@link #setDashboardPersister(DashboardPersister)} instead 85 | */ 86 | @Deprecated 87 | public void setDashboardPersiter(DashboardPersister dashboardPersister) { 88 | this.dashboardPersister = dashboardPersister; 89 | } 90 | 91 | public void setDashboardPersister(DashboardPersister dashboardPersister) { 92 | this.dashboardPersister = dashboardPersister; 93 | } 94 | 95 | public WidgetActionsFactory getWidgetActionsFactory() { 96 | return widgetActionsFactory; 97 | } 98 | 99 | public void setWidgetActionsFactory(WidgetActionsFactory widgetActionsFactory) { 100 | this.widgetActionsFactory = widgetActionsFactory; 101 | } 102 | 103 | } 104 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/web/DashboardContextAware.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.web; 14 | 15 | /** 16 | * Interface to be implemented by any wicket compoment that wishes to be notified 17 | * of the DashboardContext that it runs in. 18 | * 19 | * @author Decebal Suiu 20 | */ 21 | public interface DashboardContextAware { 22 | 23 | public void setDashboardContext(DashboardContext dashboardContext); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/web/DashboardContextInjector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.web; 14 | 15 | import org.apache.wicket.Component; 16 | import org.apache.wicket.application.IComponentInstantiationListener; 17 | 18 | /** 19 | *{@link IComponentInstantiationListener} which inject {@link DashboardContext} if a {@link Component} implemets {@link DashboardContextAware} 20 | * @author Decebal Suiu 21 | */ 22 | public class DashboardContextInjector implements IComponentInstantiationListener { 23 | 24 | private DashboardContext dashboardContext; 25 | 26 | public DashboardContextInjector() { 27 | dashboardContext = new DashboardContext(); 28 | } 29 | 30 | public DashboardContextInjector(DashboardContext dashboardContext) { 31 | this.dashboardContext = dashboardContext; 32 | } 33 | 34 | public DashboardContext getDashboardContext() { 35 | return dashboardContext; 36 | } 37 | 38 | @Override 39 | public void onInstantiation(Component component) { 40 | if (component instanceof DashboardContextAware) { 41 | ((DashboardContextAware) component).setDashboardContext(dashboardContext); 42 | } 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/web/DashboardEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.web; 14 | 15 | import org.apache.wicket.ajax.AjaxRequestTarget; 16 | 17 | /** 18 | * @author Decebal Suiu 19 | */ 20 | public class DashboardEvent { 21 | 22 | public enum EventType { 23 | WIDGET_ADDED, 24 | WIDGET_REMOVED, 25 | WIDGETS_SORTED; 26 | } 27 | 28 | private AjaxRequestTarget target; 29 | private EventType type; 30 | private Object detail; 31 | 32 | public DashboardEvent(AjaxRequestTarget target, EventType type, Object detail) { 33 | this.type = type; 34 | this.detail = detail; 35 | this.target = target; 36 | } 37 | 38 | public AjaxRequestTarget getTarget() { 39 | return target; 40 | } 41 | 42 | public EventType getType() { 43 | return type; 44 | } 45 | 46 | public Object getDetail() { 47 | return detail; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/web/DashboardPanel.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 |
6 |
7 |
8 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/web/DashboardResourcesBehavior.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.web; 14 | 15 | import org.apache.wicket.Component; 16 | import org.apache.wicket.behavior.Behavior; 17 | import org.apache.wicket.markup.head.CssHeaderItem; 18 | import org.apache.wicket.markup.head.IHeaderResponse; 19 | import org.apache.wicket.markup.head.JavaScriptHeaderItem; 20 | 21 | /** 22 | * Provides required resources (JS, CSS) in a head. 23 | * Should be attached to a component which require these resources 24 | * @author Decebal Suiu 25 | */ 26 | public class DashboardResourcesBehavior extends Behavior { 27 | 28 | private static final long serialVersionUID = 1L; 29 | 30 | @Override 31 | public void renderHead(Component component, IHeaderResponse response) { 32 | super.renderHead(component, response); 33 | 34 | DashboardSettings settings = DashboardSettings.get(); 35 | 36 | if (settings.isIncludeJQuery()) { 37 | response.render(JavaScriptHeaderItem.forReference(settings.getJQueryReference())); 38 | } 39 | 40 | if (settings.isIncludeJQueryUI()) { 41 | response.render(JavaScriptHeaderItem.forReference(settings.getJQueryUIReference())); 42 | } 43 | 44 | if (settings.isIncludeJQueryJson()) { 45 | response.render(JavaScriptHeaderItem.forReference(settings.getJQueryJsonReference())); 46 | } 47 | 48 | if (settings.isIncludeJavaScript()) { 49 | response.render(JavaScriptHeaderItem.forReference(settings.getJavaScriptReference())); 50 | } 51 | 52 | if (settings.isIncludeCss()) { 53 | response.render(CssHeaderItem.forReference(settings.getCssReference())); 54 | if (settings.isRtl()) { 55 | response.render(CssHeaderItem.forReference(settings.getRtlCssReference())); 56 | } 57 | } 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/web/SortableAjaxBehavior.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.web; 14 | 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | 18 | import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior; 19 | import org.apache.wicket.ajax.AjaxRequestTarget; 20 | import org.apache.wicket.ajax.attributes.AjaxRequestAttributes; 21 | 22 | import ro.fortsoft.wicket.dashboard.WidgetLocation; 23 | 24 | import com.google.gson.Gson; 25 | 26 | /** 27 | * @author Decebal Suiu 28 | */ 29 | public abstract class SortableAjaxBehavior extends AbstractDefaultAjaxBehavior { 30 | 31 | private static final long serialVersionUID = 1L; 32 | 33 | /** Sorted identifiant into the request */ 34 | private static final String JSON_DATA = "data"; 35 | 36 | public abstract void onSort(AjaxRequestTarget target, Map widgetLocations); 37 | 38 | @Override 39 | protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { 40 | super.updateAjaxAttributes(attributes); 41 | 42 | StringBuilder buffer = new StringBuilder(); 43 | buffer.append("var data = serializeWidgetLocations();"); 44 | buffer.append("return {'" + JSON_DATA + "': data};"); 45 | 46 | attributes.getDynamicExtraParameters().add(buffer); 47 | } 48 | 49 | @Override 50 | protected void respond(AjaxRequestTarget target) { 51 | String jsonData = getComponent().getRequest().getRequestParameters().getParameterValue(JSON_DATA).toString(); 52 | Item[] items = getItems(jsonData); 53 | Map locations = new HashMap(); 54 | for (Item item : items) { 55 | WidgetLocation location = new WidgetLocation(item.column, item.sortIndex); 56 | locations.put(item.widget, location); 57 | } 58 | 59 | onSort(target, locations); 60 | } 61 | 62 | private Item[] getItems(String jsonData) { 63 | Gson gson = new Gson(); 64 | Item[] items = gson.fromJson(jsonData, Item[].class); 65 | /* 66 | System.out.println(items.length); 67 | for (Item item : items) { 68 | System.out.println(item); 69 | } 70 | */ 71 | 72 | return items; 73 | } 74 | 75 | static class Item { 76 | 77 | public int column; 78 | public String widget; 79 | public int sortIndex; 80 | 81 | @Override 82 | public String toString() { 83 | StringBuffer buffer = new StringBuffer(); 84 | buffer.append("Item["); 85 | buffer.append("column = ").append(column); 86 | buffer.append(" widget = ").append(widget); 87 | buffer.append(" sortIndex = ").append(sortIndex); 88 | buffer.append("]"); 89 | 90 | return buffer.toString(); 91 | } 92 | 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/web/WidgetActionsPanel.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/web/WidgetActionsPanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.web; 14 | 15 | import org.apache.wicket.AttributeModifier; 16 | import org.apache.wicket.markup.html.link.AbstractLink; 17 | import org.apache.wicket.markup.html.list.ListItem; 18 | import org.apache.wicket.markup.html.list.ListView; 19 | import org.apache.wicket.markup.html.panel.GenericPanel; 20 | import org.apache.wicket.model.IModel; 21 | import org.apache.wicket.model.LoadableDetachableModel; 22 | import ro.fortsoft.wicket.dashboard.Widget; 23 | import ro.fortsoft.wicket.dashboard.WidgetAction; 24 | 25 | import java.util.List; 26 | 27 | /** 28 | * @author Decebal Suiu 29 | */ 30 | public class WidgetActionsPanel extends GenericPanel implements DashboardContextAware { 31 | 32 | private static final long serialVersionUID = 1L; 33 | 34 | private transient DashboardContext dashboardContext; 35 | 36 | public WidgetActionsPanel(String id, IModel model) { 37 | super(id, model); 38 | 39 | IModel> actionsModel = new LoadableDetachableModel>() { 40 | 41 | private static final long serialVersionUID = 1L; 42 | 43 | @Override 44 | protected List load() { 45 | return dashboardContext.getWidgetActionsFactory().createWidgetActions(getWidget()); 46 | } 47 | 48 | }; 49 | ListView actionsView = new ListView("action", actionsModel) { 50 | 51 | private static final long serialVersionUID = 1L; 52 | 53 | @Override 54 | protected void populateItem(ListItem item) { 55 | WidgetAction action = item.getModelObject(); 56 | AbstractLink link = action.getLink("link"); 57 | link.add(action.getImage("image")); 58 | link.add(AttributeModifier.replace("title", action.getTooltip())); 59 | item.add(link); 60 | } 61 | 62 | }; 63 | add(actionsView); 64 | } 65 | 66 | @Override 67 | public void setDashboardContext(DashboardContext dashboardContext) { 68 | this.dashboardContext = dashboardContext; 69 | } 70 | 71 | private Widget getWidget() { 72 | return getModelObject(); 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/web/WidgetHeaderPanel.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 |
7 |
8 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/web/WidgetHeaderPanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.web; 14 | 15 | import org.apache.wicket.AttributeModifier; 16 | import org.apache.wicket.ajax.AjaxEventBehavior; 17 | import org.apache.wicket.ajax.AjaxRequestTarget; 18 | import org.apache.wicket.markup.head.IHeaderResponse; 19 | import org.apache.wicket.markup.head.OnDomReadyHeaderItem; 20 | import org.apache.wicket.markup.html.basic.Label; 21 | import org.apache.wicket.markup.html.image.Image; 22 | import org.apache.wicket.markup.html.panel.GenericPanel; 23 | import org.apache.wicket.model.AbstractReadOnlyModel; 24 | import org.apache.wicket.model.IModel; 25 | import org.apache.wicket.model.PropertyModel; 26 | import org.apache.wicket.request.resource.PackageResourceReference; 27 | import org.apache.wicket.request.resource.ResourceReference; 28 | import ro.fortsoft.wicket.dashboard.Dashboard; 29 | import ro.fortsoft.wicket.dashboard.Widget; 30 | 31 | /** 32 | * @author Decebal Suiu 33 | */ 34 | public class WidgetHeaderPanel extends GenericPanel implements DashboardContextAware { 35 | 36 | private static final long serialVersionUID = 1L; 37 | 38 | private transient DashboardContext dashboardContext; 39 | 40 | public WidgetHeaderPanel(String id, IModel model) { 41 | super(id, model); 42 | 43 | setMarkupId("header-" + getModelObject().getId()); 44 | 45 | final Image toggle = new Image("toggle", "") { 46 | 47 | @Override 48 | protected ResourceReference getImageResourceReference() { 49 | String name = getWidget().isCollapsed() ? "res/up.png" : "res/down.png"; 50 | 51 | return new PackageResourceReference(WidgetHeaderPanel.class, name); 52 | } 53 | 54 | }; 55 | 56 | toggle.setOutputMarkupId(true); 57 | toggle.add(new AjaxEventBehavior("click") { 58 | 59 | private static final long serialVersionUID = 1L; 60 | 61 | @Override 62 | protected void onEvent(AjaxRequestTarget target) { 63 | Widget widget = getWidget(); 64 | 65 | // change widget's collapsed property 66 | widget.setCollapsed(!widget.isCollapsed()); 67 | 68 | // save the new state of widget/dashboard 69 | Dashboard dashboard = findParent(DashboardPanel.class).getDashboard(); 70 | dashboardContext.getDashboardPersister().save(dashboard); 71 | 72 | // change toggle's image 73 | target.add(toggle); 74 | 75 | // hide/show the widget's view 76 | WidgetView widgetView = findParent(WidgetPanel.class).getWidgetView(); 77 | target.add(widgetView); 78 | } 79 | 80 | }); 81 | toggle.add(new AttributeModifier("title", new AbstractReadOnlyModel() { 82 | 83 | private static final long serialVersionUID = 1L; 84 | 85 | @Override 86 | public String getObject() { 87 | return getWidget().isCollapsed() ? getString("expand") : getString("collapse"); 88 | } 89 | 90 | })); 91 | add(toggle); 92 | 93 | add(new Label("title", new PropertyModel(model, "title"))); 94 | 95 | WidgetActionsPanel actionsPanel = new WidgetActionsPanel("actions", model); 96 | add(actionsPanel); 97 | } 98 | 99 | public Widget getWidget() { 100 | return getModelObject(); 101 | } 102 | 103 | @Override 104 | public void setDashboardContext(DashboardContext dashboardContext) { 105 | this.dashboardContext = dashboardContext; 106 | } 107 | 108 | @Override 109 | public void renderHead(IHeaderResponse response) { 110 | super.renderHead(response); 111 | 112 | StringBuilder statement = new StringBuilder("$('#").append(getMarkupId()).append("').on('mouseover', function(ev) {"); 113 | statement.append(" $(this).find('.dragbox-actions').show();"). 114 | append("}).on('mouseout', function(ev) {"). 115 | append(" $(this).find('.dragbox-actions').hide();"). 116 | append("});"); 117 | 118 | response.render(OnDomReadyHeaderItem.forScript(statement.toString())); 119 | } 120 | 121 | } 122 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/web/WidgetModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.web; 14 | 15 | import org.apache.wicket.model.IModel; 16 | 17 | import ro.fortsoft.wicket.dashboard.Dashboard; 18 | import ro.fortsoft.wicket.dashboard.Widget; 19 | import ro.fortsoft.wicket.dashboard.web.util.CascadingLoadableDetachableModel; 20 | 21 | /** 22 | * @author Decebal Suiu 23 | */ 24 | public class WidgetModel extends CascadingLoadableDetachableModel { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | private String widgetId; 29 | 30 | public WidgetModel(IModel dashboardModel, String widgetId) { 31 | super(dashboardModel); 32 | 33 | this.widgetId = widgetId; 34 | } 35 | 36 | public String getWidgetId() { 37 | return widgetId; 38 | } 39 | 40 | public void setWidgetId(String widgetId) { 41 | this.widgetId = widgetId; 42 | } 43 | 44 | @Override 45 | public Widget load(Dashboard parentObject) { 46 | return parentObject.getWidget(widgetId); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/web/WidgetPanel.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 |
6 |
7 |
8 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/web/WidgetPanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.web; 14 | 15 | import org.apache.wicket.markup.html.panel.EmptyPanel; 16 | import org.apache.wicket.markup.html.panel.GenericPanel; 17 | import org.apache.wicket.markup.html.panel.Panel; 18 | import org.apache.wicket.model.IModel; 19 | 20 | import ro.fortsoft.wicket.dashboard.Widget; 21 | 22 | /** 23 | * Wicket {@link GenericPanel} to render a widget on a page 24 | * @author Decebal Suiu 25 | */ 26 | public class WidgetPanel extends GenericPanel { 27 | 28 | private static final long serialVersionUID = 1L; 29 | 30 | private WidgetHeaderPanel widgetHeaderPanel; 31 | private WidgetView widgetView; 32 | private Panel settingsPanel; 33 | 34 | public WidgetPanel(String id, IModel model) { 35 | super(id, model); 36 | 37 | Widget widget = model.getObject(); 38 | 39 | setOutputMarkupId(true); 40 | 41 | widgetHeaderPanel = new WidgetHeaderPanel("header", model); 42 | add(widgetHeaderPanel); 43 | 44 | if (model.getObject().hasSettings()) { 45 | settingsPanel = widget.createSettingsPanel("settings"); 46 | } else { 47 | settingsPanel = new EmptyPanel("settings"); 48 | } 49 | settingsPanel.setOutputMarkupPlaceholderTag(true); 50 | settingsPanel.setVisible(false); 51 | add(settingsPanel); 52 | 53 | widgetView = model.getObject().createView("content"); 54 | add(widgetView); 55 | } 56 | 57 | public WidgetHeaderPanel getWidgetHeaderPanel() { 58 | return widgetHeaderPanel; 59 | } 60 | 61 | public WidgetView getWidgetView() { 62 | return widgetView; 63 | } 64 | 65 | public Panel getSettingsPanel() { 66 | return settingsPanel; 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/web/WidgetView.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Widget content here! 5 | 6 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/web/WidgetView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.web; 14 | 15 | import org.apache.wicket.Component; 16 | import org.apache.wicket.markup.html.panel.GenericPanel; 17 | import org.apache.wicket.model.IModel; 18 | 19 | import ro.fortsoft.wicket.dashboard.Widget; 20 | 21 | /** 22 | * Root for all wicket {@link Component}s which are being used for rendering of widget's content 23 | * @author Decebal Suiu 24 | */ 25 | public class WidgetView extends GenericPanel { 26 | 27 | private static final long serialVersionUID = 1L; 28 | 29 | public WidgetView(String id, IModel model) { 30 | super(id, model); 31 | 32 | setOutputMarkupPlaceholderTag(true); 33 | } 34 | 35 | public Widget getWidget() { 36 | return getModelObject(); 37 | } 38 | 39 | @Override 40 | protected void onConfigure() { 41 | super.onConfigure(); 42 | 43 | setVisible(!getWidget().isCollapsed()); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/web/res/dashboard-rtl.css: -------------------------------------------------------------------------------- 1 | .column { 2 | float: right !important; 3 | } 4 | 5 | .dragbox-actions { 6 | float: left !important; 7 | } 8 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/web/res/dashboard.css: -------------------------------------------------------------------------------- 1 | .column { 2 | /* 3 | width: 49.5%; 4 | */ 5 | margin-right: .5%; 6 | min-height: 320px; 7 | float: left; 8 | } 9 | 10 | ul.column { 11 | list-style-type: none; 12 | margin: 0; 13 | padding: 0; 14 | } 15 | 16 | .dragbox { 17 | margin: 5px 2px 20px; 18 | background: #fff; 19 | position: relative; 20 | border: 1px solid #ddd; 21 | border-radius: 5px; 22 | } 23 | 24 | .dragbox-header { 25 | margin: 0; 26 | padding: 5px; 27 | background: #f0f0f0; 28 | color: #000; 29 | border-bottom: 1px solid #eee; 30 | cursor: move; 31 | border-top-left-radius: 5px; 32 | border-top-right-radius: 5px; 33 | } 34 | 35 | .dragbox-header img { 36 | margin: 0; 37 | padding: 0; 38 | } 39 | 40 | .dragbox-toggle { 41 | display: inline; 42 | margin-right: 3px; 43 | cursor: pointer; 44 | } 45 | 46 | .dragbox-title { 47 | display: inline; 48 | font-weight: bold; 49 | } 50 | 51 | .dragbox-actions { 52 | float: right; 53 | margin: 0; 54 | padding: 0; 55 | display: none; 56 | } 57 | 58 | .dragbox-actions ul { 59 | padding: 0; 60 | margin: 0; 61 | } 62 | 63 | .dragbox-actions ul li { 64 | display: inline; 65 | margin: 0 1px 0 1px; 66 | } 67 | 68 | .dragbox-actions ul li a { 69 | text-decoration: none; 70 | } 71 | 72 | .dragbox-actions ul li a img { 73 | border: 0; 74 | margin: 0; 75 | } 76 | 77 | .dragbox-content { 78 | background: #fff; 79 | min-height: 60px; 80 | margin: 5px; 81 | line-height: 1.5em; 82 | overflow: auto; 83 | } 84 | 85 | .placeholder { 86 | background: #f0f0f0; 87 | border: 1px dashed #ddd; 88 | } 89 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/web/res/dashboard.js: -------------------------------------------------------------------------------- 1 | function serializeWidgetLocations() { 2 | var items = []; 3 | $("ul.column").each(function() { 4 | var columnId = $(this).attr("id"); 5 | var column = columnId.substring(7); // "column-".length 6 | $(this).children().each(function(i) { 7 | var widgetId = $(this).attr("id"); 8 | var widget = widgetId.substring(7); // "widget-".length 9 | // create item object for current panel 10 | var item = { 11 | column : column, 12 | widget : widget, 13 | sortIndex : i 14 | }; 15 | 16 | // push item object into items array 17 | items.push(item); 18 | }); 19 | }); 20 | 21 | // pass items variable to server to save state 22 | var data = $.toJSON(items); 23 | // alert(data); 24 | 25 | return data; 26 | } 27 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/web/res/delete.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decebals/wicket-dashboard/ece9250c8bcc8f4fe66b8ea3ba57fdb31561c805/core/src/main/java/ro/fortsoft/wicket/dashboard/web/res/delete.gif -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/web/res/down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decebals/wicket-dashboard/ece9250c8bcc8f4fe66b8ea3ba57fdb31561c805/core/src/main/java/ro/fortsoft/wicket/dashboard/web/res/down.png -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/web/res/edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decebals/wicket-dashboard/ece9250c8bcc8f4fe66b8ea3ba57fdb31561c805/core/src/main/java/ro/fortsoft/wicket/dashboard/web/res/edit.png -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/web/res/jquery.json-2.2.min.js: -------------------------------------------------------------------------------- 1 | 2 | (function($){$.toJSON=function(o) 3 | {if(typeof(JSON)=='object'&&JSON.stringify) 4 | return JSON.stringify(o);var type=typeof(o);if(o===null) 5 | return"null";if(type=="undefined") 6 | return undefined;if(type=="number"||type=="boolean") 7 | return o+"";if(type=="string") 8 | return $.quoteString(o);if(type=='object') 9 | {if(typeof o.toJSON=="function") 10 | return $.toJSON(o.toJSON());if(o.constructor===Date) 11 | {var month=o.getUTCMonth()+1;if(month<10)month='0'+month;var day=o.getUTCDate();if(day<10)day='0'+day;var year=o.getUTCFullYear();var hours=o.getUTCHours();if(hours<10)hours='0'+hours;var minutes=o.getUTCMinutes();if(minutes<10)minutes='0'+minutes;var seconds=o.getUTCSeconds();if(seconds<10)seconds='0'+seconds;var milli=o.getUTCMilliseconds();if(milli<100)milli='0'+milli;if(milli<10)milli='0'+milli;return'"'+year+'-'+month+'-'+day+'T'+ 12 | hours+':'+minutes+':'+seconds+'.'+milli+'Z"';} 13 | if(o.constructor===Array) 14 | {var ret=[];for(var i=0;i extends AjaxLink { 24 | 25 | private static final long serialVersionUID = 1L; 26 | 27 | private String confirmMessage; 28 | 29 | public AjaxConfirmLink(String id) { 30 | super(id); 31 | } 32 | 33 | public AjaxConfirmLink(String id, IModel model) { 34 | super(id, model); 35 | } 36 | 37 | public AjaxConfirmLink(String id, String confirmMessage) { 38 | super(id); 39 | 40 | this.confirmMessage = confirmMessage; 41 | } 42 | 43 | public AjaxConfirmLink(String id, IModel model, String confirmMessage) { 44 | super(id, model); 45 | 46 | this.confirmMessage = confirmMessage; 47 | } 48 | 49 | 50 | public void setConfirmMessage(String confirmMessage) { 51 | this.confirmMessage = confirmMessage; 52 | } 53 | 54 | @Override 55 | protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { 56 | super.updateAjaxAttributes(attributes); 57 | 58 | if (!Strings.isEmpty(confirmMessage)) { 59 | attributes.getAjaxCallListeners().add(new ConfirmAjaxCallListener(confirmMessage)); 60 | } 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/web/util/CascadingLoadableDetachableModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.web.util; 14 | 15 | import org.apache.wicket.model.IModel; 16 | import org.apache.wicket.model.LoadableDetachableModel; 17 | 18 | /** 19 | * @author Decebal Suiu 20 | */ 21 | public abstract class CascadingLoadableDetachableModel extends LoadableDetachableModel { 22 | 23 | private static final long serialVersionUID = 1L; 24 | 25 | protected IModel

parentModel; 26 | 27 | public CascadingLoadableDetachableModel(IModel

parentModel) { 28 | super(); 29 | 30 | this.parentModel = parentModel; 31 | } 32 | 33 | @Override 34 | public void detach() { 35 | super.detach(); 36 | 37 | parentModel.detach(); 38 | } 39 | 40 | public abstract M load(P parentObject); 41 | 42 | @Override 43 | protected M load() { 44 | return load(parentModel.getObject()); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/web/util/ConfirmAjaxCallListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.web.util; 14 | 15 | import org.apache.wicket.ajax.attributes.AjaxCallListener; 16 | import org.apache.wicket.core.util.string.JavaScriptUtils; 17 | 18 | /** 19 | * @author Decebal Suiu 20 | */ 21 | public class ConfirmAjaxCallListener extends AjaxCallListener { 22 | 23 | private static final long serialVersionUID = 1L; 24 | 25 | public ConfirmAjaxCallListener(String confirmMessage) { 26 | CharSequence message = JavaScriptUtils.escapeQuotes(confirmMessage); 27 | StringBuilder precondition = new StringBuilder("if(!confirm('").append(message).append("')) { return false; };"); 28 | onPrecondition(precondition); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/wicket-package.properties: -------------------------------------------------------------------------------- 1 | # widget collapse/expand 2 | collapse=Collapse 3 | expand=Expand 4 | 5 | # widget actions 6 | refresh=Refresh 7 | delete=Delete 8 | settings=Settings 9 | 10 | deleteAsk=Delete widget "${}"? -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/wicket-package_de.properties: -------------------------------------------------------------------------------- 1 | # widget collapse/expand 2 | collapse=Einklappen 3 | expand=Ausklappen 4 | 5 | # widget actions 6 | refresh=Neu laden 7 | delete=Löschen 8 | settings=Einstellungen 9 | 10 | deleteAsk=Widget "${}" löschen? -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/wicket-package_fr.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decebals/wicket-dashboard/ece9250c8bcc8f4fe66b8ea3ba57fdb31561c805/core/src/main/java/ro/fortsoft/wicket/dashboard/wicket-package_fr.properties -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/wicket-package_ro.properties: -------------------------------------------------------------------------------- 1 | # widget collapse/expand 2 | collapse=Colapseaza 3 | expand=Extinde 4 | 5 | # widget actions 6 | refresh=Reincarca 7 | delete=Sterge 8 | settings=Proprietati 9 | 10 | deleteAsk=Sterge widget "${}"? -------------------------------------------------------------------------------- /core/src/main/java/ro/fortsoft/wicket/dashboard/wicket-package_ru.properties: -------------------------------------------------------------------------------- 1 | # widget collapse/expand 2 | collapse=Свернуть 3 | expand=Развернуть 4 | 5 | # widget actions 6 | refresh=Обновить 7 | delete=Удалить 8 | settings=Настройки 9 | 10 | deleteAsk=Удалить виджет "${}"? 11 | -------------------------------------------------------------------------------- /core/src/main/java/wicket.properties: -------------------------------------------------------------------------------- 1 | initializer=ro.fortsoft.wicket.dashboard.DashboardContextInitializer -------------------------------------------------------------------------------- /demo/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ro.fortsoft.wicket.dashboard 6 | wicket-dashboard-parent 7 | 0.14.0-SNAPSHOT 8 | 9 | 10 | 4.0.0 11 | wicket-dashboard-demo 12 | 0.14.0-SNAPSHOT 13 | war 14 | Wicket Dashboard Demo 15 | 16 | 17 | 7.5.0.v20110901 18 | 19 | 20 | 21 | 22 | 23 | org.mortbay.jetty 24 | jetty-maven-plugin 25 | ${jetty.version} 26 | 27 | 28 | 29 | 8081 30 | 3600000 31 | 32 | 33 | 34 | 35 | 36 | 37 | org.apache.maven.plugins 38 | maven-war-plugin 39 | 2.1.1 40 | 41 | root 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | ro.fortsoft.wicket.dashboard 50 | wicket-dashboard-core 51 | ${project.version} 52 | 53 | 54 | 55 | ro.fortsoft.wicket.dashboard.widgets 56 | wicket-dashboard-ofchart 57 | ${project.version} 58 | 59 | 60 | 61 | ro.fortsoft.wicket.dashboard.widgets 62 | wicket-dashboard-loremipsum 63 | ${project.version} 64 | 65 | 66 | 67 | ro.fortsoft.wicket.dashboard.widgets 68 | wicket-dashboard-jqplot 69 | ${project.version} 70 | 71 | 72 | 73 | ro.fortsoft.wicket.dashboard.widgets 74 | wicket-dashboard-justgage 75 | ${project.version} 76 | 77 | 78 | 79 | ro.fortsoft.wicket.dashboard.widgets 80 | wicket-dashboard-wicked-charts 81 | ${project.version} 82 | 83 | 84 | 85 | 86 | log4j 87 | log4j 88 | ${log4j.version} 89 | 90 | 91 | 92 | org.slf4j 93 | slf4j-api 94 | ${slf4j.version} 95 | 96 | 97 | 98 | org.slf4j 99 | slf4j-log4j12 100 | ${slf4j.version} 101 | 102 | 103 | 104 | 105 | junit 106 | junit 107 | 4.8.2 108 | test 109 | 110 | 111 | 112 | 113 | org.eclipse.jetty.aggregate 114 | jetty-all-server 115 | ${jetty.version} 116 | provided 117 | 118 | 119 | 120 | 121 | -------------------------------------------------------------------------------- /demo/src/main/java/ro/fortsoft/wicket/dashboard/demo/AddWidgetPage.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |

11 | 12 | 13 | -------------------------------------------------------------------------------- /demo/src/main/java/ro/fortsoft/wicket/dashboard/demo/AddWidgetPage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.demo; 14 | 15 | import org.apache.wicket.markup.html.WebPage; 16 | import org.apache.wicket.model.Model; 17 | 18 | import ro.fortsoft.wicket.dashboard.Dashboard; 19 | 20 | /** 21 | * @author Decebal Suiu 22 | */ 23 | public class AddWidgetPage extends WebPage { 24 | 25 | private static final long serialVersionUID = 1L; 26 | 27 | public AddWidgetPage() { 28 | Dashboard dashboard = WicketApplication.get().getDashboard(); 29 | add(new AddWidgetPanel("addWidgetPanel", new Model(dashboard))); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /demo/src/main/java/ro/fortsoft/wicket/dashboard/demo/AddWidgetPanel$WidgetDescriptorPanel.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | By 6 |
7 | Add widget 8 | 9 |
10 | -------------------------------------------------------------------------------- /demo/src/main/java/ro/fortsoft/wicket/dashboard/demo/AddWidgetPanel.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | « Dashboard 6 |
7 |
8 |
9 |
10 |
11 | -------------------------------------------------------------------------------- /demo/src/main/java/ro/fortsoft/wicket/dashboard/demo/DemoWidgetActionsFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.demo; 14 | 15 | import java.util.List; 16 | 17 | import ro.fortsoft.wicket.dashboard.DefaultWidgetActionsFactory; 18 | import ro.fortsoft.wicket.dashboard.Widget; 19 | import ro.fortsoft.wicket.dashboard.WidgetAction; 20 | import ro.fortsoft.wicket.dashboard.web.AbstractWidgetAction; 21 | import ro.fortsoft.wicket.dashboard.web.DefaultWidgetActions; 22 | 23 | /** 24 | * @author Decebal Suiu 25 | */ 26 | public class DemoWidgetActionsFactory extends DefaultWidgetActionsFactory { 27 | 28 | @Override 29 | public List createWidgetActions(Widget widget) { 30 | List widgetActions = super.createWidgetActions(widget); 31 | widgetActions.add(0, new DetachWidgetAction(widget)); 32 | 33 | /* 34 | for (WidgetAction action : widgetActions) { 35 | if (action instanceof DefaultWidgetActions.Settings) { 36 | // change the icon (relative to context) 37 | ((AbstractWidgetAction) action).setImage("/images/edit.png"); 38 | break; 39 | } 40 | } 41 | */ 42 | 43 | return widgetActions; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /demo/src/main/java/ro/fortsoft/wicket/dashboard/demo/DetachWidgetAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.demo; 14 | 15 | import org.apache.wicket.markup.html.link.AbstractLink; 16 | import org.apache.wicket.markup.html.link.BookmarkablePageLink; 17 | import org.apache.wicket.markup.html.link.PopupSettings; 18 | import org.apache.wicket.model.ResourceModel; 19 | import org.apache.wicket.request.mapper.parameter.PageParameters; 20 | import ro.fortsoft.wicket.dashboard.Widget; 21 | import ro.fortsoft.wicket.dashboard.web.AbstractWidgetAction; 22 | 23 | /** 24 | * @author Decebal Suiu 25 | */ 26 | public class DetachWidgetAction extends AbstractWidgetAction { 27 | 28 | private static final long serialVersionUID = 1L; 29 | 30 | public DetachWidgetAction(Widget widget) { 31 | super(widget); 32 | 33 | tooltip = new ResourceModel("detach"); 34 | 35 | setImage(HomePage.class, "detach.png"); 36 | } 37 | 38 | @Override 39 | public AbstractLink getLink(String id) { 40 | PageParameters parameters = new PageParameters(); 41 | parameters.add("id", widget.getId()); 42 | BookmarkablePageLink link = new BookmarkablePageLink(id, WidgetPage.class, parameters); 43 | 44 | PopupSettings popupSettings = new PopupSettings(widget.getTitle()).setHeight(320).setWidth(550); 45 | link.setPopupSettings(popupSettings); 46 | 47 | return link; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /demo/src/main/java/ro/fortsoft/wicket/dashboard/demo/HomePage.html: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | Add Widget » 15 |
16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /demo/src/main/java/ro/fortsoft/wicket/dashboard/demo/HomePage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.demo; 14 | 15 | import org.apache.wicket.markup.html.WebPage; 16 | import org.apache.wicket.markup.html.link.BookmarkablePageLink; 17 | import org.apache.wicket.model.Model; 18 | 19 | import ro.fortsoft.wicket.dashboard.Dashboard; 20 | import ro.fortsoft.wicket.dashboard.web.DashboardPanel; 21 | 22 | /** 23 | * @author Decebal Suiu 24 | */ 25 | public class HomePage extends WebPage { 26 | 27 | private static final long serialVersionUID = 1L; 28 | 29 | public HomePage() { 30 | add(new BookmarkablePageLink("addWidget", AddWidgetPage.class)); 31 | 32 | Dashboard dashboard = WicketApplication.get().getDashboard(); 33 | add(new DashboardPanel("dashboard", new Model(dashboard))); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /demo/src/main/java/ro/fortsoft/wicket/dashboard/demo/WicketApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.demo; 14 | 15 | import org.apache.wicket.Page; 16 | import org.apache.wicket.protocol.http.WebApplication; 17 | 18 | import ro.fortsoft.wicket.dashboard.Dashboard; 19 | import ro.fortsoft.wicket.dashboard.DashboardContextInitializer; 20 | import ro.fortsoft.wicket.dashboard.DefaultDashboard; 21 | import ro.fortsoft.wicket.dashboard.demo.jqplot.DemoChartFactory; 22 | import ro.fortsoft.wicket.dashboard.demo.justgage.DemoJustGageFactory; 23 | import ro.fortsoft.wicket.dashboard.demo.ofchart.DemoChartDataFactory; 24 | import ro.fortsoft.wicket.dashboard.demo.wickedCharts.DemoHighChartsFactory; 25 | import ro.fortsoft.wicket.dashboard.web.DashboardContext; 26 | import ro.fortsoft.wicket.dashboard.widget.jqplot.JqPlotWidget; 27 | import ro.fortsoft.wicket.dashboard.widget.jqplot.JqPlotWidgetDescriptor; 28 | import ro.fortsoft.wicket.dashboard.widget.justgage.JustGageWidget; 29 | import ro.fortsoft.wicket.dashboard.widget.justgage.JustGageWidgetDescriptor; 30 | import ro.fortsoft.wicket.dashboard.widget.loremipsum.LoremIpsumWidgetDescriptor; 31 | import ro.fortsoft.wicket.dashboard.widget.ofchart.ChartWidget; 32 | import ro.fortsoft.wicket.dashboard.widget.ofchart.ChartWidgetDescriptor; 33 | import ro.fortsoft.wicket.dashboard.widgets.wicked.charts.HighChartsWidget; 34 | import ro.fortsoft.wicket.dashboard.widgets.wicked.charts.HighChartsWidgetDescriptor; 35 | 36 | /** 37 | * @author Decebal Suiu 38 | */ 39 | public class WicketApplication extends WebApplication { 40 | 41 | private Dashboard dashboard; 42 | 43 | public static WicketApplication get() { 44 | return (WicketApplication) WebApplication.get(); 45 | } 46 | 47 | @Override 48 | public void init() { 49 | super.init(); 50 | 51 | // markup settings 52 | getMarkupSettings().setStripWicketTags(true); 53 | getMarkupSettings().setDefaultMarkupEncoding("UTF-8"); 54 | 55 | // exception settings 56 | getResourceSettings().setThrowExceptionOnMissingResource(false); 57 | 58 | // mounts 59 | mountPage("add-widget", AddWidgetPage.class); 60 | mountPage("widget", WidgetPage.class); 61 | 62 | // >>> begin dashboard settings 63 | 64 | // register some widgets 65 | DashboardContext dashboardContext = getDashboardContext(); 66 | dashboardContext.getWidgetRegistry() 67 | .registerWidget(new LoremIpsumWidgetDescriptor()) 68 | .registerWidget(new ChartWidgetDescriptor()) 69 | .registerWidget(new JqPlotWidgetDescriptor()) 70 | .registerWidget(new JustGageWidgetDescriptor()) 71 | .registerWidget(new HighChartsWidgetDescriptor()); 72 | 73 | // add a custom action for all widgets 74 | dashboardContext.setWidgetActionsFactory(new DemoWidgetActionsFactory()); 75 | 76 | // set some (data) factory 77 | ChartWidget.setChartDataFactory(new DemoChartDataFactory()); 78 | JqPlotWidget.setChartFactory(new DemoChartFactory()); 79 | JustGageWidget.setJustGageFactory(new DemoJustGageFactory()); 80 | HighChartsWidget.setHighChartsFactory(new DemoHighChartsFactory()); 81 | 82 | // init dashboard from context 83 | initDashboard(); 84 | 85 | // <<< end dashboard settings 86 | } 87 | 88 | @Override 89 | public Class getHomePage() { 90 | return HomePage.class; 91 | } 92 | 93 | /* 94 | // for test locale 95 | @Override 96 | public Session newSession(Request request, Response response) { 97 | Session session = super.newSession(request, response); 98 | session.setLocale(new Locale("ro", "RO")); 99 | 100 | return session; 101 | } 102 | */ 103 | 104 | public Dashboard getDashboard() { 105 | return dashboard; 106 | } 107 | 108 | private DashboardContext getDashboardContext() { 109 | return getMetaData(DashboardContextInitializer.DASHBOARD_CONTEXT_KEY); 110 | } 111 | 112 | private void initDashboard() { 113 | dashboard = getDashboardContext().getDashboardPersister().load(); 114 | if (dashboard == null) { 115 | dashboard = new DefaultDashboard("default", "Default"); 116 | } 117 | } 118 | 119 | } 120 | -------------------------------------------------------------------------------- /demo/src/main/java/ro/fortsoft/wicket/dashboard/demo/WicketApplication.properties: -------------------------------------------------------------------------------- 1 | detach=Detach -------------------------------------------------------------------------------- /demo/src/main/java/ro/fortsoft/wicket/dashboard/demo/WicketApplication_de.properties: -------------------------------------------------------------------------------- 1 | detach=Herauslösen -------------------------------------------------------------------------------- /demo/src/main/java/ro/fortsoft/wicket/dashboard/demo/WicketApplication_fr.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decebals/wicket-dashboard/ece9250c8bcc8f4fe66b8ea3ba57fdb31561c805/demo/src/main/java/ro/fortsoft/wicket/dashboard/demo/WicketApplication_fr.properties -------------------------------------------------------------------------------- /demo/src/main/java/ro/fortsoft/wicket/dashboard/demo/WicketApplication_ro.properties: -------------------------------------------------------------------------------- 1 | detach=Detaseaza -------------------------------------------------------------------------------- /demo/src/main/java/ro/fortsoft/wicket/dashboard/demo/WidgetPage.html: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | -------------------------------------------------------------------------------- /demo/src/main/java/ro/fortsoft/wicket/dashboard/demo/WidgetPage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.demo; 14 | 15 | import org.apache.wicket.markup.html.WebPage; 16 | import org.apache.wicket.request.mapper.parameter.PageParameters; 17 | 18 | import ro.fortsoft.wicket.dashboard.Dashboard; 19 | import ro.fortsoft.wicket.dashboard.Widget; 20 | 21 | /** 22 | * @author Decebal Suiu 23 | */ 24 | public class WidgetPage extends WebPage { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | public WidgetPage(PageParameters parameters) { 29 | super(parameters); 30 | 31 | String widgetId = parameters.get("id").toString(); 32 | Dashboard dashboard = WicketApplication.get().getDashboard(); 33 | Widget widget = dashboard.getWidget(widgetId); 34 | add(widget.createView("widget")); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /demo/src/main/java/ro/fortsoft/wicket/dashboard/demo/detach.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decebals/wicket-dashboard/ece9250c8bcc8f4fe66b8ea3ba57fdb31561c805/demo/src/main/java/ro/fortsoft/wicket/dashboard/demo/detach.png -------------------------------------------------------------------------------- /demo/src/main/java/ro/fortsoft/wicket/dashboard/demo/jqplot/DemoChartFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.demo.jqplot; 14 | 15 | import java.util.Arrays; 16 | import java.util.Map; 17 | 18 | import ro.fortsoft.wicket.dashboard.widget.jqplot.ChartFactory; 19 | import ro.fortsoft.wicket.dashboard.widget.jqplot.JqPlotWidget; 20 | import br.com.digilabs.jqplot.Chart; 21 | import br.com.digilabs.jqplot.chart.AreaChart; 22 | import br.com.digilabs.jqplot.chart.BarChart; 23 | import br.com.digilabs.jqplot.chart.LineChart; 24 | import br.com.digilabs.jqplot.chart.PieChart; 25 | import br.com.digilabs.jqplot.elements.Serie; 26 | 27 | /** 28 | * @author Decebal Suiu 29 | */ 30 | public class DemoChartFactory implements ChartFactory { 31 | 32 | @Override 33 | public Chart createChart(JqPlotWidget widget) { 34 | return getChart(widget.getSettings()); 35 | } 36 | 37 | private Chart getChart(Map settings) { 38 | Chart chart = null; 39 | 40 | String chartType = settings.get("chartType"); 41 | if (JqPlotWidget.BAR_TYPE.equals(chartType)) { 42 | chart = barChart(); 43 | } else if (JqPlotWidget.LINE_TYPE.equals(chartType)) { 44 | chart = lineChart(); 45 | } else if (JqPlotWidget.PIE_TYPE.equals(chartType)) { 46 | chart = pieChart(); 47 | } else if (JqPlotWidget.AREA_TYPE.equals(chartType)) { 48 | chart = areaChart(); 49 | } 50 | 51 | return chart; 52 | } 53 | 54 | public static Chart lineChart() { 55 | LineChart lineChart; 56 | lineChart = new LineChart("Line Chart"); 57 | lineChart.addValues(1, 2, 3, 4, 5); 58 | 59 | return lineChart; 60 | } 61 | 62 | public static Chart areaChart() { 63 | AreaChart areaChart; 64 | areaChart = new AreaChart("Area Char"); 65 | areaChart.addValue(Arrays.asList(11, 9, 5, 12, 14)); 66 | areaChart.addValue(Arrays.asList(4, 8, 5, 3, 6)); 67 | areaChart.addValue(Arrays.asList(12, 6, 13, 11, 2)); 68 | 69 | return areaChart; 70 | } 71 | 72 | public static Chart barChart() { 73 | BarChart barChart; 74 | barChart = new BarChart("Bar Chart"); 75 | 76 | barChart.setPadMin(1.05f); 77 | barChart.setStackSeries(true); 78 | barChart.setCaptureRightClick(true); 79 | barChart.setHighlightMouseDown(true); 80 | 81 | barChart.setBarMargin(30); 82 | barChart.setTicks("A", "B", "C", "D"); 83 | barChart.addValue(Arrays.asList(200, 600, 700, 1000)); 84 | barChart.addValue(Arrays.asList(200, 600, 700, 1000)); 85 | barChart.addValue(Arrays.asList(200, 600, 700, 1000)); 86 | 87 | // Texto das Legendas. 88 | barChart.addSeries(new Serie("A"), new Serie("B"), new Serie("C")); 89 | 90 | return barChart; 91 | } 92 | 93 | public static Chart pieChart() { 94 | PieChart pizzaChart = new PieChart("Pizza Chart"); 95 | pizzaChart.addValue("Drops", 10f); 96 | pizzaChart.addValue("Chocolate", 20f); 97 | pizzaChart.addValue("Jujuba", 5f); 98 | 99 | return pizzaChart; 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /demo/src/main/java/ro/fortsoft/wicket/dashboard/demo/justgage/DemoJustGageFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.demo.justgage; 14 | 15 | import ro.fortsoft.wicket.dashboard.widget.justgage.JustGage; 16 | import ro.fortsoft.wicket.dashboard.widget.justgage.JustGageFactory; 17 | import ro.fortsoft.wicket.dashboard.widget.justgage.JustGageWidget; 18 | 19 | /** 20 | * @author Decebal Suiu 21 | */ 22 | public class DemoJustGageFactory implements JustGageFactory{ 23 | 24 | @Override 25 | public JustGage createJustGage(JustGageWidget widget) { 26 | return new JustGage().setValue(4) 27 | .setMin(0) 28 | .setMax(10) 29 | .setTitle("Beers") 30 | .setGaugeColor("#F78000") 31 | .setLabel("average"); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /demo/src/main/java/ro/fortsoft/wicket/dashboard/demo/ofchart/DemoChartDataFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.demo.ofchart; 14 | 15 | import java.util.Map; 16 | 17 | import jofc2.model.Chart; 18 | import ro.fortsoft.wicket.dashboard.widget.ofchart.ChartDataFactory; 19 | import ro.fortsoft.wicket.dashboard.widget.ofchart.ChartWidget; 20 | 21 | /** 22 | * @author Decebal Suiu 23 | */ 24 | public class DemoChartDataFactory implements ChartDataFactory { 25 | 26 | @Override 27 | public String createChartData(ChartWidget widget) { 28 | return getChart(widget.getSettings()).toString(); 29 | } 30 | 31 | private Chart getChart(Map settings) { 32 | Chart chart = null; 33 | 34 | String chartType = settings.get("chartType"); 35 | if (ChartWidget.BAR_TYPE.equals(chartType)) { 36 | chart = DemoChartFactory.createDemoBarChart(); 37 | } else if (ChartWidget.DOUBLE_BAR_TYPE.equals(chartType)) { 38 | chart = DemoChartFactory.createDemoDoubleBarChart(); 39 | } else if (ChartWidget.LINE_TYPE.equals(chartType)) { 40 | chart = DemoChartFactory.createDemoLineChart(); 41 | } else if (ChartWidget.DOTED_LINE_TYPE.equals(chartType)) { 42 | chart = DemoChartFactory.createDemoDotedLineChart(); 43 | } else if (ChartWidget.PIE_TYPE.equals(chartType)) { 44 | chart = DemoChartFactory.createDemoPieChart(); 45 | } else if (ChartWidget.SCATTER_TYPE.equals(chartType)) { 46 | chart = DemoChartFactory.createDemoScatterChart(); 47 | } 48 | 49 | return chart; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /demo/src/main/java/ro/fortsoft/wicket/dashboard/demo/wickedCharts/DemoHighChartsFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Paul Bors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.demo.wickedCharts; 14 | 15 | import com.googlecode.wickedcharts.highcharts.options.Options; 16 | import com.googlecode.wickedcharts.highcharts.options.SeriesType; 17 | import ro.fortsoft.wicket.dashboard.widgets.wicked.charts.HighChartsFactory; 18 | import ro.fortsoft.wicket.dashboard.widgets.wicked.charts.HighChartsWidget; 19 | import ro.fortsoft.wicket.dashboard.widgets.wicked.charts.options.AngularGaugeOptions; 20 | import ro.fortsoft.wicket.dashboard.widgets.wicked.charts.options.AreaRangeOptions; 21 | import ro.fortsoft.wicket.dashboard.widgets.wicked.charts.options.AreaSplineOptions; 22 | import ro.fortsoft.wicket.dashboard.widgets.wicked.charts.options.BasicAreaOptions; 23 | import ro.fortsoft.wicket.dashboard.widgets.wicked.charts.options.BasicBarOptions; 24 | import ro.fortsoft.wicket.dashboard.widgets.wicked.charts.options.BasicLineOptions; 25 | import ro.fortsoft.wicket.dashboard.widgets.wicked.charts.options.BubbleChart3DOptions; 26 | import ro.fortsoft.wicket.dashboard.widgets.wicked.charts.options.ColumnRangeOptions; 27 | import ro.fortsoft.wicket.dashboard.widgets.wicked.charts.options.PieWithLegendOptions; 28 | import ro.fortsoft.wicket.dashboard.widgets.wicked.charts.options.ScatterPlotOptions; 29 | import ro.fortsoft.wicket.dashboard.widgets.wicked.charts.options.SplineUpdatingOptions; 30 | import ro.fortsoft.wicket.dashboard.widgets.wicked.charts.options.StackedAndGroupedColumnOptions; 31 | import ro.fortsoft.wicket.dashboard.widgets.wicked.charts.settings.Settings; 32 | 33 | /** 34 | * @author Paul Bors 35 | */ 36 | public class DemoHighChartsFactory implements HighChartsFactory { 37 | 38 | @Override 39 | public Options createOptions(HighChartsWidget widget) { 40 | Options options; 41 | SeriesType seriesType = SeriesType.valueOf(widget.getSettings().get(Settings.seriesType.name())); 42 | switch(seriesType) { 43 | case AREA: { 44 | options = new BasicAreaOptions(); 45 | break; 46 | } 47 | case AREASPLINE: { 48 | options = new AreaSplineOptions(); 49 | break; 50 | } 51 | case BAR: { 52 | options = new BasicBarOptions(); 53 | break; 54 | } 55 | case COLUMN: { 56 | options = new StackedAndGroupedColumnOptions(); 57 | break; 58 | } 59 | case LINE: { 60 | options = new BasicLineOptions(); 61 | break; 62 | } 63 | case PIE: { 64 | options = new PieWithLegendOptions(); 65 | break; 66 | } 67 | case SCATTER: { 68 | options = new ScatterPlotOptions(); 69 | break; 70 | } 71 | case SPLINE: { 72 | options = new SplineUpdatingOptions(); 73 | break; 74 | } 75 | case GAUGE: { 76 | options = new AngularGaugeOptions(); 77 | break; 78 | } 79 | case COLUMNRANGE: { 80 | options = new ColumnRangeOptions(); 81 | break; 82 | } 83 | case AREARANGE: { 84 | options = new AreaRangeOptions(); 85 | break; 86 | } 87 | case BUBBLE: { 88 | options = new BubbleChart3DOptions(); 89 | break; 90 | } 91 | default: { 92 | options = new Options(); 93 | break; 94 | } 95 | } 96 | return options; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /demo/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=INFO,Console 2 | 3 | log4j.appender.Console=org.apache.log4j.ConsoleAppender 4 | log4j.appender.Console.layout=org.apache.log4j.PatternLayout 5 | log4j.appender.Console.layout.conversionPattern=%-5p - %-26.26c{1} - %m\n 6 | 7 | log4j.logger.org.apache.wicket=INFO 8 | log4j.logger.org.apache.wicket.protocol.http.HttpSessionStore=INFO 9 | log4j.logger.org.apache.wicket.version=INFO 10 | log4j.logger.org.apache.wicket.RequestCycle=INFO 11 | log4j.logger.org.apache.wicket.resource.loader=INFO 12 | -------------------------------------------------------------------------------- /demo/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | Dashboard 9 | 10 | 11 | wicket.filter 12 | org.apache.wicket.protocol.http.WicketFilter 13 | 14 | applicationClassName 15 | ro.fortsoft.wicket.dashboard.demo.WicketApplication 16 | 17 | 18 | 19 | 20 | wicket.filter 21 | /app/* 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /demo/src/main/webapp/css/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | font-family: Verdana; 3 | font-size: 11px; 4 | } 5 | 6 | .left { 7 | float: left; 8 | } 9 | 10 | .right { 11 | float: right; 12 | } 13 | 14 | .toolbar { 15 | line-height: 24px; 16 | margin-bottom: 10px; 17 | width: 100%; 18 | float: left; 19 | font-weight: bold; 20 | border-bottom: 1px solid #CACACA; 21 | } 22 | 23 | .widget-descriptor { 24 | border-bottom: 1px dotted LightGray; 25 | padding-top: 10px; 26 | padding-bottom: 10px; 27 | clear: both; 28 | } 29 | 30 | .widget-descriptor .name { 31 | color: blue; 32 | font-weight: bold; 33 | font-size: 13; 34 | } 35 | 36 | .widget-descriptor .provider { 37 | color: green; 38 | } 39 | 40 | .widget-descriptor .description { 41 | margin-top: 5px; 42 | margin-bottom: 5px; 43 | } 44 | 45 | .widget-descriptor .message { 46 | font-style: italic; 47 | background: Khaki; 48 | padding: 3px; 49 | } 50 | 51 | -------------------------------------------------------------------------------- /demo/src/main/webapp/images/edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decebals/wicket-dashboard/ece9250c8bcc8f4fe66b8ea3ba57fdb31561c805/demo/src/main/webapp/images/edit.png -------------------------------------------------------------------------------- /demo/src/main/webapp/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /demo/src/test/java/ro/fortsoft/wicket/dashboard/demo/Start.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.demo; 14 | 15 | import org.eclipse.jetty.server.Server; 16 | import org.eclipse.jetty.server.bio.SocketConnector; 17 | import org.eclipse.jetty.webapp.WebAppContext; 18 | 19 | /** 20 | * @author Decebal Suiu 21 | */ 22 | public class Start { 23 | 24 | public static void main(String[] args) throws Exception { 25 | Server server = new Server(); 26 | SocketConnector connector = new SocketConnector(); 27 | 28 | // Set some timeout options to make debugging easier. 29 | connector.setMaxIdleTime(1000 * 60 * 60); 30 | connector.setSoLingerTime(-1); 31 | int port = Integer.parseInt(System.getProperty("jetty.port", "8081")); 32 | connector.setPort(port); 33 | server.addConnector(connector); 34 | 35 | WebAppContext webAppContext = new WebAppContext(); 36 | webAppContext.setServer(server); 37 | webAppContext.setContextPath("/"); 38 | webAppContext.setWar("src/main/webapp"); 39 | 40 | server.setHandler(webAppContext); 41 | 42 | // START JMX SERVER 43 | // MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); 44 | // MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer); 45 | // server.getContainer().addEventListener(mBeanContainer); 46 | // mBeanContainer.start(); 47 | 48 | try { 49 | System.out.println(">>> STARTING EMBEDDED JETTY SERVER (" + port + "), PRESS ANY KEY TO STOP"); 50 | server.start(); 51 | System.in.read(); 52 | System.out.println(">>> STOPPING EMBEDDED JETTY SERVER"); 53 | // while (System.in.available() == 0) { 54 | // Thread.sleep(5000); 55 | // } 56 | server.stop(); 57 | server.join(); 58 | } catch (Exception e) { 59 | e.printStackTrace(); 60 | System.exit(100); 61 | } 62 | } 63 | 64 | } -------------------------------------------------------------------------------- /screenshots/wicket-dashboard-gauge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decebals/wicket-dashboard/ece9250c8bcc8f4fe66b8ea3ba57fdb31561c805/screenshots/wicket-dashboard-gauge.png -------------------------------------------------------------------------------- /screenshots/wicket-dashboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decebals/wicket-dashboard/ece9250c8bcc8f4fe66b8ea3ba57fdb31561c805/screenshots/wicket-dashboard.png -------------------------------------------------------------------------------- /widgets/jqplot/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ro.fortsoft.wicket.dashboard.widgets 6 | wicket-dashboard-widgets-parent 7 | 0.14.0-SNAPSHOT 8 | 9 | 10 | 4.0.0 11 | wicket-dashboard-jqplot 12 | 0.14.0-SNAPSHOT 13 | jar 14 | JqPlot Widget 15 | 16 | 17 | 18 | 19 | org.wicketstuff 20 | jqplot 21 | ${jqPlot.version} 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /widgets/jqplot/src/main/java/ro/fortsoft/wicket/dashboard/widget/jqplot/ChartContainer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widget.jqplot; 14 | 15 | import java.util.List; 16 | 17 | import org.apache.wicket.Component; 18 | import org.apache.wicket.behavior.Behavior; 19 | import org.apache.wicket.markup.head.CssHeaderItem; 20 | import org.apache.wicket.markup.head.IHeaderResponse; 21 | import org.apache.wicket.markup.head.JavaScriptHeaderItem; 22 | import org.apache.wicket.markup.head.OnDomReadyHeaderItem; 23 | import org.apache.wicket.markup.html.WebMarkupContainer; 24 | import org.apache.wicket.model.IModel; 25 | import org.apache.wicket.request.resource.CssResourceReference; 26 | import org.apache.wicket.request.resource.JavaScriptResourceReference; 27 | import org.apache.wicket.resource.JQueryPluginResourceReference; 28 | import org.wicketstuff.jqplot.behavior.JqPlotBehavior; 29 | 30 | import br.com.digilabs.jqplot.Chart; 31 | import br.com.digilabs.jqplot.JqPlotUtils; 32 | 33 | /** 34 | * @author Decebal Suiu 35 | */ 36 | public class ChartContainer extends WebMarkupContainer { 37 | 38 | private static final long serialVersionUID = 1L; 39 | 40 | public ChartContainer(String id, IModel> model) { 41 | super(id, model); 42 | 43 | setOutputMarkupId(true); 44 | } 45 | 46 | private String createJquery() { 47 | Chart chart = getChart(); 48 | 49 | StringBuilder builder = new StringBuilder(); 50 | builder.append("$.jqplot('").append(getMarkupId()).append("', "); 51 | builder.append(chart.getChartData().toJsonString()); 52 | builder.append(", "); 53 | builder.append(JqPlotUtils.jqPlotToJson(chart.getChartConfiguration())); 54 | builder.append(");\r\n"); 55 | 56 | return builder.toString(); 57 | } 58 | 59 | @Override 60 | protected void onInitialize() { 61 | super.onInitialize(); 62 | 63 | add(getJqPlotBehavior()); 64 | } 65 | 66 | private Chart getChart() { 67 | return (Chart) getDefaultModelObject(); 68 | } 69 | 70 | private Behavior getJqPlotBehavior() { 71 | return new Behavior() { 72 | 73 | private static final long serialVersionUID = 1L; 74 | 75 | @Override 76 | public void renderHead(Component component, IHeaderResponse response) { 77 | super.renderHead(component, response); 78 | 79 | response.render(JavaScriptHeaderItem.forReference(new JQueryPluginResourceReference(JqPlotBehavior.class, "jquery.jqplot.min.js"))); 80 | response.render(CssHeaderItem.forReference(new CssResourceReference(JqPlotBehavior.class, "jquery.jqplot.min.css"))); 81 | List resources = JqPlotUtils.retriveJavaScriptResources(getChart()); 82 | for (String resource : resources) { 83 | response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(JqPlotBehavior.class, resource))); 84 | } 85 | String json = createJquery(); 86 | response.render(OnDomReadyHeaderItem.forScript(json)); 87 | } 88 | 89 | }; 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /widgets/jqplot/src/main/java/ro/fortsoft/wicket/dashboard/widget/jqplot/ChartFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widget.jqplot; 14 | 15 | import br.com.digilabs.jqplot.Chart; 16 | 17 | /** 18 | * @author Decebal Suiu 19 | */ 20 | public interface ChartFactory { 21 | 22 | public Chart createChart(JqPlotWidget widget); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /widgets/jqplot/src/main/java/ro/fortsoft/wicket/dashboard/widget/jqplot/JqPlotSettingsPanel.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | Type 6 | 7 | Save 8 | Cancel 9 |
10 |
11 | -------------------------------------------------------------------------------- /widgets/jqplot/src/main/java/ro/fortsoft/wicket/dashboard/widget/jqplot/JqPlotSettingsPanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widget.jqplot; 14 | 15 | import org.apache.wicket.ajax.AjaxRequestTarget; 16 | import org.apache.wicket.ajax.markup.html.AjaxLink; 17 | import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink; 18 | import org.apache.wicket.markup.html.form.DropDownChoice; 19 | import org.apache.wicket.markup.html.form.Form; 20 | import org.apache.wicket.markup.html.panel.GenericPanel; 21 | import org.apache.wicket.model.IModel; 22 | import org.apache.wicket.model.PropertyModel; 23 | 24 | import ro.fortsoft.wicket.dashboard.Dashboard; 25 | import ro.fortsoft.wicket.dashboard.Widget; 26 | import ro.fortsoft.wicket.dashboard.web.DashboardContext; 27 | import ro.fortsoft.wicket.dashboard.web.DashboardContextAware; 28 | import ro.fortsoft.wicket.dashboard.web.DashboardPanel; 29 | import ro.fortsoft.wicket.dashboard.web.WidgetPanel; 30 | 31 | /** 32 | * @author Decebal Suiu 33 | */ 34 | public class JqPlotSettingsPanel extends GenericPanel implements DashboardContextAware { 35 | 36 | private static final long serialVersionUID = 1L; 37 | 38 | private transient DashboardContext dashboardContext; 39 | private String chartType; 40 | 41 | public JqPlotSettingsPanel(String id, IModel model) { 42 | super(id, model); 43 | 44 | setOutputMarkupPlaceholderTag(true); 45 | 46 | Form form = new Form("form"); 47 | chartType = getModelObject().getSettings().get("chartType"); 48 | // chartType = ChartWidget.BAR_TYPE; 49 | DropDownChoice choice = new DropDownChoice("chartType", 50 | new PropertyModel(this, "chartType"), JqPlotWidget.TYPES); 51 | form.add(choice); 52 | 53 | form.add(new AjaxSubmitLink("submit") { 54 | 55 | private static final long serialVersionUID = 1L; 56 | 57 | @Override 58 | protected void onSubmit(AjaxRequestTarget target, Form form) { 59 | getModelObject().getSettings().put("chartType", chartType); 60 | Dashboard dashboard = findParent(DashboardPanel.class).getDashboard(); 61 | dashboardContext.getDashboardPersister().save(dashboard); 62 | 63 | hideSettingPanel(target); 64 | // TODO 65 | WidgetPanel widgetPanel = findParent(WidgetPanel.class); 66 | JqPlotWidgetView widgetView = (JqPlotWidgetView) widgetPanel.getWidgetView(); 67 | target.add(widgetView); 68 | } 69 | 70 | @Override 71 | protected void onError(AjaxRequestTarget target, Form form) { 72 | } 73 | 74 | }); 75 | form.add(new AjaxLink("cancel") { 76 | 77 | private static final long serialVersionUID = 1L; 78 | 79 | @Override 80 | public void onClick(AjaxRequestTarget target) { 81 | hideSettingPanel(target); 82 | } 83 | 84 | }); 85 | 86 | add(form); 87 | } 88 | 89 | public String getChartType() { 90 | return chartType; 91 | } 92 | 93 | public void setChartType(String chartType) { 94 | this.chartType = chartType; 95 | } 96 | 97 | @Override 98 | public void setDashboardContext(DashboardContext dashboardContext) { 99 | this.dashboardContext = dashboardContext; 100 | } 101 | 102 | private void hideSettingPanel(AjaxRequestTarget target) { 103 | setVisible(false); 104 | target.add(this); 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /widgets/jqplot/src/main/java/ro/fortsoft/wicket/dashboard/widget/jqplot/JqPlotWidget.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widget.jqplot; 14 | 15 | import java.util.Arrays; 16 | import java.util.List; 17 | 18 | import org.apache.wicket.markup.html.panel.Panel; 19 | import org.apache.wicket.model.Model; 20 | 21 | import ro.fortsoft.wicket.dashboard.AbstractWidget; 22 | import ro.fortsoft.wicket.dashboard.Widget; 23 | import ro.fortsoft.wicket.dashboard.web.WidgetView; 24 | 25 | import br.com.digilabs.jqplot.Chart; 26 | 27 | /** 28 | * @author Decebal Suiu 29 | */ 30 | public class JqPlotWidget extends AbstractWidget { 31 | 32 | private static final long serialVersionUID = 1L; 33 | 34 | public static final String BAR_TYPE = "Bar"; 35 | public static final String LINE_TYPE = "Line"; 36 | public static final String PIE_TYPE = "Pie"; 37 | public static final String AREA_TYPE = "Area"; 38 | 39 | public static final List TYPES = Arrays.asList(new String[] { 40 | BAR_TYPE, 41 | LINE_TYPE, 42 | PIE_TYPE, 43 | AREA_TYPE 44 | }); 45 | 46 | private static ChartFactory chartFactory; 47 | 48 | public JqPlotWidget() { 49 | super(); 50 | 51 | title = "JqPlot"; 52 | } 53 | 54 | public static ChartFactory getChartFactory() { 55 | return chartFactory; 56 | } 57 | 58 | public static void setChartFactory(ChartFactory chartFactory) { 59 | JqPlotWidget.chartFactory = chartFactory; 60 | } 61 | 62 | public WidgetView createView(String viewId) { 63 | return new JqPlotWidgetView(viewId, new Model(this)); 64 | } 65 | 66 | public Chart getChart() { 67 | if (chartFactory == null) { 68 | throw new RuntimeException("ChartFactory cannot be null. Use JqPlotWidget.setChartFactory(...)"); 69 | } 70 | 71 | return chartFactory.createChart(this); 72 | } 73 | 74 | @Override 75 | public void init() { 76 | if (!settings.containsKey("chartType")) { 77 | settings.put("chartType", JqPlotWidget.BAR_TYPE); 78 | } 79 | } 80 | 81 | @Override 82 | public boolean hasSettings() { 83 | return true; 84 | } 85 | 86 | @Override 87 | public Panel createSettingsPanel(String settingsPanelId) { 88 | return new JqPlotSettingsPanel(settingsPanelId, new Model(this)); 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /widgets/jqplot/src/main/java/ro/fortsoft/wicket/dashboard/widget/jqplot/JqPlotWidgetDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widget.jqplot; 14 | 15 | import ro.fortsoft.wicket.dashboard.WidgetDescriptor; 16 | 17 | /** 18 | * @author Decebal Suiu 19 | */ 20 | public class JqPlotWidgetDescriptor implements WidgetDescriptor { 21 | 22 | private static final long serialVersionUID = 1L; 23 | 24 | public String getDescription() { 25 | return "A chart widget using JqPlot."; 26 | } 27 | 28 | public String getName() { 29 | return "Chart (JqPlot)"; 30 | } 31 | 32 | public String getProvider() { 33 | return "Decebal Suiu"; 34 | } 35 | 36 | public String getWidgetClassName() { 37 | return JqPlotWidget.class.getName(); 38 | } 39 | 40 | @Override 41 | public String getTypeName() { 42 | return "widget.jqplot"; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /widgets/jqplot/src/main/java/ro/fortsoft/wicket/dashboard/widget/jqplot/JqPlotWidgetView.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 |
6 | -------------------------------------------------------------------------------- /widgets/jqplot/src/main/java/ro/fortsoft/wicket/dashboard/widget/jqplot/JqPlotWidgetView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widget.jqplot; 14 | 15 | import org.apache.wicket.model.IModel; 16 | import org.apache.wicket.model.LoadableDetachableModel; 17 | import org.apache.wicket.model.Model; 18 | 19 | import ro.fortsoft.wicket.dashboard.Widget; 20 | import ro.fortsoft.wicket.dashboard.web.WidgetView; 21 | 22 | import br.com.digilabs.jqplot.Chart; 23 | 24 | /** 25 | * @author Decebal Suiu 26 | */ 27 | public class JqPlotWidgetView extends WidgetView { 28 | 29 | private static final long serialVersionUID = 1L; 30 | 31 | public JqPlotWidgetView(String id, Model model) { 32 | super(id, model); 33 | 34 | final JqPlotWidget widget = (JqPlotWidget) model.getObject(); 35 | IModel> chartModel = new LoadableDetachableModel>() { 36 | 37 | private static final long serialVersionUID = 1L; 38 | 39 | @Override 40 | protected Chart load() { 41 | return widget.getChart(); 42 | } 43 | 44 | }; 45 | add(new ChartContainer("chart", chartModel)); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /widgets/justgage/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ro.fortsoft.wicket.dashboard.widgets 6 | wicket-dashboard-widgets-parent 7 | 0.14.0-SNAPSHOT 8 | 9 | 10 | 4.0.0 11 | wicket-dashboard-justgage 12 | 0.14.0-SNAPSHOT 13 | jar 14 | JustGage Widget 15 | 16 | 17 | -------------------------------------------------------------------------------- /widgets/justgage/src/main/java/ro/fortsoft/wicket/dashboard/widget/justgage/JustGage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widget.justgage; 14 | 15 | import ro.fortsoft.wicket.dashboard.widget.justgage.option.Option; 16 | 17 | /** 18 | * @author Decebal Suiu 19 | */ 20 | public class JustGage { 21 | 22 | // This field is set by JustGageWidgetView !!! 23 | @Option(required = true) 24 | private String id; 25 | 26 | @Option(required = true) 27 | private String title; 28 | 29 | @Option(required = true) 30 | private int value; 31 | 32 | @Option 33 | private int min; 34 | 35 | @Option 36 | private int max; 37 | 38 | @Option 39 | private String gaugeColor; 40 | 41 | @Option 42 | private String label; 43 | 44 | public String getId() { 45 | return id; 46 | } 47 | 48 | public JustGage setId(String id) { 49 | this.id = id; 50 | return this; 51 | } 52 | 53 | public JustGage setValue(int value) { 54 | this.value = value; 55 | return this; 56 | } 57 | 58 | public int getValue() { 59 | return value; 60 | } 61 | 62 | public JustGage setTitle(String title) { 63 | this.title = title; 64 | return this; 65 | } 66 | 67 | public String getTitle() { 68 | return title; 69 | } 70 | 71 | public JustGage setMin(int min) { 72 | this.min = min; 73 | return this; 74 | } 75 | 76 | public int getMin() { 77 | return min; 78 | } 79 | 80 | public JustGage setMax(int max) { 81 | this.max = max; 82 | return this; 83 | } 84 | 85 | public int getMax() { 86 | return max; 87 | } 88 | 89 | public String getGaugeColor() { 90 | return gaugeColor; 91 | } 92 | 93 | public JustGage setGaugeColor(String gaugeColor) { 94 | this.gaugeColor = gaugeColor; 95 | return this; 96 | } 97 | 98 | public String getLabel() { 99 | return label; 100 | } 101 | 102 | public JustGage setLabel(String label) { 103 | this.label = label; 104 | return this; 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /widgets/justgage/src/main/java/ro/fortsoft/wicket/dashboard/widget/justgage/JustGageFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widget.justgage; 14 | 15 | /** 16 | * @author Decebal Suiu 17 | */ 18 | public interface JustGageFactory { 19 | 20 | public JustGage createJustGage(JustGageWidget widget); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /widgets/justgage/src/main/java/ro/fortsoft/wicket/dashboard/widget/justgage/JustGageWidget.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widget.justgage; 14 | 15 | import org.apache.wicket.model.Model; 16 | 17 | import ro.fortsoft.wicket.dashboard.AbstractWidget; 18 | import ro.fortsoft.wicket.dashboard.Widget; 19 | import ro.fortsoft.wicket.dashboard.web.WidgetView; 20 | 21 | /** 22 | * @author Decebal Suiu 23 | */ 24 | public class JustGageWidget extends AbstractWidget { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | private static JustGageFactory justGageFactory; 29 | 30 | public JustGageWidget() { 31 | super(); 32 | 33 | title = "JustGage"; 34 | } 35 | 36 | public static JustGageFactory getChartFactory() { 37 | return justGageFactory; 38 | } 39 | 40 | public static void setJustGageFactory(JustGageFactory justGageFactory) { 41 | JustGageWidget.justGageFactory = justGageFactory; 42 | } 43 | 44 | public JustGage getJustGage() { 45 | if (justGageFactory == null) { 46 | throw new RuntimeException("JustGageFactory cannot be null. Use JustGageWidget.setJustGageFactory(...)"); 47 | } 48 | 49 | return justGageFactory.createJustGage(this); 50 | } 51 | 52 | public WidgetView createView(String viewId) { 53 | return new JustGageWidgetView(viewId, new Model(this)); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /widgets/justgage/src/main/java/ro/fortsoft/wicket/dashboard/widget/justgage/JustGageWidgetDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widget.justgage; 14 | 15 | import ro.fortsoft.wicket.dashboard.WidgetDescriptor; 16 | 17 | /** 18 | * @author Decebal Suiu 19 | */ 20 | public class JustGageWidgetDescriptor implements WidgetDescriptor { 21 | 22 | private static final long serialVersionUID = 1L; 23 | 24 | public String getDescription() { 25 | return "A simple gauge widget. See http://justgage.com/"; 26 | } 27 | 28 | public String getName() { 29 | return "JustGage"; 30 | } 31 | 32 | public String getProvider() { 33 | return "Decebal Suiu"; 34 | } 35 | 36 | public String getWidgetClassName() { 37 | return JustGageWidget.class.getName(); 38 | } 39 | 40 | @Override 41 | public String getTypeName() { 42 | return "widget.justgage"; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /widgets/justgage/src/main/java/ro/fortsoft/wicket/dashboard/widget/justgage/JustGageWidgetView.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 |
6 | -------------------------------------------------------------------------------- /widgets/justgage/src/main/java/ro/fortsoft/wicket/dashboard/widget/justgage/JustGageWidgetView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widget.justgage; 14 | 15 | import org.apache.wicket.markup.head.IHeaderResponse; 16 | import org.apache.wicket.markup.head.JavaScriptHeaderItem; 17 | import org.apache.wicket.markup.head.OnDomReadyHeaderItem; 18 | import org.apache.wicket.markup.html.WebMarkupContainer; 19 | import org.apache.wicket.model.Model; 20 | import org.apache.wicket.request.resource.PackageResourceReference; 21 | import org.apache.wicket.request.resource.ResourceReference; 22 | 23 | import ro.fortsoft.wicket.dashboard.Widget; 24 | import ro.fortsoft.wicket.dashboard.web.WidgetView; 25 | import ro.fortsoft.wicket.dashboard.widget.justgage.option.JavaScriptOptionsRenderer; 26 | 27 | /** 28 | * @author Decebal Suiu 29 | */ 30 | public class JustGageWidgetView extends WidgetView { 31 | 32 | private static final long serialVersionUID = 1L; 33 | 34 | private ResourceReference raphaelReference = new PackageResourceReference( 35 | JustGageWidgetView.class, "res/raphael.2.1.0.min.js"); 36 | private ResourceReference justgageReference = new PackageResourceReference( 37 | JustGageWidgetView.class, "res/justgage.1.0.1.min.js"); 38 | 39 | private String gaugeId; 40 | 41 | public JustGageWidgetView(String id, Model model) { 42 | super(id, model); 43 | 44 | gaugeId = "gauge" + getSession().nextSequenceValue(); 45 | add(new WebMarkupContainer("gauge").setMarkupId(gaugeId)); 46 | } 47 | 48 | @Override 49 | public void renderHead(IHeaderResponse response) { 50 | super.renderHead(response); 51 | 52 | response.render(JavaScriptHeaderItem.forReference(raphaelReference)); 53 | response.render(JavaScriptHeaderItem.forReference(justgageReference)); 54 | 55 | response.render(OnDomReadyHeaderItem.forScript(getJustGageJavaScript())); 56 | } 57 | 58 | private CharSequence getJustGageJavaScript() { 59 | /* 60 | var g = new JustGage({ 61 | id: "gauge", 62 | value: 67, 63 | min: 0, 64 | max: 100, 65 | title: "Visitors" 66 | }); 67 | */ 68 | 69 | JustGageWidget widget = (JustGageWidget) getModelObject(); 70 | JustGage justGage = widget.getJustGage(); 71 | justGage.setId(gaugeId); 72 | 73 | StringBuilder function = new StringBuilder(); 74 | function.append("var " + gaugeId + " = "); 75 | function.append("new JustGage({"); 76 | JavaScriptOptionsRenderer.renderOptions(justGage, function); 77 | function.append("});"); 78 | 79 | // System.out.println(function); 80 | 81 | return function; 82 | } 83 | 84 | /* 85 | private String getGaugeId() { 86 | // return "gauge-" + getModelObject().getId(); 87 | return getGaugeVarname(); 88 | } 89 | 90 | private String getGaugeVarname() { 91 | return "gauge" + getSession().nextSequenceValue(); 92 | } 93 | */ 94 | 95 | } 96 | -------------------------------------------------------------------------------- /widgets/justgage/src/main/java/ro/fortsoft/wicket/dashboard/widget/justgage/option/JavaScriptOptionsRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widget.justgage.option; 14 | 15 | import java.lang.reflect.Field; 16 | 17 | /** 18 | * @author Decebal Suiu 19 | */ 20 | public class JavaScriptOptionsRenderer { 21 | 22 | public static void renderOptions(Object optionsProvider, StringBuilder builder) { 23 | for (Field field : optionsProvider.getClass().getDeclaredFields()) { 24 | // check if field has Option annotation 25 | Option option; 26 | if ((option = field.getAnnotation(Option.class)) != null) { 27 | String name = option.name(); 28 | if ("".equals(name)) { 29 | name = field.getName(); 30 | } 31 | Object value = null; 32 | if (!field.isAccessible()) { 33 | field.setAccessible(true); 34 | } 35 | try { 36 | value = field.get(optionsProvider); 37 | } catch (Exception e) { 38 | // TODO 39 | e.printStackTrace(); 40 | } 41 | boolean required = option.required(); 42 | 43 | if ((value == null) && !required ) { 44 | continue; // jump to next option 45 | } 46 | 47 | String optionValue; 48 | if (field.getType().equals(String.class)) { 49 | optionValue = "\"" + value + "\""; 50 | } else { 51 | optionValue = value.toString(); 52 | } 53 | 54 | builder.append(name + ':' + optionValue + ','); 55 | } 56 | } 57 | 58 | char lastChar = builder.charAt(builder.length() - 1); 59 | if (',' == lastChar) { 60 | builder.deleteCharAt(builder.length() - 1); // delete last "," 61 | } 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /widgets/justgage/src/main/java/ro/fortsoft/wicket/dashboard/widget/justgage/option/Option.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widget.justgage.option; 14 | 15 | import java.lang.annotation.Retention; 16 | import java.lang.annotation.RetentionPolicy; 17 | 18 | /** 19 | * @author Decebal Suiu 20 | */ 21 | @Retention(RetentionPolicy.RUNTIME) 22 | public @interface Option { 23 | 24 | String name() default ""; // java not allow null as default value 25 | boolean required() default false; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /widgets/justgage/src/main/java/ro/fortsoft/wicket/dashboard/widget/justgage/res/raphael.2.1.0.min.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decebals/wicket-dashboard/ece9250c8bcc8f4fe66b8ea3ba57fdb31561c805/widgets/justgage/src/main/java/ro/fortsoft/wicket/dashboard/widget/justgage/res/raphael.2.1.0.min.js -------------------------------------------------------------------------------- /widgets/loremipsum/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ro.fortsoft.wicket.dashboard.widgets 6 | wicket-dashboard-widgets-parent 7 | 0.14.0-SNAPSHOT 8 | 9 | 10 | 4.0.0 11 | wicket-dashboard-loremipsum 12 | 0.14.0-SNAPSHOT 13 | jar 14 | LoremIpsum Widget 15 | 16 | 17 | 18 | 19 | de.sven-jacobs 20 | loremipsum 21 | ${loremipsum.version} 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /widgets/loremipsum/src/main/java/ro/fortsoft/wicket/dashboard/widget/loremipsum/LoremIpsumWidget.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widget.loremipsum; 14 | 15 | import org.apache.wicket.model.Model; 16 | 17 | import ro.fortsoft.wicket.dashboard.AbstractWidget; 18 | import ro.fortsoft.wicket.dashboard.Widget; 19 | import ro.fortsoft.wicket.dashboard.web.WidgetView; 20 | 21 | 22 | import de.svenjacobs.loremipsum.LoremIpsum; 23 | 24 | /** 25 | * @author Decebal Suiu 26 | */ 27 | public class LoremIpsumWidget extends AbstractWidget { 28 | 29 | private static final long serialVersionUID = 1L; 30 | 31 | private transient LoremIpsum loremIpsum; 32 | 33 | public LoremIpsumWidget() { 34 | super(); 35 | 36 | title = "Text"; 37 | } 38 | 39 | public String getText() { 40 | if (loremIpsum == null) { 41 | loremIpsum = new LoremIpsum(); 42 | } 43 | 44 | return loremIpsum.getWords(); 45 | } 46 | 47 | public WidgetView createView(String viewId) { 48 | return new LoremIpsumWidgetView(viewId, new Model(this)); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /widgets/loremipsum/src/main/java/ro/fortsoft/wicket/dashboard/widget/loremipsum/LoremIpsumWidgetDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widget.loremipsum; 14 | 15 | import ro.fortsoft.wicket.dashboard.WidgetDescriptor; 16 | 17 | /** 18 | * @author Decebal Suiu 19 | */ 20 | public class LoremIpsumWidgetDescriptor implements WidgetDescriptor { 21 | 22 | private static final long serialVersionUID = 1L; 23 | 24 | public String getDescription() { 25 | return "A simple lorem ipsum widget."; 26 | } 27 | 28 | public String getName() { 29 | return "LoremIpsum"; 30 | } 31 | 32 | public String getProvider() { 33 | return "Decebal Suiu"; 34 | } 35 | 36 | public String getWidgetClassName() { 37 | return LoremIpsumWidget.class.getName(); 38 | } 39 | 40 | @Override 41 | public String getTypeName() { 42 | return "widget.loremipsum"; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /widgets/loremipsum/src/main/java/ro/fortsoft/wicket/dashboard/widget/loremipsum/LoremIpsumWidgetView.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /widgets/loremipsum/src/main/java/ro/fortsoft/wicket/dashboard/widget/loremipsum/LoremIpsumWidgetView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widget.loremipsum; 14 | 15 | import org.apache.wicket.markup.html.basic.Label; 16 | import org.apache.wicket.model.Model; 17 | 18 | import ro.fortsoft.wicket.dashboard.Widget; 19 | import ro.fortsoft.wicket.dashboard.web.WidgetView; 20 | 21 | /** 22 | * @author Decebal Suiu 23 | */ 24 | public class LoremIpsumWidgetView extends WidgetView { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | public LoremIpsumWidgetView(String id, Model model) { 29 | super(id, model); 30 | 31 | LoremIpsumWidget widget = (LoremIpsumWidget) model.getObject(); 32 | add(new Label("text", widget.getText())); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /widgets/ofchart/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ro.fortsoft.wicket.dashboard.widgets 6 | wicket-dashboard-widgets-parent 7 | 0.14.0-SNAPSHOT 8 | 9 | 10 | 4.0.0 11 | wicket-dashboard-ofchart 12 | 0.14.0-SNAPSHOT 13 | jar 14 | OpenFlashChart Widget 15 | 16 | 17 | 18 | 19 | jofc2 20 | jofc2 21 | ${jofc2.version} 22 | 23 | 24 | 25 | 26 | 27 | jofc2.maven.repo 28 | JOFC2 GoogleCode.com Snapshot Repository 29 | http://jofc2.googlecode.com/svn/repository/snapshots/ 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /widgets/ofchart/src/main/java/ro/fortsoft/wicket/dashboard/widget/ofchart/ChartDataFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widget.ofchart; 14 | 15 | /** 16 | * @author Decebal Suiu 17 | */ 18 | public interface ChartDataFactory { 19 | 20 | /** 21 | * Retrieves a json string. 22 | */ 23 | public String createChartData(ChartWidget widget); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /widgets/ofchart/src/main/java/ro/fortsoft/wicket/dashboard/widget/ofchart/ChartSettingsPanel.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | Type 6 | 7 | Save 8 | Cancel 9 |
10 |
11 | -------------------------------------------------------------------------------- /widgets/ofchart/src/main/java/ro/fortsoft/wicket/dashboard/widget/ofchart/ChartSettingsPanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widget.ofchart; 14 | 15 | import org.apache.wicket.ajax.AjaxRequestTarget; 16 | import org.apache.wicket.ajax.markup.html.AjaxLink; 17 | import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink; 18 | import org.apache.wicket.markup.html.form.DropDownChoice; 19 | import org.apache.wicket.markup.html.form.Form; 20 | import org.apache.wicket.markup.html.panel.GenericPanel; 21 | import org.apache.wicket.model.IModel; 22 | import org.apache.wicket.model.PropertyModel; 23 | 24 | import ro.fortsoft.wicket.dashboard.Dashboard; 25 | import ro.fortsoft.wicket.dashboard.Widget; 26 | import ro.fortsoft.wicket.dashboard.web.DashboardContext; 27 | import ro.fortsoft.wicket.dashboard.web.DashboardContextAware; 28 | import ro.fortsoft.wicket.dashboard.web.DashboardPanel; 29 | import ro.fortsoft.wicket.dashboard.web.WidgetPanel; 30 | 31 | /** 32 | * @author Decebal Suiu 33 | */ 34 | public class ChartSettingsPanel extends GenericPanel implements DashboardContextAware { 35 | 36 | private static final long serialVersionUID = 1L; 37 | 38 | private transient DashboardContext dashboardContext; 39 | private String chartType; 40 | 41 | public ChartSettingsPanel(String id, IModel model) { 42 | super(id, model); 43 | 44 | setOutputMarkupPlaceholderTag(true); 45 | 46 | Form form = new Form("form"); 47 | chartType = getModelObject().getSettings().get("chartType"); 48 | // chartType = ChartWidget.BAR_TYPE; 49 | DropDownChoice choice = new DropDownChoice("chartType", 50 | new PropertyModel(this, "chartType"), ChartWidget.TYPES); 51 | form.add(choice); 52 | 53 | form.add(new AjaxSubmitLink("submit") { 54 | 55 | private static final long serialVersionUID = 1L; 56 | 57 | @Override 58 | protected void onSubmit(AjaxRequestTarget target, Form form) { 59 | getModelObject().getSettings().put("chartType", chartType); 60 | Dashboard dashboard = findParent(DashboardPanel.class).getDashboard(); 61 | dashboardContext.getDashboardPersister().save(dashboard); 62 | 63 | hideSettingPanel(target); 64 | // TODO 65 | WidgetPanel widgetPanel = findParent(WidgetPanel.class); 66 | ChartWidgetView widgetView = (ChartWidgetView) widgetPanel.getWidgetView(); 67 | target.add(widgetView); 68 | } 69 | 70 | @Override 71 | protected void onError(AjaxRequestTarget target, Form form) { 72 | } 73 | 74 | }); 75 | form.add(new AjaxLink("cancel") { 76 | 77 | private static final long serialVersionUID = 1L; 78 | 79 | @Override 80 | public void onClick(AjaxRequestTarget target) { 81 | hideSettingPanel(target); 82 | } 83 | 84 | }); 85 | 86 | add(form); 87 | } 88 | 89 | public String getChartType() { 90 | return chartType; 91 | } 92 | 93 | public void setChartType(String chartType) { 94 | this.chartType = chartType; 95 | } 96 | 97 | @Override 98 | public void setDashboardContext(DashboardContext dashboardContext) { 99 | this.dashboardContext = dashboardContext; 100 | } 101 | 102 | private void hideSettingPanel(AjaxRequestTarget target) { 103 | setVisible(false); 104 | target.add(this); 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /widgets/ofchart/src/main/java/ro/fortsoft/wicket/dashboard/widget/ofchart/ChartWidget.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widget.ofchart; 14 | 15 | import java.util.Arrays; 16 | import java.util.List; 17 | 18 | import org.apache.wicket.markup.html.panel.Panel; 19 | import org.apache.wicket.model.Model; 20 | 21 | import ro.fortsoft.wicket.dashboard.AbstractWidget; 22 | import ro.fortsoft.wicket.dashboard.Widget; 23 | import ro.fortsoft.wicket.dashboard.web.WidgetView; 24 | 25 | /** 26 | * @author Decebal Suiu 27 | */ 28 | public class ChartWidget extends AbstractWidget { 29 | 30 | private static final long serialVersionUID = 1L; 31 | 32 | public static final String BAR_TYPE = "Bar"; 33 | public static final String DOUBLE_BAR_TYPE = "DoubleBar"; 34 | public static final String LINE_TYPE = "Line"; 35 | public static final String DOTED_LINE_TYPE = "DotedLine"; 36 | public static final String PIE_TYPE = "Pie"; 37 | public static final String SCATTER_TYPE = "Scatter"; 38 | 39 | public static final List TYPES = Arrays.asList(new String[] { 40 | BAR_TYPE, 41 | DOUBLE_BAR_TYPE, 42 | LINE_TYPE, 43 | DOTED_LINE_TYPE, 44 | PIE_TYPE, 45 | SCATTER_TYPE 46 | }); 47 | 48 | private static ChartDataFactory chartDataFactory; 49 | 50 | public ChartWidget() { 51 | super(); 52 | 53 | title = "Chart"; 54 | } 55 | 56 | public static ChartDataFactory getChartDataFactory() { 57 | return chartDataFactory; 58 | } 59 | 60 | public static void setChartDataFactory(ChartDataFactory chartDataFactory) { 61 | ChartWidget.chartDataFactory = chartDataFactory; 62 | } 63 | 64 | public String getChartData() { 65 | if (chartDataFactory == null) { 66 | throw new RuntimeException("ChartDataFactory cannot be null. Use ChartWidget.setChartDataFactory(...)"); 67 | } 68 | 69 | return chartDataFactory.createChartData(this); 70 | } 71 | 72 | public WidgetView createView(String viewId) { 73 | return new ChartWidgetView(viewId, new Model(this)); 74 | } 75 | 76 | @Override 77 | public void init() { 78 | if (!settings.containsKey("chartType")) { 79 | settings.put("chartType", ChartWidget.BAR_TYPE); 80 | } 81 | } 82 | 83 | @Override 84 | public boolean hasSettings() { 85 | return true; 86 | } 87 | 88 | @Override 89 | public Panel createSettingsPanel(String settingsPanelId) { 90 | return new ChartSettingsPanel(settingsPanelId, new Model(this)); 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /widgets/ofchart/src/main/java/ro/fortsoft/wicket/dashboard/widget/ofchart/ChartWidgetDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widget.ofchart; 14 | 15 | import ro.fortsoft.wicket.dashboard.WidgetDescriptor; 16 | 17 | /** 18 | * @author Decebal Suiu 19 | */ 20 | public class ChartWidgetDescriptor implements WidgetDescriptor { 21 | 22 | private static final long serialVersionUID = 1L; 23 | 24 | public String getDescription() { 25 | return "A chart widget using OpenFlashChart."; 26 | } 27 | 28 | public String getName() { 29 | return "Chart (OpenFlashChart)"; 30 | } 31 | 32 | public String getProvider() { 33 | return "Decebal Suiu"; 34 | } 35 | 36 | public String getWidgetClassName() { 37 | return ChartWidget.class.getName(); 38 | } 39 | 40 | @Override 41 | public String getTypeName() { 42 | return "widget.ofchart"; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /widgets/ofchart/src/main/java/ro/fortsoft/wicket/dashboard/widget/ofchart/ChartWidgetView.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 |
6 | -------------------------------------------------------------------------------- /widgets/ofchart/src/main/java/ro/fortsoft/wicket/dashboard/widget/ofchart/ChartWidgetView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widget.ofchart; 14 | 15 | import org.apache.wicket.model.IModel; 16 | 17 | import ro.fortsoft.wicket.dashboard.Widget; 18 | import ro.fortsoft.wicket.dashboard.web.WidgetView; 19 | 20 | /** 21 | * @author Decebal Suiu 22 | */ 23 | public class ChartWidgetView extends WidgetView { 24 | 25 | private static final long serialVersionUID = 1L; 26 | 27 | public ChartWidgetView(String id, IModel model) { 28 | super(id, model); 29 | 30 | // TODO put width, height in settings 31 | add(new OpenFlashChart("chart", "100%", "300", model)); 32 | // add(new OpenFlashChart("chart", "100%", "100%", model)); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /widgets/ofchart/src/main/java/ro/fortsoft/wicket/dashboard/widget/ofchart/DataResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widget.ofchart; 14 | 15 | import java.io.IOException; 16 | 17 | import org.apache.wicket.request.resource.AbstractResource; 18 | 19 | import ro.fortsoft.wicket.dashboard.Dashboard; 20 | 21 | /** 22 | * @author Decebal Suiu 23 | */ 24 | public class DataResource extends AbstractResource { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | private Dashboard dashboard; 29 | 30 | public DataResource(Dashboard dashboard) { 31 | this.dashboard = dashboard; 32 | } 33 | 34 | @Override 35 | protected ResourceResponse newResourceResponse(Attributes attributes) { 36 | System.out.println("DataResource.newResourceResponse()"); 37 | String widgetId = attributes.getParameters().get("widgetId").toString(); 38 | System.out.println("widgetId = " + widgetId); 39 | 40 | System.out.println("dashboard = " + dashboard); 41 | final ChartWidget widget = (ChartWidget) dashboard.getWidget(widgetId); 42 | System.out.println("widget = " + widget); 43 | 44 | ResourceResponse response = new ResourceResponse(); 45 | response.setContentType("application/json"); 46 | response.setWriteCallback(new WriteCallback() { 47 | 48 | @Override 49 | public void writeData(Attributes attributes) throws IOException { 50 | attributes.getResponse().write(widget.getChartData()); 51 | } 52 | 53 | }); 54 | 55 | return response; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /widgets/ofchart/src/main/java/ro/fortsoft/wicket/dashboard/widget/ofchart/DataResourceReference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widget.ofchart; 14 | 15 | import org.apache.wicket.Application; 16 | import org.apache.wicket.request.resource.IResource; 17 | import org.apache.wicket.request.resource.ResourceReference; 18 | 19 | import ro.fortsoft.wicket.dashboard.Dashboard; 20 | import ro.fortsoft.wicket.dashboard.DashboardContextInitializer; 21 | import ro.fortsoft.wicket.dashboard.web.DashboardContext; 22 | 23 | /** 24 | * @author Decebal Suiu 25 | */ 26 | public class DataResourceReference extends ResourceReference { 27 | 28 | private static final long serialVersionUID = 1L; 29 | 30 | public DataResourceReference() { 31 | super(OpenFlashChart.class, "wicket-ofc-data"); 32 | } 33 | 34 | @Override 35 | public IResource getResource() { 36 | return new DataResource(getDashboard()); 37 | } 38 | 39 | // TODO 40 | private Dashboard getDashboard() { 41 | DashboardContext dashboardContext = Application.get().getMetaData(DashboardContextInitializer.DASHBOARD_CONTEXT_KEY); 42 | Dashboard dashboard = dashboardContext.getDashboardPersister().load(); 43 | 44 | return dashboard; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /widgets/ofchart/src/main/java/ro/fortsoft/wicket/dashboard/widget/ofchart/Initializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widget.ofchart; 14 | 15 | import org.apache.wicket.Application; 16 | import org.apache.wicket.IInitializer; 17 | import org.apache.wicket.protocol.http.WebApplication; 18 | 19 | /** 20 | * @author Decebal Suiu 21 | */ 22 | public class Initializer implements IInitializer { 23 | 24 | @Override 25 | public void init(Application application) { 26 | ((WebApplication) application).mountResource("widget-ofc-data", new DataResourceReference()); 27 | } 28 | 29 | @Override 30 | public void destroy(Application application) { 31 | // does noting 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /widgets/ofchart/src/main/java/ro/fortsoft/wicket/dashboard/widget/ofchart/OpenFlashChart.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /widgets/ofchart/src/main/java/ro/fortsoft/wicket/dashboard/widget/ofchart/OpenFlashChart.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Decebal Suiu 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widget.ofchart; 14 | 15 | import org.apache.wicket.markup.head.IHeaderResponse; 16 | import org.apache.wicket.markup.head.JavaScriptHeaderItem; 17 | import org.apache.wicket.markup.html.panel.GenericPanel; 18 | import org.apache.wicket.model.IModel; 19 | import org.apache.wicket.request.Url; 20 | import org.apache.wicket.request.mapper.parameter.PageParameters; 21 | import org.apache.wicket.request.resource.PackageResourceReference; 22 | 23 | import ro.fortsoft.wicket.dashboard.Widget; 24 | 25 | /** 26 | * http://cwiki.apache.org/WICKET/open-flash-chart-and-wicket.html 27 | */ 28 | public class OpenFlashChart extends GenericPanel { 29 | 30 | private static final long serialVersionUID = 1L; 31 | 32 | private String width; 33 | private String height; 34 | private SWFObject swf; 35 | 36 | public OpenFlashChart(String id, String width, String height, IModel model) { 37 | super(id, model); 38 | 39 | this.width = width; 40 | this.height = height; 41 | } 42 | 43 | @Override 44 | public void renderHead(IHeaderResponse response) { 45 | super.renderHead(response); 46 | 47 | response.render(JavaScriptHeaderItem.forReference(new PackageResourceReference(OpenFlashChart.class, "res/saveChartImage.js"))); 48 | } 49 | 50 | @Override 51 | protected void onInitialize() { 52 | super.onInitialize(); 53 | 54 | String swfUrl = toAbsolutePath(urlFor(new PackageResourceReference(OpenFlashChart.class, "res/open-flash-chart.swf"), null).toString()); 55 | 56 | // see http://ofc2dz.com/OFC2/downloads/ofc2Downloads.html 57 | // http://ofc2dz.com/OFC2/examples/MiscellaneousPatches.html (Passing the Char Parameter "ID" when saving images (23-Feb-2009)) 58 | swfUrl = swfUrl.concat("?id=").concat(getMarkupId()); 59 | // System.out.println("swfUrl = " + swfUrl); 60 | swf = new SWFObject(swfUrl, width, height, "9.0.0"); 61 | add(swf); 62 | } 63 | 64 | @Override 65 | protected void onBeforeRender() { 66 | String jsonUrl = getUrlForJson(); 67 | // System.out.println("jsonUrl = " + jsonUrl); 68 | swf.addParameter("data-file", jsonUrl); 69 | swf.addParameter("wmode", "transparent"); 70 | 71 | super.onBeforeRender(); 72 | } 73 | 74 | private String getUrlForJson() { 75 | PageParameters parameters = new PageParameters(); 76 | parameters.add("widgetId", getModelObject().getId()); 77 | String jsonUrl = urlFor(new DataResourceReference(), parameters).toString(); 78 | 79 | return toAbsolutePath(jsonUrl); 80 | } 81 | 82 | private String toAbsolutePath(String relativePath) { 83 | return getRequestCycle().getUrlRenderer().renderFullUrl(Url.parse(relativePath)); 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /widgets/ofchart/src/main/java/ro/fortsoft/wicket/dashboard/widget/ofchart/res/expressInstall.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decebals/wicket-dashboard/ece9250c8bcc8f4fe66b8ea3ba57fdb31561c805/widgets/ofchart/src/main/java/ro/fortsoft/wicket/dashboard/widget/ofchart/res/expressInstall.swf -------------------------------------------------------------------------------- /widgets/ofchart/src/main/java/ro/fortsoft/wicket/dashboard/widget/ofchart/res/open-flash-chart.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decebals/wicket-dashboard/ece9250c8bcc8f4fe66b8ea3ba57fdb31561c805/widgets/ofchart/src/main/java/ro/fortsoft/wicket/dashboard/widget/ofchart/res/open-flash-chart.swf -------------------------------------------------------------------------------- /widgets/ofchart/src/main/java/ro/fortsoft/wicket/dashboard/widget/ofchart/res/open-flash-chart.swf.bad: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decebals/wicket-dashboard/ece9250c8bcc8f4fe66b8ea3ba57fdb31561c805/widgets/ofchart/src/main/java/ro/fortsoft/wicket/dashboard/widget/ofchart/res/open-flash-chart.swf.bad -------------------------------------------------------------------------------- /widgets/ofchart/src/main/java/ro/fortsoft/wicket/dashboard/widget/ofchart/res/saveChartImage.js: -------------------------------------------------------------------------------- 1 | function save_image(chartId) { 2 | openImageWindow(chartId); 3 | } 4 | 5 | function openImageWindow(src) { 6 | var img_win = window.open('', 'Charts: Export as Image') 7 | with (img_win.document) { 8 | write('Charts: Export as Image<\/title><\/head><body>' + image(src) + '<\/body><\/html>') 9 | } 10 | // stop the 'loading...' message 11 | img_win.document.close(); 12 | } 13 | 14 | function image(src) { 15 | return "<img src='data:image/png;base64," + $('#' + src)[0].get_img_binary() + "' />" 16 | } 17 | -------------------------------------------------------------------------------- /widgets/ofchart/src/main/java/wicket.properties: -------------------------------------------------------------------------------- 1 | initializer=ro.fortsoft.wicket.dashboard.widget.ofchart.Initializer -------------------------------------------------------------------------------- /widgets/pom.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 3 | 4 | <parent> 5 | <groupId>ro.fortsoft.wicket.dashboard</groupId> 6 | <artifactId>wicket-dashboard-parent</artifactId> 7 | <version>0.14.0-SNAPSHOT</version> 8 | </parent> 9 | 10 | <modelVersion>4.0.0</modelVersion> 11 | <groupId>ro.fortsoft.wicket.dashboard.widgets</groupId> 12 | <artifactId>wicket-dashboard-widgets-parent</artifactId> 13 | <version>0.14.0-SNAPSHOT</version> 14 | <packaging>pom</packaging> 15 | <name>Wicket Dashboard Widgets Parent</name> 16 | 17 | <properties> 18 | <jofc2.version>1.0.1-SNAPSHOT</jofc2.version> 19 | <jqPlot.version>6.8.0</jqPlot.version> 20 | <loremipsum.version>1.0</loremipsum.version> 21 | <justGage.version>1.0.1</justGage.version> 22 | <wickedCharts.version>1.5.0</wickedCharts.version> 23 | </properties> 24 | 25 | <dependencies> 26 | <dependency> 27 | <groupId>ro.fortsoft.wicket.dashboard</groupId> 28 | <artifactId>wicket-dashboard-core</artifactId> 29 | <version>${project.version}</version> 30 | <scope>provided</scope> 31 | </dependency> 32 | </dependencies> 33 | 34 | <modules> 35 | <module>ofchart</module> 36 | <module>jqplot</module> 37 | <module>loremipsum</module> 38 | <module>justgage</module> 39 | <module>wicked-charts</module> 40 | </modules> 41 | 42 | </project> 43 | -------------------------------------------------------------------------------- /widgets/wicked-charts/pom.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0"?> 2 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 3 | 4 | <parent> 5 | <groupId>ro.fortsoft.wicket.dashboard.widgets</groupId> 6 | <artifactId>wicket-dashboard-widgets-parent</artifactId> 7 | <version>0.14.0-SNAPSHOT</version> 8 | </parent> 9 | 10 | <modelVersion>4.0.0</modelVersion> 11 | <artifactId>wicket-dashboard-wicked-charts</artifactId> 12 | <version>0.14.0-SNAPSHOT</version> 13 | <packaging>jar</packaging> 14 | <name>HighCharts (Wicked-Charts) Widget</name> 15 | 16 | <developers> 17 | <developer> 18 | <name>Paul Bors</name> 19 | <email>Paul@Bors.ws</email> 20 | </developer> 21 | </developers> 22 | 23 | <dependencies> 24 | <!-- HighCharts (integrated in Wicket by Wicked-Charts) --> 25 | <dependency> 26 | <groupId>com.googlecode.wicked-charts</groupId> 27 | <artifactId>wicked-charts-wicket6</artifactId> 28 | <version>${wickedCharts.version}</version> 29 | </dependency> 30 | </dependencies> 31 | 32 | </project> 33 | -------------------------------------------------------------------------------- /widgets/wicked-charts/src/main/java/ro/fortsoft/wicket/dashboard/widgets/wicked/charts/HighChartsFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Paul Bors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widgets.wicked.charts; 14 | 15 | import com.googlecode.wickedcharts.highcharts.options.Options; 16 | 17 | /** 18 | * @author <a href="http://www.GitHub.com/PaulBors">Paul Bors</a> 19 | */ 20 | public interface HighChartsFactory { 21 | public Options createOptions(HighChartsWidget widget); 22 | } 23 | -------------------------------------------------------------------------------- /widgets/wicked-charts/src/main/java/ro/fortsoft/wicket/dashboard/widgets/wicked/charts/HighChartsWidget.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Paul Bors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widgets.wicked.charts; 14 | 15 | import com.googlecode.wickedcharts.highcharts.options.Options; 16 | import com.googlecode.wickedcharts.highcharts.options.SeriesType; 17 | import com.googlecode.wickedcharts.wicket6.highcharts.Chart; 18 | import org.apache.wicket.markup.html.panel.Panel; 19 | import org.apache.wicket.model.Model; 20 | import ro.fortsoft.wicket.dashboard.AbstractWidget; 21 | import ro.fortsoft.wicket.dashboard.Widget; 22 | import ro.fortsoft.wicket.dashboard.web.WidgetView; 23 | import ro.fortsoft.wicket.dashboard.widgets.wicked.charts.options.ShowcaseOptions; 24 | import ro.fortsoft.wicket.dashboard.widgets.wicked.charts.settings.HighChartsSettingsPanel; 25 | import ro.fortsoft.wicket.dashboard.widgets.wicked.charts.settings.Settings; 26 | 27 | import java.util.Map; 28 | 29 | /** 30 | * @author <a href="http://www.GitHub.com/PaulBors">Paul Bors</a> 31 | */ 32 | public class HighChartsWidget extends AbstractWidget { 33 | private static final long serialVersionUID = 1L; 34 | 35 | private static HighChartsFactory highChartsFactory; 36 | 37 | private transient Chart chart; 38 | 39 | public HighChartsWidget() { 40 | super(); 41 | 42 | setTitle("HighCharts"); 43 | 44 | Map<String, String> settings = getSettings(); 45 | settings.put(Settings.seriesType.name(), SeriesType.SPLINE.name()); 46 | } 47 | 48 | public static HighChartsFactory getHighChartsFactory() { 49 | if (highChartsFactory == null) { 50 | throw new RuntimeException("HighChartsFactory cannot be null. Use HighChartsWidget.getHighChartsFactory(...)"); 51 | } 52 | return highChartsFactory; 53 | } 54 | 55 | public static void setHighChartsFactory(HighChartsFactory highChartsFactory) { 56 | HighChartsWidget.highChartsFactory = highChartsFactory; 57 | } 58 | 59 | public Options newOptions() { 60 | return HighChartsWidget.getHighChartsFactory().createOptions(this); 61 | } 62 | 63 | public Chart getChart(String id) { 64 | chart = new Chart(id, newOptions()); 65 | setTitle(((ShowcaseOptions)chart.getOptions()).getLabel()); 66 | return chart; 67 | } 68 | 69 | public void updateChart() { 70 | chart.setOptions(newOptions()); 71 | setTitle(((ShowcaseOptions)chart.getOptions()).getLabel()); 72 | } 73 | 74 | @Override 75 | public boolean hasSettings() { 76 | return true; 77 | } 78 | 79 | @Override 80 | public Panel createSettingsPanel(String settingsPanelId) { 81 | return new HighChartsSettingsPanel(settingsPanelId, new Model<HighChartsWidget>(this)); 82 | } 83 | 84 | public WidgetView createView(String viewId) { 85 | return new HighChartsWidgetView(viewId, new Model<Widget>(this)); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /widgets/wicked-charts/src/main/java/ro/fortsoft/wicket/dashboard/widgets/wicked/charts/HighChartsWidgetDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Paul Bors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widgets.wicked.charts; 14 | 15 | import ro.fortsoft.wicket.dashboard.WidgetDescriptor; 16 | 17 | /** 18 | * @author <a href="http://www.GitHub.com/PaulBors">Paul Bors</a> 19 | */ 20 | public class HighChartsWidgetDescriptor implements WidgetDescriptor { 21 | private static final long serialVersionUID = 1L; 22 | 23 | @Override 24 | public String getDescription() { 25 | return "A chart widget using HighCharts (commercial license) as integrated in Wicket via Wicked-Charts."; 26 | } 27 | 28 | @Override 29 | public String getName() { 30 | return "HighCharts"; 31 | } 32 | 33 | @Override 34 | public String getProvider() { 35 | return "Paul Bors"; 36 | } 37 | 38 | @Override 39 | public String getWidgetClassName() { 40 | return HighChartsWidget.class.getName(); 41 | } 42 | 43 | @Override 44 | public String getTypeName() { 45 | return "widget.highCharts"; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /widgets/wicked-charts/src/main/java/ro/fortsoft/wicket/dashboard/widgets/wicked/charts/HighChartsWidgetView.html: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="utf-8"?> 2 | <html xmlns:wicket="http://wicket.apache.org/"> 3 | <wicket:panel> 4 | <div wicket:id="chart"/> 5 | </wicket:panel> 6 | </html> -------------------------------------------------------------------------------- /widgets/wicked-charts/src/main/java/ro/fortsoft/wicket/dashboard/widgets/wicked/charts/HighChartsWidgetView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Paul Bors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widgets.wicked.charts; 14 | 15 | import org.apache.wicket.model.IModel; 16 | import ro.fortsoft.wicket.dashboard.Widget; 17 | import ro.fortsoft.wicket.dashboard.web.WidgetView; 18 | 19 | /** 20 | * @author <a href="http://www.GitHub.com/PaulBors">Paul Bors</a> 21 | */ 22 | public class HighChartsWidgetView extends WidgetView { 23 | private static final long serialVersionUID = 1L; 24 | 25 | public HighChartsWidgetView(String id, IModel<Widget> model) { 26 | super(id, model); 27 | 28 | final HighChartsWidget widget = (HighChartsWidget)model.getObject(); 29 | add(widget.getChart("chart")); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /widgets/wicked-charts/src/main/java/ro/fortsoft/wicket/dashboard/widgets/wicked/charts/options/AreaSplineOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Paul Bors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widgets.wicked.charts.options; 14 | 15 | import com.googlecode.wickedcharts.highcharts.options.Axis; 16 | import com.googlecode.wickedcharts.highcharts.options.ChartOptions; 17 | import com.googlecode.wickedcharts.highcharts.options.CreditOptions; 18 | import com.googlecode.wickedcharts.highcharts.options.Function; 19 | import com.googlecode.wickedcharts.highcharts.options.HorizontalAlignment; 20 | import com.googlecode.wickedcharts.highcharts.options.Legend; 21 | import com.googlecode.wickedcharts.highcharts.options.LegendLayout; 22 | import com.googlecode.wickedcharts.highcharts.options.PlotBand; 23 | import com.googlecode.wickedcharts.highcharts.options.PlotOptions; 24 | import com.googlecode.wickedcharts.highcharts.options.PlotOptionsChoice; 25 | import com.googlecode.wickedcharts.highcharts.options.SeriesType; 26 | import com.googlecode.wickedcharts.highcharts.options.Title; 27 | import com.googlecode.wickedcharts.highcharts.options.Tooltip; 28 | import com.googlecode.wickedcharts.highcharts.options.VerticalAlignment; 29 | import com.googlecode.wickedcharts.highcharts.options.color.HexColor; 30 | import com.googlecode.wickedcharts.highcharts.options.color.RgbaColor; 31 | import com.googlecode.wickedcharts.highcharts.options.series.SimpleSeries; 32 | 33 | import java.util.Arrays; 34 | import java.util.Collections; 35 | 36 | /** 37 | * @author <a href="http://www.GitHub.com/PaulBors">Paul Bors</a> 38 | */ 39 | public class AreaSplineOptions extends ShowcaseOptions { 40 | private static final long serialVersionUID = 1L; 41 | 42 | public AreaSplineOptions() { 43 | setChart(new ChartOptions().setType(SeriesType.AREASPLINE)); 44 | 45 | setTitle(new Title("Average fruit consumption during one week")); 46 | 47 | setLegend(new Legend() 48 | .setLayout(LegendLayout.VERTICAL) 49 | .setAlign(HorizontalAlignment.LEFT) 50 | .setVerticalAlign(VerticalAlignment.TOP) 51 | .setX(150) 52 | .setY(100) 53 | .setFloating(Boolean.TRUE) 54 | .setBorderWidth(1) 55 | .setBackgroundColor(new HexColor("#FFFFFF")) 56 | ); 57 | 58 | setxAxis(new Axis() 59 | .setCategories( 60 | Arrays.asList(new String[]{ 61 | "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" 62 | }) 63 | ) 64 | .setPlotBands(Collections.singletonList(new PlotBand() 65 | .setFrom(4.5f) 66 | .setTo(6.5f) 67 | .setColor(new RgbaColor(68, 170, 213, .2f))) 68 | ) 69 | ); 70 | 71 | setyAxis(new Axis().setTitle(new Title("Fruit units"))); 72 | 73 | setTooltip( 74 | new Tooltip().setFormatter( 75 | new Function(" return ''+this.x +': '+ this.y +' units';") 76 | ) 77 | ); 78 | 79 | setCredits(new CreditOptions().setEnabled(Boolean.FALSE)); 80 | 81 | setPlotOptions( 82 | new PlotOptionsChoice().setAreaspline( 83 | new PlotOptions().setFillOpacity(0.5f) 84 | ) 85 | ); 86 | 87 | addSeries( 88 | new SimpleSeries() 89 | .setName("John") 90 | .setData(Arrays.asList(new Number[] { 3, 4, 3, 5, 4, 10, 12 })) 91 | ); 92 | 93 | addSeries( 94 | new SimpleSeries() 95 | .setName("Jane") 96 | .setData(Arrays.asList(new Number[] { 1, 3, 4, 3, 3, 5, 4 })) 97 | ); 98 | } 99 | 100 | @Override 101 | public String getLabel() { 102 | return super.getLabel() + "Area spline"; 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /widgets/wicked-charts/src/main/java/ro/fortsoft/wicket/dashboard/widgets/wicked/charts/options/BasicLineOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Paul Bors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widgets.wicked.charts.options; 14 | 15 | import com.googlecode.wickedcharts.highcharts.options.Axis; 16 | import com.googlecode.wickedcharts.highcharts.options.ChartOptions; 17 | import com.googlecode.wickedcharts.highcharts.options.HorizontalAlignment; 18 | import com.googlecode.wickedcharts.highcharts.options.Legend; 19 | import com.googlecode.wickedcharts.highcharts.options.LegendLayout; 20 | import com.googlecode.wickedcharts.highcharts.options.PlotLine; 21 | import com.googlecode.wickedcharts.highcharts.options.SeriesType; 22 | import com.googlecode.wickedcharts.highcharts.options.Title; 23 | import com.googlecode.wickedcharts.highcharts.options.VerticalAlignment; 24 | import com.googlecode.wickedcharts.highcharts.options.color.HexColor; 25 | import com.googlecode.wickedcharts.highcharts.options.series.Series; 26 | import com.googlecode.wickedcharts.highcharts.options.series.SimpleSeries; 27 | 28 | import java.util.Arrays; 29 | import java.util.Collections; 30 | 31 | /** 32 | * @author <a href="http://www.GitHub.com/PaulBors">Paul Bors</a> 33 | */ 34 | public class BasicLineOptions extends ShowcaseOptions { 35 | private static final long serialVersionUID = 1L; 36 | 37 | public BasicLineOptions() { 38 | ChartOptions chartOptions = new ChartOptions(); 39 | chartOptions.setType(SeriesType.LINE); 40 | chartOptions.setMarginRight(130); 41 | chartOptions.setMarginBottom(25); 42 | setChartOptions(chartOptions); 43 | 44 | Title title = new Title("Monthly Average Temperature"); 45 | title.setX(-20); 46 | setTitle(title); 47 | 48 | Title subTitle = new Title("Source: WorldClimate.com"); 49 | subTitle.setX(-20); 50 | setSubtitle(subTitle); 51 | 52 | Axis xAxis = new Axis(); 53 | xAxis.setCategories(Arrays.asList( 54 | new String[] { 55 | "Jan", "Feb", "Mar", "Apr", "May", "Jun", 56 | "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" 57 | } 58 | )); 59 | setxAxis(xAxis); 60 | 61 | PlotLine plotLines = new PlotLine(); 62 | plotLines.setValue(0f); 63 | plotLines.setWidth(1); 64 | plotLines.setColor(new HexColor("#999999")); 65 | 66 | Axis yAxis = new Axis(); 67 | yAxis.setTitle(new Title("Temperature (°C)")); 68 | yAxis.setPlotLines(Collections.singletonList(plotLines)); 69 | setyAxis(yAxis); 70 | 71 | Legend legend = new Legend(); 72 | legend.setLayout(LegendLayout.VERTICAL); 73 | legend.setAlign(HorizontalAlignment.RIGHT); 74 | legend.setVerticalAlign(VerticalAlignment.TOP); 75 | legend.setX(-10); 76 | legend.setY(100); 77 | legend.setBorderWidth(0); 78 | setLegend(legend); 79 | 80 | Series<Number> series1 = new SimpleSeries(); 81 | series1.setName("Tokyo"); 82 | series1.setData(Arrays.asList(new Number[] { 83 | 7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6 84 | })); 85 | addSeries(series1); 86 | 87 | Series<Number> series2 = new SimpleSeries(); 88 | series2.setName("New York"); 89 | series2.setData(Arrays.asList(new Number[] { 90 | -0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5 91 | })); 92 | addSeries(series2); 93 | 94 | Series<Number> series3 = new SimpleSeries(); 95 | series3.setName("Berlin"); 96 | series3.setData(Arrays.asList(new Number[] { 97 | -0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0 98 | })); 99 | addSeries(series3); 100 | 101 | Series<Number> series4 = new SimpleSeries(); 102 | series4.setName("London"); 103 | series4.setData(Arrays.asList(new Number[] { 104 | 3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8 105 | })); 106 | addSeries(series4); 107 | } 108 | 109 | @Override 110 | public String getLabel() { 111 | return super.getLabel() + "Basic line"; 112 | } 113 | } -------------------------------------------------------------------------------- /widgets/wicked-charts/src/main/java/ro/fortsoft/wicket/dashboard/widgets/wicked/charts/options/BubbleChart3DOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Paul Bors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widgets.wicked.charts.options; 14 | 15 | import com.googlecode.wickedcharts.highcharts.options.Axis; 16 | import com.googlecode.wickedcharts.highcharts.options.ChartOptions; 17 | import com.googlecode.wickedcharts.highcharts.options.Marker; 18 | import com.googlecode.wickedcharts.highcharts.options.SeriesType; 19 | import com.googlecode.wickedcharts.highcharts.options.Title; 20 | import com.googlecode.wickedcharts.highcharts.options.ZoomType; 21 | import com.googlecode.wickedcharts.highcharts.options.color.RadialGradient; 22 | import com.googlecode.wickedcharts.highcharts.options.color.RgbaColor; 23 | import com.googlecode.wickedcharts.highcharts.options.series.BubbleSeries; 24 | 25 | /** 26 | * @author <a href="http://www.GitHub.com/PaulBors">Paul Bors</a> 27 | */ 28 | public class BubbleChart3DOptions extends ShowcaseOptions { 29 | private static final long serialVersionUID = 1L; 30 | 31 | public BubbleChart3DOptions() { 32 | setChartOptions(new ChartOptions() 33 | .setType(SeriesType.BUBBLE) 34 | .setPlotBorderWidth(1) 35 | .setZoomType(ZoomType.XY) 36 | ); 37 | 38 | setTitle(new Title("Highcharts Bubbles with radial gradient fill")); 39 | 40 | setxAxis(new Axis() 41 | .setGridLineWidth(1) 42 | ); 43 | 44 | setyAxis(new Axis() 45 | .setStartOnTick(Boolean.FALSE) 46 | .setEndOnTick(Boolean.FALSE) 47 | ); 48 | 49 | addSeries(new BubbleSeries() 50 | .addPoint(9, 81, 63) 51 | .addPoint(98, 5, 89) 52 | .addPoint(51, 50, 73) 53 | .addPoint(41, 22, 14) 54 | .addPoint(58, 24, 20) 55 | .addPoint(78, 37, 34) 56 | .addPoint(55, 56, 53) 57 | .addPoint(18, 45, 70) 58 | .addPoint(42, 44, 28) 59 | .addPoint(3, 52, 59) 60 | .addPoint(31, 18, 97) 61 | .addPoint(79, 91, 63) 62 | .addPoint(93, 23, 23) 63 | .addPoint(44, 83, 22) 64 | .setMarker(new Marker().setFillColor(new RadialGradient() 65 | .setCx(0.4) 66 | .setCy(0.3) 67 | .setR(0.7) 68 | .addStop(0, new RgbaColor(255, 255, 255, 0.5f)) 69 | .addStop(1, new RgbaColor(69, 114, 167, 0.5f)) 70 | )) 71 | ); 72 | 73 | addSeries(new BubbleSeries() 74 | .addPoint(42, 38, 20) 75 | .addPoint(6, 18, 1) 76 | .addPoint(1, 93, 55) 77 | .addPoint(57, 2, 90) 78 | .addPoint(80, 76, 22) 79 | .addPoint(11, 74, 96) 80 | .addPoint(88, 56, 10) 81 | .addPoint(30, 47, 49) 82 | .addPoint(57, 62, 98) 83 | .addPoint(4, 16, 16) 84 | .addPoint(46, 10, 11) 85 | .addPoint(22, 87, 89) 86 | .addPoint(57, 91, 82) 87 | .addPoint(45, 15, 98) 88 | .setMarker(new Marker().setFillColor(new RadialGradient() 89 | .setCx(0.4) 90 | .setCy(0.3) 91 | .setR(0.7) 92 | .addStop(0, new RgbaColor(255, 255, 255, 0.5f)) 93 | .addStop(1, new RgbaColor(170, 70, 67, 0.5f)) 94 | )) 95 | ); 96 | } 97 | 98 | @Override 99 | public String getLabel() { 100 | return super.getLabel() + "3D Bubbles"; 101 | } 102 | } -------------------------------------------------------------------------------- /widgets/wicked-charts/src/main/java/ro/fortsoft/wicket/dashboard/widgets/wicked/charts/options/ColumnRangeOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Paul Bors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widgets.wicked.charts.options; 14 | 15 | import com.googlecode.wickedcharts.highcharts.options.Axis; 16 | import com.googlecode.wickedcharts.highcharts.options.ChartOptions; 17 | import com.googlecode.wickedcharts.highcharts.options.DataLabels; 18 | import com.googlecode.wickedcharts.highcharts.options.Function; 19 | import com.googlecode.wickedcharts.highcharts.options.Legend; 20 | import com.googlecode.wickedcharts.highcharts.options.PlotOptions; 21 | import com.googlecode.wickedcharts.highcharts.options.PlotOptionsChoice; 22 | import com.googlecode.wickedcharts.highcharts.options.SeriesType; 23 | import com.googlecode.wickedcharts.highcharts.options.Title; 24 | import com.googlecode.wickedcharts.highcharts.options.Tooltip; 25 | import com.googlecode.wickedcharts.highcharts.options.series.CoordinatesSeries; 26 | 27 | /** 28 | * @author <a href="http://www.GitHub.com/PaulBors">Paul Bors</a> 29 | */ 30 | public class ColumnRangeOptions extends ShowcaseOptions { 31 | private static final long serialVersionUID = 1L; 32 | 33 | public ColumnRangeOptions() { 34 | setChartOptions(new ChartOptions() 35 | .setType(SeriesType.COLUMNRANGE) 36 | .setInverted(Boolean.TRUE) 37 | ); 38 | 39 | setTitle(new Title("Temperature variation by month")); 40 | 41 | setSubtitle(new Title("Observed in Vik i Sogn, Norway, 2009")); 42 | 43 | setxAxis(new Axis() 44 | .setCategories( 45 | "Jan", 46 | "Feb", 47 | "Mar", 48 | "Apr", 49 | "May", 50 | "Jun", 51 | "Jul", 52 | "Aug", 53 | "Sep", 54 | "Oct", 55 | "Nov", 56 | "Dec" 57 | ) 58 | ); 59 | 60 | setyAxis(new Axis() 61 | .setTitle(new Title("Temperature (°C)")) 62 | ); 63 | 64 | setTooltip(new Tooltip() 65 | .setValueSuffix("°C") 66 | ); 67 | 68 | setPlotOptions(new PlotOptionsChoice() 69 | .setColumnrange(new PlotOptions() 70 | .setDataLabels(new DataLabels() 71 | .setEnabled(Boolean.TRUE) 72 | .setFormatter(new Function("return this.y + '°C';")) 73 | .setY(0)) 74 | ) 75 | ); 76 | 77 | setLegend(new Legend(Boolean.FALSE)); 78 | 79 | addSeries(new CoordinatesSeries() 80 | .addPoint(-9.7, 9.4) 81 | .addPoint(-8.7, 6.5) 82 | .addPoint(-3.5, 9.4) 83 | .addPoint(-1.4, 19.9) 84 | .addPoint(0.0, 22.6) 85 | .addPoint(2.9, 29.5) 86 | .addPoint(9.2, 30.7) 87 | .addPoint(7.3, 26.5) 88 | .addPoint(4.4, 18.0) 89 | .addPoint(-3.1, 11.4) 90 | .addPoint(-5.2, 10.4) 91 | .addPoint(-13.5, 9.8) 92 | ); 93 | } 94 | 95 | @Override 96 | public String getLabel() { 97 | return super.getLabel() + "Column range"; 98 | } 99 | } -------------------------------------------------------------------------------- /widgets/wicked-charts/src/main/java/ro/fortsoft/wicket/dashboard/widgets/wicked/charts/options/PieWithLegendOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Paul Bors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widgets.wicked.charts.options; 14 | 15 | import com.googlecode.wickedcharts.highcharts.options.ChartOptions; 16 | import com.googlecode.wickedcharts.highcharts.options.Cursor; 17 | import com.googlecode.wickedcharts.highcharts.options.DataLabels; 18 | import com.googlecode.wickedcharts.highcharts.options.PlotOptions; 19 | import com.googlecode.wickedcharts.highcharts.options.PlotOptionsChoice; 20 | import com.googlecode.wickedcharts.highcharts.options.SeriesType; 21 | import com.googlecode.wickedcharts.highcharts.options.Title; 22 | import com.googlecode.wickedcharts.highcharts.options.Tooltip; 23 | import com.googlecode.wickedcharts.highcharts.options.color.NullColor; 24 | import com.googlecode.wickedcharts.highcharts.options.series.Point; 25 | import com.googlecode.wickedcharts.highcharts.options.series.PointSeries; 26 | 27 | /** 28 | * @author <a href="http://www.GitHub.com/PaulBors">Paul Bors</a> 29 | */ 30 | public class PieWithLegendOptions extends ShowcaseOptions { 31 | private static final long serialVersionUID = 1L; 32 | 33 | public PieWithLegendOptions() { 34 | setChartOptions(new ChartOptions() 35 | .setPlotBackgroundColor(new NullColor()) 36 | .setPlotBorderWidth(null) 37 | .setPlotShadow(Boolean.FALSE) 38 | ); 39 | 40 | setTitle(new Title("Browser market shares at a specific website, 2010")); 41 | 42 | setTooltip(new Tooltip() 43 | .setPointFormat("{series.name}: <b>{point.percentage}%</b>") 44 | .setPercentageDecimals(1) 45 | ); 46 | 47 | setPlotOptions(new PlotOptionsChoice() 48 | .setPie(new PlotOptions() 49 | .setAllowPointSelect(Boolean.TRUE) 50 | .setCursor(Cursor.POINTER) 51 | .setDataLabels(new DataLabels() 52 | .setEnabled(Boolean.TRUE)) 53 | .setShowInLegend(Boolean.TRUE) 54 | ) 55 | ); 56 | 57 | addSeries(new PointSeries() 58 | .setType(SeriesType.PIE) 59 | .setName("Browser share") 60 | .addPoint(new Point("Firefox", 45.0)) 61 | .addPoint(new Point("IE", 26.8)) 62 | .addPoint(new Point("Chrome", 12.8) 63 | .setSliced(Boolean.TRUE) 64 | .setSelected(Boolean.TRUE)) 65 | .addPoint(new Point("Safari", 8.5)) 66 | .addPoint(new Point("Opera", 6.2)) 67 | .addPoint(new Point("Others", 0.7)) 68 | ); 69 | 70 | } 71 | 72 | @Override 73 | public String getLabel() { 74 | return super.getLabel() + "Pie with legend"; 75 | } 76 | } -------------------------------------------------------------------------------- /widgets/wicked-charts/src/main/java/ro/fortsoft/wicket/dashboard/widgets/wicked/charts/options/ShowcaseOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Paul Bors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widgets.wicked.charts.options; 14 | 15 | import com.googlecode.wickedcharts.highcharts.options.Options; 16 | 17 | /** 18 | * Abstract parent class for all Options in the showcase. 19 | * 20 | * @author <a href="http://www.GitHub.com/PaulBors">Paul Bors</a> 21 | */ 22 | public abstract class ShowcaseOptions extends Options { 23 | private static final long serialVersionUID = 1L; 24 | 25 | /** 26 | * The label under which the Options class is shown in navigation. 27 | */ 28 | public String getLabel() { 29 | return "HighCharts: "; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /widgets/wicked-charts/src/main/java/ro/fortsoft/wicket/dashboard/widgets/wicked/charts/settings/HighChartsSettingsPanel.html: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="utf-8"?> 2 | <html xmlns:wicket="http://wicket.apache.org/"> 3 | <wicket:panel> 4 | <form wicket:id="form"> 5 | <span>Type</span> 6 | <select wicket:id="seriesType"></select> 7 | <a wicket:id="submit" class="button">Save</a> 8 | <a wicket:id="cancel" class="button">Cancel</a> 9 | <br> 10 | Visit the <a href="http://www.HighCharts.com/demo/">HighCharts demo</a> site for a full list of chart types. 11 | </form> 12 | </wicket:panel> 13 | </html> -------------------------------------------------------------------------------- /widgets/wicked-charts/src/main/java/ro/fortsoft/wicket/dashboard/widgets/wicked/charts/settings/Settings.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Paul Bors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with 5 | * the License. You may obtain a copy of the License in the LICENSE file, or at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the 11 | * specific language governing permissions and limitations under the License. 12 | */ 13 | package ro.fortsoft.wicket.dashboard.widgets.wicked.charts.settings; 14 | 15 | import com.googlecode.wickedcharts.highcharts.options.SeriesType; 16 | 17 | import java.util.Map; 18 | 19 | /** 20 | * @author <a href="http://www.GitHub.com/PaulBors">Paul Bors</a> 21 | */ 22 | public enum Settings { 23 | seriesType("seriesType"); 24 | 25 | private String name; 26 | 27 | Settings(String name) { 28 | this.name = name; 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return name; 34 | } 35 | 36 | public static SeriesType toSeriesType(Map<String, String> settings) { 37 | return SeriesType.valueOf(settings.get(seriesType.name())); 38 | } 39 | 40 | } 41 | --------------------------------------------------------------------------------