Mercurial > people > jerboaa > scheduler-plugin
changeset 4:80dd4b9b42e2
Add controllers and actual UI.
line wrap: on
line diff
--- a/client-common/pom.xml Sat Jan 26 01:23:23 2013 +0100 +++ b/client-common/pom.xml Thu Feb 07 18:33:27 2013 +0100 @@ -108,6 +108,8 @@ <Bundle-SymbolicName>com.redhat.thermostat.tutorial.schedule.client.common</Bundle-SymbolicName> <Export-Package> com.redhat.thermostat.tutorial.schedule.client.common, + com.redhat.thermostat.tutorial.schedule.client.common.locale, + com.redhat.thermostat.tutorial.schedule.client.common.clock, </Export-Package> <!-- Do not autogenerate uses clauses in Manifests --> <_nouses>true</_nouses>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client-common/src/main/java/com/redhat/thermostat/tutorial/schedule/client/common/ClockView.java Thu Feb 07 18:33:27 2013 +0100 @@ -0,0 +1,83 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * <http://www.gnu.org/licenses/>. + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.tutorial.schedule.client.common; + +import com.redhat.thermostat.client.core.views.BasicView; +import com.redhat.thermostat.client.core.views.UIComponent; +import com.redhat.thermostat.common.ActionListener; +import com.redhat.thermostat.common.ActionNotifier; +import com.redhat.thermostat.tutorial.schedule.client.common.clock.ClockTime; + +/** + * View that provides the Clock and Stopwatch element. + */ +public abstract class ClockView extends BasicView implements UIComponent { + + public enum ClockViewAction { + + TOGGLE_PRESENTATION_MODE, + } + protected final ActionNotifier<ClockViewAction> clockViewNotifier; + + public ClockView() { + clockViewNotifier = new ActionNotifier<>(this); + } + + public void addClockViewActionListener(ActionListener<ClockViewAction> listener) { + clockViewNotifier.addActionListener(listener); + } + + public void removeClockViewActionListener(ActionListener<ClockViewAction> listener) { + clockViewNotifier.removeActionListener(listener); + } + + /** + * Display or hide the presentation details. + * + * <br /><br /> + * + * The presentation details contain information about the presentation, like + * the authors and the current presentation title. This method toggles off + * (or on) the display of such information. + */ + public abstract void displayPresentationDetails(boolean display); + + /** + * Display the given {@link ClockTime} in the current {@code ClockView}. + */ + public abstract void displayTime(ClockTime time); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client-common/src/main/java/com/redhat/thermostat/tutorial/schedule/client/common/IconResources.java Thu Feb 07 18:33:27 2013 +0100 @@ -0,0 +1,68 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * <http://www.gnu.org/licenses/>. + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.tutorial.schedule.client.common; + +import com.redhat.thermostat.client.ui.IconDescriptor; + +/** + * Class to hold {@link IconDescriptor} for the icons used by the plugin GUI. + * + * <br /><br /> + * + * {@link IconDescriptor}s are cross GUI Toolkit versions of images. They can + * carry any image type of any size (limited by available memory), although + * they are mainly + */ +public class IconResources { + + private static IconDescriptor loadFile; + private static IconDescriptor presentation; + + public static IconDescriptor getLoadFileIcon() { + if (loadFile == null) { + loadFile = IconDescriptor.loadIcon("com/redhat/thermostat/tutorial/schedule/client/common/load.png"); + } + return loadFile; + } + + public static IconDescriptor getPresentationIcon() { + if (presentation == null) { + presentation = IconDescriptor.loadIcon("com/redhat/thermostat/tutorial/schedule/client/common/presentation.png"); + } + return presentation; + } +}
--- a/client-common/src/main/java/com/redhat/thermostat/tutorial/schedule/client/common/SchedulerView.java Sat Jan 26 01:23:23 2013 +0100 +++ b/client-common/src/main/java/com/redhat/thermostat/tutorial/schedule/client/common/SchedulerView.java Thu Feb 07 18:33:27 2013 +0100 @@ -39,6 +39,8 @@ import com.redhat.thermostat.client.core.views.BasicView; import com.redhat.thermostat.client.core.views.UIComponent; import com.redhat.thermostat.client.core.views.View; +import com.redhat.thermostat.common.ActionListener; +import com.redhat.thermostat.common.ActionNotifier; /** * This class represents a Thermostat {@link View}. @@ -60,5 +62,25 @@ * class with the correct {@link UIComponent} specialisation. */ public abstract class SchedulerView extends BasicView implements UIComponent { + + public enum SchedulerViewAction { + LOAD_SCHEDULE, + } + + protected final ActionNotifier<SchedulerView.SchedulerViewAction> schedulerViewNotifier; + + public SchedulerView() { + schedulerViewNotifier = new ActionNotifier<>(this); + } + + public void addSchedulerViewActionListener(ActionListener<SchedulerView.SchedulerViewAction> listener) { + schedulerViewNotifier.addActionListener(listener); + } + + public void removeSchedulerViewActionListener(ActionListener<SchedulerView.SchedulerViewAction> listener) { + schedulerViewNotifier.removeActionListener(listener); + } + + public abstract ClockView getClockView(); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client-common/src/main/java/com/redhat/thermostat/tutorial/schedule/client/common/clock/ClockTime.java Thu Feb 07 18:33:27 2013 +0100 @@ -0,0 +1,90 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * <http://www.gnu.org/licenses/>. + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.tutorial.schedule.client.common.clock; + +/** + * Simple class representing a Clock time wiht hours, minutes and seconds. + */ +public class ClockTime { + + private int hour; + private int minute; + private int second; + + /** + * @return the hour + */ + public int getHour() { + return hour; + } + + /** + * @param hour the hour to set + */ + public void setHour(int hour) { + this.hour = hour; + } + + /** + * @return the minute + */ + public int getMinute() { + return minute; + } + + /** + * @param minute the minute to set + */ + public void setMinute(int minute) { + this.minute = minute; + } + + /** + * @return the second + */ + public int getSecond() { + return second; + } + + /** + * @param second the second to set + */ + public void setSecond(int second) { + this.second = second; + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client-common/src/main/java/com/redhat/thermostat/tutorial/schedule/client/common/locale/LocaleResources.java Thu Feb 07 18:33:27 2013 +0100 @@ -0,0 +1,68 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * <http://www.gnu.org/licenses/>. + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ +package com.redhat.thermostat.tutorial.schedule.client.common.locale; + +import com.redhat.thermostat.common.locale.Translate; + +/** + * Localization helper Enum. + * + * <br /><br /> + * + * In Thermostat localisation is handled via {@link Enum} and {@link Translate} + * classes pairs. {@link Translate} instances are usually created directly + * by the respective {@code LocaleResources} class and contain reference to + * all the i18n strings of the plugin. Of course, there can be more + * {@code LocaleResources} depending on the actual needs of the plugin. + */ +public enum LocaleResources { + + SCHEDULER_TAB, + PRESENTATION_TITLE, + SPEAKERS, + HEADER_LABEL, + LOAD_SCHEDULE, + PRESENTATION_MODE, + CLOCK_VIEW_TITLE, + PRESENTATION_SUMMARY; + + public static final String RESOURCE_BUNDLE = + "com.redhat.thermostat.tutorial.schedule.client.common.locale.strings"; + + public static Translate<LocaleResources> createLocalizer() { + return new Translate<>(RESOURCE_BUNDLE, LocaleResources.class); + } +}
Binary file client-common/src/main/resources/com/redhat/thermostat/thread/client/common/gtk-media-record.png has changed
--- a/client-common/src/main/resources/com/redhat/thermostat/thread/client/common/locale/strings.properties Sat Jan 26 01:23:23 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -MISSING_INFO = Missing Information - -NAME = Name -ID = ID -START = Started -STOP = Stopped -WAIT_COUNT = Wait Count -BLOCK_COUNT = Blocked Count -RUNNING = Running % -WAITING = Waiting % -SLEEPING = Sleeping % -MONITOR = Monitor % - -START_RECORDING = Start Recording -STOP_RECORDING = Stop Recording -THREAD_MONITOR_SWITCH = Monitor Thread - -VM_CAPABILITIES = VM Capabilities -TABLE = Table -DETAILS = Details -TIMELINE = Timeline -THREAD_COUNT = Thread Count - -LIVE_THREADS = Live Threads -DAEMON_THREADS = Daemon Threads - -THREAD_CONTROL_PANEL = Thread Control Panel -THREAD_DUMP = Thread Dump - -THREAD_DETAILS_EMTPY = Please double-click on a thread in the thread table
Binary file client-common/src/main/resources/com/redhat/thermostat/thread/client/common/monitor.png has changed
Binary file client-common/src/main/resources/com/redhat/thermostat/thread/client/common/record.png has changed
Binary file client-common/src/main/resources/com/redhat/thermostat/tutorial/schedule/client/common/load.png has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client-common/src/main/resources/com/redhat/thermostat/tutorial/schedule/client/common/locale/strings.properties Thu Feb 07 18:33:27 2013 +0100 @@ -0,0 +1,8 @@ +SCHEDULER_TAB=Scheduler +HEADER_LABEL=FreeJav DevRoom Schedule +PRESENTATION_TITLE=Title +SPEAKERS=Speakers +LOAD_SCHEDULE=Load Presentations +PRESENTATION_MODE=Presentation Mode +CLOCK_VIEW_TITLE=Clock +PRESENTATION_SUMMARY=Full Schedule
Binary file client-common/src/main/resources/com/redhat/thermostat/tutorial/schedule/client/common/presentation.png has changed
--- a/client-controllers/pom.xml Sat Jan 26 01:23:23 2013 +0100 +++ b/client-controllers/pom.xml Thu Feb 07 18:33:27 2013 +0100 @@ -114,6 +114,12 @@ </dependencies> <build> + <resources> + <resource> + <directory>src/main/resources</directory> + <filtering>false</filtering> + </resource> + </resources> <plugins> <plugin> <groupId>org.apache.felix</groupId>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client-controllers/src/main/java/com/redhat/thermostat/tutorial/schedule/client/controller/impl/ClockController.java Thu Feb 07 18:33:27 2013 +0100 @@ -0,0 +1,165 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * <http://www.gnu.org/licenses/>. + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.tutorial.schedule.client.controller.impl; + +import com.redhat.thermostat.client.core.views.BasicView; +import com.redhat.thermostat.client.core.views.BasicView.Action; + +import com.redhat.thermostat.common.ActionEvent; +import com.redhat.thermostat.common.ActionListener; +import com.redhat.thermostat.common.ApplicationCache; +import com.redhat.thermostat.common.Timer; + +import com.redhat.thermostat.tutorial.schedule.client.common.ClockView; +import com.redhat.thermostat.tutorial.schedule.client.common.ClockView.ClockViewAction; +import com.redhat.thermostat.tutorial.schedule.client.common.clock.ClockTime; +import java.util.Calendar; + +import java.util.Date; +import java.util.concurrent.TimeUnit; + +/** + * Controller class for the {@link ClockView}. + */ +public class ClockController { + + private static final String LOCK = new String("ClockControllerLock"); + + private static final String SHOW_DETAILS_KEY = "SHOW_DETAILS_KEY"; + private static final String PRESENTATION_MODE_KEY = "PRESENTATION_MODE_KEY"; + + private volatile boolean presentationMode; + + private ClockView clockView; + private ApplicationCache applicationCache; + + public ClockController(ClockView clockView, ApplicationCache applicationCache) { + + this.clockView = clockView; + this.applicationCache = applicationCache; + + clockView.displayPresentationDetails(isShowDetails()); + presentationMode = isPresentationMode(); + } + + private boolean isShowDetails() { + return getValue(SHOW_DETAILS_KEY); + } + + private boolean isPresentationMode() { + return getValue(PRESENTATION_MODE_KEY); + } + + private boolean getValue(String key) { + Boolean result = (Boolean) applicationCache.getAttribute(key); + return result != null ? result : false; + } + + private void togglePresentationMode() { + synchronized (LOCK) { + presentationMode = !presentationMode; + applicationCache.addAttribute(PRESENTATION_MODE_KEY, presentationMode); + clockView.displayPresentationDetails(presentationMode); + } + } + + void initController(final Timer timer) { + timer.setDelay(1); + timer.setTimeUnit(TimeUnit.SECONDS); + + // don't need exact seconds since we calculate correct timing each time + timer.setSchedulingType(Timer.SchedulingType.FIXED_RATE); + timer.setAction(new Runnable() { + @Override + public void run() { + boolean _presentationMode = false; + synchronized (LOCK) { + _presentationMode = ClockController.this.presentationMode; + } + + if (!_presentationMode) { + // normal clock mode, so we just show the current time + long nowMillis = System.currentTimeMillis(); + Date now = new Date(nowMillis); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(now); + + int hour = calendar.get(Calendar.HOUR); + int minute = calendar.get(Calendar.MINUTE); + int second = calendar.get(Calendar.SECOND); + + ClockTime time = new ClockTime(); + time.setHour(hour); + time.setMinute(minute); + time.setSecond(second); + + clockView.displayTime(time); + } + } + }); + clockView.addActionListener(new ActionListener<BasicView.Action>() { + @Override + public void actionPerformed(ActionEvent<Action> actionEvent) { + switch (actionEvent.getActionId()) { + case VISIBLE: + timer.start(); + break; + + case HIDDEN: + timer.stop(); + break; + + default: + break; + } + } + }); + clockView.addClockViewActionListener(new ActionListener<ClockView.ClockViewAction>() { + @Override + public void actionPerformed(ActionEvent<ClockViewAction> actionEvent) { + switch (actionEvent.getActionId()) { + case TOGGLE_PRESENTATION_MODE: + togglePresentationMode(); + break; + + default: + break; + } + } + }); + } +}
--- a/client-controllers/src/main/java/com/redhat/thermostat/tutorial/schedule/client/controller/impl/SchedulerInformationService.java Sat Jan 26 01:23:23 2013 +0100 +++ b/client-controllers/src/main/java/com/redhat/thermostat/tutorial/schedule/client/controller/impl/SchedulerInformationService.java Thu Feb 07 18:33:27 2013 +0100 @@ -41,7 +41,7 @@ import com.redhat.thermostat.client.core.NameMatchingRefFilter; import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.common.dao.HostRef; +import com.redhat.thermostat.storage.core.HostRef; import com.redhat.thermostat.tutorial.schedule.client.common.SchedulerViewProvider; /**
--- a/client-controllers/src/main/java/com/redhat/thermostat/tutorial/schedule/client/controller/impl/SchedulerMainController.java Sat Jan 26 01:23:23 2013 +0100 +++ b/client-controllers/src/main/java/com/redhat/thermostat/tutorial/schedule/client/controller/impl/SchedulerMainController.java Thu Feb 07 18:33:27 2013 +0100 @@ -38,25 +38,43 @@ import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.client.core.views.UIComponent; +import com.redhat.thermostat.common.ActionEvent; +import com.redhat.thermostat.common.ActionListener; import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.common.dao.HostRef; +import com.redhat.thermostat.storage.core.HostRef; import com.redhat.thermostat.tutorial.schedule.client.common.SchedulerView; +import com.redhat.thermostat.tutorial.schedule.client.common.SchedulerView.SchedulerViewAction; import com.redhat.thermostat.tutorial.schedule.client.common.SchedulerViewProvider; +import java.io.File; /** * Main controller for the Scheduler plugin. */ public class SchedulerMainController implements InformationServiceController<HostRef> { - private ApplicationService applicationService; - private SchedulerViewProvider schedulerProvider; private SchedulerView view; SchedulerMainController(ApplicationService applicationService, SchedulerViewProvider schedulerProvider) { - this.applicationService = applicationService; - this.schedulerProvider = schedulerProvider; + + view = schedulerProvider.createView(); - view = schedulerProvider.createView(); + view.addSchedulerViewActionListener(new ActionListener<SchedulerView.SchedulerViewAction>() { + @Override + public void actionPerformed(ActionEvent<SchedulerViewAction> actionEvent) { + switch (actionEvent.getActionId()) { + case LOAD_SCHEDULE: + File payload = (File) actionEvent.getPayload(); + System.err.println("file: " + payload); + break; + + default: + break; + } + } + }); + + ClockController clockController = new ClockController(view.getClockView(), applicationService.getApplicationCache()); + clockController.initController(applicationService.getTimerFactory().createTimer()); } @Override
--- a/client-controllers/src/main/java/com/redhat/thermostat/tutorial/schedule/client/controller/osgi/Activator.java Sat Jan 26 01:23:23 2013 +0100 +++ b/client-controllers/src/main/java/com/redhat/thermostat/tutorial/schedule/client/controller/osgi/Activator.java Thu Feb 07 18:33:27 2013 +0100 @@ -41,7 +41,7 @@ import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; -import com.redhat.thermostat.common.dao.HostRef; +import com.redhat.thermostat.storage.core.HostRef; import com.redhat.thermostat.tutorial.schedule.client.common.SchedulerViewProvider; import com.redhat.thermostat.tutorial.schedule.client.controller.impl.SchedulerInformationService; import java.util.Dictionary;
--- a/client-swing/pom.xml Sat Jan 26 01:23:23 2013 +0100 +++ b/client-swing/pom.xml Thu Feb 07 18:33:27 2013 +0100 @@ -125,6 +125,8 @@ </Export-Package> <Private-Package> com.redhat.thermostat.tutorial.schedule.client.swing.impl, + com.redhat.thermostat.tutorial.schedule.client.swing.impl.clock, + com.redhat.thermostat.tutorial.schedule.client.swing.impl.scheduler, com.redhat.thermostat.tutorial.schedule.client.swing.osgi, </Private-Package> <!-- Do not autogenerate uses clauses in Manifests -->
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client-swing/src/main/java/com/redhat/thermostat/tutorial/schedule/client/swing/impl/ClockUtils.java Thu Feb 07 18:33:27 2013 +0100 @@ -0,0 +1,65 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * <http://www.gnu.org/licenses/>. + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.tutorial.schedule.client.swing.impl; + +import com.redhat.thermostat.client.ui.Palette; +import com.redhat.thermostat.common.locale.Translate; +import com.redhat.thermostat.tutorial.schedule.client.common.locale.LocaleResources; +import java.awt.Color; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; + +/** + * Some common utilities + */ +public class ClockUtils { + + private static final Translate<LocaleResources> t = LocaleResources.createLocalizer(); + + public static final boolean DEBUG = false; + public static final Color PANEL_BG = new Color(51, 51, 51); + public static final Color PANEL_FG = Palette.GRAY.getColor(); + + public static GraphicsDevice getGraphicsDevice() { + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + return ge.getDefaultScreenDevice(); + } + + public static String localize(LocaleResources toTranslate) { + return t.localize(toTranslate); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client-swing/src/main/java/com/redhat/thermostat/tutorial/schedule/client/swing/impl/ContentPanel.java Thu Feb 07 18:33:27 2013 +0100 @@ -0,0 +1,141 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * <http://www.gnu.org/licenses/>. + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.tutorial.schedule.client.swing.impl; + +import com.redhat.thermostat.client.swing.components.HeaderPanel; +import com.redhat.thermostat.tutorial.schedule.client.common.clock.ClockTime; +import com.redhat.thermostat.tutorial.schedule.client.swing.impl.clock.ClockPanel; +import com.redhat.thermostat.tutorial.schedule.client.swing.impl.scheduler.CurrentPresentationPanel; +import com.redhat.thermostat.tutorial.schedule.client.swing.impl.scheduler.PresentationBorder; +import java.awt.BorderLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import javax.swing.Timer; + +/** + * Panel that contains all the UI elements. + */ +@SuppressWarnings("serial") +public class ContentPanel extends JPanel { + + private CurrentPresentationPanel onAir; + private ClockPanel clock; + public ContentPanel() { + + setLayout(new BorderLayout()); + setBackground(ClockUtils.PANEL_BG); + + onAir = new CurrentPresentationPanel(); + onAir.setBorder(new PresentationBorder(PresentationBorder.Border.EST)); + add(onAir, BorderLayout.WEST); + + clock = new ClockPanel(); + add(clock, BorderLayout.CENTER); + } + + public void displayOnAirInformation(boolean display) { + onAir.setVisible(display); + repaint(); + } + + public ClockPanel getClock() { + return clock; + } + + public static final void main(String[] args) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + JFrame frame = new JFrame(); + frame.setSize(500, 500); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + ClockTime time = new ClockTime(); + time.setSecond(10); + time.setMinute(59); + time.setHour(11); + + final ContentPanel panel = new ContentPanel(); + panel.getClock().setTime(time); + panel.displayOnAirInformation(true); + Timer timer = new Timer(1000, new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + + ClockTime time = panel.getClock().getTime(); + + int second = time.getSecond(); + int minute = time.getMinute(); + int hour = time.getHour(); + + second -= 1; + if (second < 0) { + second = 60; + + minute -= 1; + if (minute < 0) { + minute = 60; + hour -= 1; + if (hour < 0) { + hour = 12; + } + } + + } + + time.setSecond(second); + time.setMinute(minute); + time.setHour(hour); + + panel.clock.setTime(time); + + panel.clock.repaint(); + } + }); + timer.setInitialDelay(1000); + timer.start(); + + frame.getContentPane().add(panel); + + frame.setVisible(true); + } + }); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client-swing/src/main/java/com/redhat/thermostat/tutorial/schedule/client/swing/impl/SwingClockView.java Thu Feb 07 18:33:27 2013 +0100 @@ -0,0 +1,105 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * <http://www.gnu.org/licenses/>. + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.tutorial.schedule.client.swing.impl; + +import com.redhat.thermostat.client.core.views.BasicView; +import com.redhat.thermostat.client.swing.ComponentVisibleListener; +import com.redhat.thermostat.client.swing.SwingComponent; +import com.redhat.thermostat.client.swing.components.ActionButton; +import com.redhat.thermostat.client.swing.components.ActionToggleButton; +import com.redhat.thermostat.client.swing.components.HeaderPanel; +import com.redhat.thermostat.client.swing.components.ToolbarButton; +import com.redhat.thermostat.tutorial.schedule.client.common.ClockView; +import com.redhat.thermostat.tutorial.schedule.client.common.IconResources; +import com.redhat.thermostat.tutorial.schedule.client.common.clock.ClockTime; +import com.redhat.thermostat.tutorial.schedule.client.common.locale.LocaleResources; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.ImageIcon; + +/** + */ +public class SwingClockView extends ClockView implements SwingComponent { + + private ContentPanel content; + + public SwingClockView(HeaderPanel panel) { + + content = new ContentPanel(); + + panel.setContent(content); + + // notify listeners when this panel is visible or invisible + content.addHierarchyListener(new ComponentVisibleListener() { + @Override + public void componentShown(Component e) { + SwingClockView.this.notifier.fireAction(BasicView.Action.VISIBLE); + } + + @Override + public void componentHidden(Component e) { + SwingClockView.this.notifier.fireAction(BasicView.Action.VISIBLE); + } + }); + + ToolbarButton presentationMode = new ActionToggleButton(new ImageIcon(IconResources.getPresentationIcon().getData().array()), + ClockUtils.localize(LocaleResources.PRESENTATION_MODE)); + presentationMode.getToolbarButton().addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + SwingClockView.this.clockViewNotifier.fireAction(SwingClockView.ClockViewAction.TOGGLE_PRESENTATION_MODE); + } + }); + panel.addToolBarButton(presentationMode); + } + + @Override + public void displayPresentationDetails(boolean display) { + content.displayOnAirInformation(display); + } + + @Override + public void displayTime(ClockTime time) { + content.getClock().setTime(time); + } + + @Override + public Component getUiComponent() { + return content; + } +}
--- a/client-swing/src/main/java/com/redhat/thermostat/tutorial/schedule/client/swing/impl/SwingSchedulerView.java Sat Jan 26 01:23:23 2013 +0100 +++ b/client-swing/src/main/java/com/redhat/thermostat/tutorial/schedule/client/swing/impl/SwingSchedulerView.java Thu Feb 07 18:33:27 2013 +0100 @@ -37,20 +37,69 @@ package com.redhat.thermostat.tutorial.schedule.client.swing.impl; import com.redhat.thermostat.client.swing.SwingComponent; +import com.redhat.thermostat.client.swing.components.ActionButton; +import com.redhat.thermostat.client.swing.components.HeaderPanel; +import com.redhat.thermostat.client.swing.components.ToolbarButton; +import com.redhat.thermostat.tutorial.schedule.client.common.ClockView; +import com.redhat.thermostat.tutorial.schedule.client.common.IconResources; import com.redhat.thermostat.tutorial.schedule.client.common.SchedulerView; +import com.redhat.thermostat.tutorial.schedule.client.common.locale.LocaleResources; import java.awt.Component; -import javax.swing.JLabel; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import javax.swing.ImageIcon; +import javax.swing.JFileChooser; +import javax.swing.filechooser.FileFilter; /** * This is an actual Swing based implementation of a Thermostat {@link View}. */ public class SwingSchedulerView extends SchedulerView implements SwingComponent { + private SwingClockView clockView; + private HeaderPanel uiComponent; + public SwingSchedulerView() { + uiComponent = new HeaderPanel(ClockUtils.localize(LocaleResources.HEADER_LABEL)); + ToolbarButton loadSchedule = new ActionButton(new ImageIcon(IconResources.getLoadFileIcon().getData().array()), + ClockUtils.localize(LocaleResources.LOAD_SCHEDULE)); + loadSchedule.getToolbarButton().addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JFileChooser fileChooser = new JFileChooser(); + FileFilter filter = new FileFilter() { + + @Override + public boolean accept(File f) { + return (f.isDirectory() || f.getName().endsWith("ics")); + } + + @Override + public String getDescription() { + return "iCal"; + } + }; + fileChooser.setFileFilter(filter); + int open = fileChooser.showOpenDialog(clockView.getUiComponent()); + if (open == JFileChooser.APPROVE_OPTION) { + File payload = fileChooser.getSelectedFile(); + SwingSchedulerView.this.schedulerViewNotifier.fireAction(SchedulerViewAction.LOAD_SCHEDULE, payload); + } + } + }); + + uiComponent.addToolBarButton(loadSchedule); + clockView = new SwingClockView(uiComponent); + } + + @Override + public Component getUiComponent() { + return uiComponent; } @Override - public Component getUiComponent() { - return new JLabel("Scheduler is here!"); + public ClockView getClockView() { + return clockView; } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client-swing/src/main/java/com/redhat/thermostat/tutorial/schedule/client/swing/impl/clock/ClockPanel.java Thu Feb 07 18:33:27 2013 +0100 @@ -0,0 +1,137 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * <http://www.gnu.org/licenses/>. + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.tutorial.schedule.client.swing.impl.clock; + +import com.redhat.thermostat.client.swing.GraphicsUtils; +import com.redhat.thermostat.client.ui.Palette; +import com.redhat.thermostat.tutorial.schedule.client.common.clock.ClockTime; +import com.redhat.thermostat.tutorial.schedule.client.swing.impl.ClockUtils; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.geom.Arc2D; +import java.awt.geom.Area; +import javax.swing.JPanel; + +/** + */ +@SuppressWarnings("serial") +public class ClockPanel extends JPanel { + + private ClockTime time; + + public ClockPanel(ClockTime time) { + this.time = time; + setBackground(ClockUtils.PANEL_BG); + } + + public ClockPanel() { + this(new ClockTime()); + } + + public void setTime(ClockTime time) { + this.time = time; + repaint(); + } + + public ClockTime getTime() { + return time; + } + + @Override + protected void paintComponent(Graphics g) { + Graphics2D graphics = GraphicsUtils.getInstance().createAAGraphics(g); + + graphics.setColor(ClockUtils.PANEL_BG); + + Rectangle rect = graphics.getClipBounds(); + graphics.fillRect(rect.x, rect.y, rect.width + 1, rect.height + 1); + + int size = rect.width; + if (rect.width > rect.height) { + size = rect.height; + } + + int radius = (size - 60)/2; + int innerRadius = (radius / 3); + + int x = (getWidth() / 2); + int y = (getHeight() / 2); + + graphics.setColor(Palette. LIGHT_GRAY.getColor()); + drawArc(graphics, x, y, radius, innerRadius * 2, time.getSecond(), false); + + radius = radius - innerRadius - 4; + innerRadius = innerRadius - 4; + + graphics.setColor(ClockUtils.PANEL_FG); + drawArc(graphics, x, y, radius, innerRadius, time.getMinute(), false); + + radius = radius - innerRadius - 8; + + graphics.setColor(Palette.EARL_GRAY.getColor()); + drawArc(graphics, x, y, radius, innerRadius, time.getHour(), true); + + graphics.dispose(); + } + + private void drawArc(Graphics2D graphics, int x, int y, int radius, int innerRadius, int mark, boolean hour) { + + int length = 0; + if (!hour) { + length = (mark * 6); + } else { + length = (mark * 30); + } + + int startAngle = 90 - length; + int endAngle = length; + + Arc2D.Float circle = new Arc2D.Float(x - radius, y - radius, radius * 2, radius * 2, startAngle, endAngle, Arc2D.PIE); + + Area area = new Area(circle); + if (!hour) { + Arc2D.Float inside = new Arc2D.Float(x - innerRadius, y - innerRadius, + innerRadius * 2, + innerRadius * 2, + startAngle, endAngle, Arc2D.PIE); + area.subtract(new Area(inside)); + } + + graphics.fill(area); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client-swing/src/main/java/com/redhat/thermostat/tutorial/schedule/client/swing/impl/scheduler/BulletIcon.java Thu Feb 07 18:33:27 2013 +0100 @@ -0,0 +1,65 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * <http://www.gnu.org/licenses/>. + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.tutorial.schedule.client.swing.impl.scheduler; + +import com.redhat.thermostat.client.swing.GraphicsUtils; +import com.redhat.thermostat.client.swing.components.EmptyIcon; +import com.redhat.thermostat.tutorial.schedule.client.swing.impl.ClockUtils; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Graphics2D; + +/** + * Implements an Icon with a bullet point. + */ +@SuppressWarnings("serial") +public class BulletIcon extends EmptyIcon { + + public BulletIcon() { + super(16, 16); + } + + @Override + public synchronized void paintIcon(Component c, Graphics g, int x, int y) { + Graphics2D graphics = GraphicsUtils.getInstance().createAAGraphics(g); + + graphics.setColor(ClockUtils.PANEL_FG); + graphics.fillOval(x + 5, y + 5, getIconWidth() - 10, getIconHeight() - 10); + + graphics.dispose(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client-swing/src/main/java/com/redhat/thermostat/tutorial/schedule/client/swing/impl/scheduler/CurrentPresentationPanel.java Thu Feb 07 18:33:27 2013 +0100 @@ -0,0 +1,72 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * <http://www.gnu.org/licenses/>. + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.tutorial.schedule.client.swing.impl.scheduler; + +import com.redhat.thermostat.tutorial.schedule.client.swing.impl.ClockUtils; +import java.awt.BorderLayout; +import java.awt.Dimension; +import javax.swing.Box; +import javax.swing.JPanel; + +/** + * Simple panel holding information about the current presentation and the + * speaker. + */ +@SuppressWarnings("serial") +public class CurrentPresentationPanel extends JPanel { + + private PresentationInfoPanel info; + + public CurrentPresentationPanel() { + setLayout(new BorderLayout()); + + setBackground(ClockUtils.PANEL_BG); + + info = new PresentationInfoPanel(); + info.setTitle("Thermostat: The road from 0.1 to 1.0, a success story (in progress)"); + + info.addSpeaker("Mario Torre"); + info.addSpeaker("Roman Kennke"); + + add(Box.createRigidArea(new Dimension(0, 100)), BorderLayout.NORTH); + add(Box.createRigidArea(new Dimension(50, 50)), BorderLayout.WEST); + add(Box.createRigidArea(new Dimension(50, 50)), BorderLayout.EAST); + add(Box.createRigidArea(new Dimension(0, 100)), BorderLayout.SOUTH); + + add(info, BorderLayout.CENTER); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client-swing/src/main/java/com/redhat/thermostat/tutorial/schedule/client/swing/impl/scheduler/PresentationBorder.java Thu Feb 07 18:33:27 2013 +0100 @@ -0,0 +1,118 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * <http://www.gnu.org/licenses/>. + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.tutorial.schedule.client.swing.impl.scheduler; + +import com.redhat.thermostat.client.swing.GraphicsUtils; +import com.redhat.thermostat.client.swing.components.DebugBorder; +import com.redhat.thermostat.client.ui.Palette; +import com.redhat.thermostat.tutorial.schedule.client.swing.impl.ClockUtils; +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.LinearGradientPaint; +import java.awt.geom.Point2D; + +/** + * Simple border, just to introduce the ${@link DebugBorder} class. + */ +public class PresentationBorder extends DebugBorder { + + public enum Border { + NORTH, + SOUTH, + EST, + WEST, + } + + private Border border; + + public PresentationBorder(Border border) { + this.border = border; + } + + @Override + public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { + if (ClockUtils.DEBUG) { + super.paintBorder(c, g, x, y, width, height); + } else { + + Graphics2D graphics = GraphicsUtils.getInstance().createAAGraphics(g); + + switch (border) { + case EST: + drawBorder(graphics, x + width - 1, y, x + width - 1, y + height); + break; + + case WEST: + drawBorder(graphics, x, y, x, y + height); + break; + + case NORTH: + drawBorder(graphics, x, y, x + width - 1, y); + break; + + case SOUTH: + drawBorder(graphics, x, y + height - 1, x + width - 1, y + height - 1); + break; + + default: + break; + } + + graphics.dispose(); + } + } + + private void drawBorder(Graphics2D graphics, int x, int y, int w, int h) { + LinearGradientPaint paint = + new LinearGradientPaint(new Point2D.Float(0, 0), + new Point2D.Float(w, h), + new float[] { 0.0f, .050f, .499f, .5f, .950f, 1.0f }, + new Color[] { + ClockUtils.PANEL_BG, + ClockUtils.PANEL_BG, + ClockUtils.PANEL_FG, + ClockUtils.PANEL_FG, + ClockUtils.PANEL_BG, + ClockUtils.PANEL_BG + }); + + graphics.setPaint(paint); + graphics.drawLine(x, y, w, h); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client-swing/src/main/java/com/redhat/thermostat/tutorial/schedule/client/swing/impl/scheduler/PresentationInfoPanel.java Thu Feb 07 18:33:27 2013 +0100 @@ -0,0 +1,129 @@ +/* + * Copyright 2012, 2013 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * <http://www.gnu.org/licenses/>. + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.tutorial.schedule.client.swing.impl.scheduler; + +import com.lowagie.text.Font; +import com.redhat.thermostat.client.swing.components.DebugBorder; +import com.redhat.thermostat.tutorial.schedule.client.common.locale.LocaleResources; +import com.redhat.thermostat.tutorial.schedule.client.swing.impl.ClockUtils; +import java.awt.Component; +import java.awt.Dimension; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.SwingConstants; + + +/** + */ +@SuppressWarnings("serial") +public class PresentationInfoPanel extends JPanel { + + private JTextArea title; + private JLabel titleCaption; + private JLabel speakersCaption; + + private JPanel presentationPanel; + + public PresentationInfoPanel() { + setBackground(ClockUtils.PANEL_BG); + + setPreferredSize(new Dimension(450, 300)); + + setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + + titleCaption = new JLabel(ClockUtils.localize(LocaleResources.PRESENTATION_TITLE)); + titleCaption.setForeground(ClockUtils.PANEL_FG); + titleCaption.setBackground(ClockUtils.PANEL_BG); + titleCaption.setHorizontalTextPosition(SwingConstants.LEFT); + titleCaption.setAlignmentX(Component.LEFT_ALIGNMENT); + titleCaption.setFont(titleCaption.getFont().deriveFont(Font.BOLD)); + + title = new JTextArea(""); + title.setEditable(false); + title.setLineWrap(true); + title.setWrapStyleWord(true); + title.setAlignmentX(Component.LEFT_ALIGNMENT); + + title.setForeground(ClockUtils.PANEL_FG); + title.setBackground(ClockUtils.PANEL_BG); + title.setBorder(null); + title.setMaximumSize(new Dimension(450, 20)); + + speakersCaption = new JLabel(ClockUtils.localize(LocaleResources.SPEAKERS)); + speakersCaption.setForeground(ClockUtils.PANEL_FG); + speakersCaption.setBackground(ClockUtils.PANEL_BG); + speakersCaption.setHorizontalTextPosition(SwingConstants.LEFT); + speakersCaption.setAlignmentX(Component.LEFT_ALIGNMENT); + speakersCaption.setFont(speakersCaption.getFont().deriveFont(Font.BOLD)); + + presentationPanel = new JPanel(); + presentationPanel.setBackground(ClockUtils.PANEL_BG); + presentationPanel.setLayout(new BoxLayout(presentationPanel, BoxLayout.Y_AXIS)); + + presentationPanel.add(titleCaption); + presentationPanel.add(Box.createRigidArea(new Dimension(0, 5))); + presentationPanel.add(title); + presentationPanel.add(Box.createRigidArea(new Dimension(0, 20))); + presentationPanel.add(speakersCaption); + presentationPanel.add(Box.createRigidArea(new Dimension(0, 5))); + add(presentationPanel); + } + + public String getTitle() { + return title.getText(); + } + + public void setTitle(String title) { + this.title.setText(title); + + repaint(); + } + + public void addSpeaker(String speaker) { + JLabel speakerLabel = new JLabel(speaker); + speakerLabel.setForeground(ClockUtils.PANEL_FG); + speakerLabel.setAlignmentX(Component.LEFT_ALIGNMENT); + speakerLabel.setFont(speakerLabel.getFont().deriveFont(Font.NORMAL)); + + speakerLabel.setIcon(new BulletIcon()); + presentationPanel.add(speakerLabel); + repaint(); + } +}
--- a/copy_jars.sh Sat Jan 26 01:23:23 2013 +0100 +++ b/copy_jars.sh Thu Feb 07 18:33:27 2013 +0100 @@ -1,6 +1,6 @@ #/bin/sh if [ x"$THERMOSTAT_DEV_HOME" = x ] ; then - echo "variable THERMOSTAT_DEV_HOME is not set, should point to the thermostat distribution/target directory" + echo "variable THERMOSTAT_DEV_HOME is not set, should point to the thermostat src directory" exit -1 fi