GROUP_TIMELINES_R0: GROUP_TIMELINES_R0-collective.patch
File GROUP_TIMELINES_R0-collective.patch, 20.0 KB (added by boyan, 16 years ago) |
---|
-
pom.xml
251 251 <module>modules/org.sophie2.main.func.links</module> 252 252 <module>modules/org.sophie2.main.func.image</module> 253 253 <module>modules/org.sophie2.main.func.resources</module> 254 <module>modules/org.sophie2.main.skin.alternative</module> 254 <module>modules/org.sophie2.main.skin.alternative</module> 255 <module>modules/org.sophie2.main.func.timelines</module> 255 256 </modules> 256 257 <repositories> 257 258 <repository> -
modules/org.sophie2.base.model.book/src/main/java/org/sophie2/base/model/book/timelines/Channel.java
1 package org.sophie2.base.model.book.timelines; 2 3 import org.sophie2.core.prolib.impl.BaseProObject; 4 import org.sophie2.core.prolib.interfaces.ListProp; 5 6 /** 7 * Represents a timeline channel. 8 * 9 * @author boyan 10 */ 11 public class Channel extends BaseProObject { 12 13 /** 14 * The channel entries. 15 * 16 * @return A list property, holding the entries. 17 */ 18 public ListProp<TimelineEntry> entries() { 19 // TODO Auto-generated method stub 20 return null; 21 } 22 23 /** 24 * Adds an entry to the channel. 25 * 26 * @param timelineEntry 27 * the entry to be added. 28 */ 29 public void addEntry(TimelineEntry timelineEntry) { 30 // TODO Auto-generated method stub 31 32 } 33 34 /** 35 * Removes an entry from the channel. 36 * 37 * @param timelineEntry 38 * the entry to be removed 39 */ 40 public void removeEntry(TimelineEntry timelineEntry) { 41 // TODO Auto-generated method stub 42 43 } 44 } -
modules/org.sophie2.base.model.book/src/main/java/org/sophie2/base/model/book/timelines/Timeline.java
1 package org.sophie2.base.model.book.timelines; 2 3 import org.sophie2.base.model.book.Page; 4 import org.sophie2.core.prolib.impl.BaseProObject; 5 import org.sophie2.core.prolib.interfaces.ListProp; 6 import org.sophie2.core.prolib.interfaces.Prop; 7 8 /** 9 * Represents a Sophie2 timeline. 10 * 11 * @author boyan 12 */ 13 public class Timeline extends BaseProObject { 14 15 /** 16 * Constructs a timeline for a given page with a default duration. 17 * 18 * @param page 19 * the page this timeline corresponds to. 20 */ 21 public Timeline(Page page) { 22 // nothing for now 23 } 24 25 /** 26 * Constructs a timeline for a given page with a given length. 27 * 28 * @param page 29 * the page this timeline corresponds to. 30 * @param duration 31 * the length of the timeline in seconds 32 */ 33 public Timeline(Page page, int duration) { 34 // nothing for now 35 } 36 37 /** 38 * The channels of this timeline. Each channel corresponds to a group of 39 * elements on the page. 40 * 41 * @return the list property 42 */ 43 public ListProp<Channel> channels() { 44 // TODO Auto-generated method stub 45 return null; 46 } 47 48 /** 49 * Moves the head position to a specified time in the timeline. If it 50 * exceeds the length of the timeline, the position is not changed. 51 * 52 * @param time 53 * the time to jump to (in seconds). 54 * @return the new head position. 55 */ 56 public int jumpTo(int time) { 57 // TODO Auto-generated method stub 58 return 0; 59 } 60 61 /** 62 * The position of the timeline head in seconds. 63 * 64 * @return a property holding the head position 65 */ 66 public Prop<Integer> headPosition() { 67 // TODO Auto-generated method stub 68 return null; 69 } 70 71 /** 72 * Indicates whether the timeline is currently playing. 73 * 74 * @return a property, holding a boolean value. 75 */ 76 public Prop<Boolean> playing() { 77 // TODO Auto-generated method stub 78 return null; 79 } 80 81 /** 82 * Plays the timeline. 83 */ 84 public void play() { 85 // TODO Auto-generated method stub 86 87 } 88 89 /** 90 * Pauses the timeline and keeps the head position to resume playing. 91 */ 92 public void pause() { 93 // TODO Auto-generated method stub 94 95 } 96 97 /** 98 * Stops the timeline and resets its head position. 99 */ 100 public void stop() { 101 // TODO Auto-generated method stub 102 103 } 104 } -
modules/org.sophie2.base.model.book/src/main/java/org/sophie2/base/model/book/timelines/TimelineEntry.java
1 package org.sophie2.base.model.book.timelines; 2 3 import org.sophie2.base.model.book.PageElement; 4 import org.sophie2.core.prolib.impl.BaseProObject; 5 6 /** 7 * Represents a timeline entry. 8 * 9 * @author boyan 10 */ 11 public class TimelineEntry extends BaseProObject { 12 13 /** 14 * Constructs a timeline entry by a given element (or group of elements) on 15 * the page. 16 * 17 * @param element 18 */ 19 public TimelineEntry(PageElement element) { 20 // TODO Auto-generated constructor stub 21 } 22 } -
modules/org.sophie2.base.model.book/src/test/java/org/sophie2/base/model/book/timelines/TimelineUnitTest.java
1 package org.sophie2.base.model.book.timelines; 2 3 import org.junit.After; 4 import org.junit.Before; 5 import org.junit.Test; 6 import org.sophie2.base.model.book.Book; 7 import org.sophie2.base.model.book.Page; 8 import org.sophie2.base.model.resources.ResourceSpace; 9 import org.sophie2.core.testing.UnitTestBase; 10 11 /** 12 * A unit test for the {@link Timeline}s class. Ensures timeline navigation is 13 * working correctly (playing, pausing, jumping). 14 * 15 * @author boyan 16 */ 17 public class TimelineUnitTest extends UnitTestBase { 18 19 /** 20 * A reference to a page that is needed in the {@link Timeline} constructor. 21 */ 22 public Page page; 23 24 @Before 25 @Override 26 public void setUp() throws Exception { 27 super.setUp(); 28 Book book = Book.createDefaultBook().get(Book.class); 29 Page p = ResourceSpace.createResource("New Page", Page.class, book); 30 this.page = p; 31 } 32 33 @After 34 @Override 35 public void tearDown() throws Exception { 36 this.page.delete(); 37 super.tearDown(); 38 } 39 40 /** 41 * Tests whether playing/pausing the timeline works. This should affect the 42 * playing() property of the {@link Timeline}. 43 */ 44 @Test 45 public void testPlayPause() { 46 Timeline t = new Timeline(this.page); 47 assertFalse(t.playing().get()); 48 t.play(); 49 assertTrue(t.playing().get()); 50 t.pause(); 51 assertFalse(t.playing().get()); 52 } 53 54 /** 55 * Tests whether a user is able to jump to a location within the timeline. 56 * If the time specified exceeds the timeline length, that should not be 57 * possible. 58 */ 59 @Test 60 public void testJumpTo() { 61 Timeline t = new Timeline(this.page, 30); 62 63 assertFalse(t.playing().get()); 64 assertEquals(t.headPosition().get().intValue(), t.jumpTo(45)); 65 66 t.jumpTo(15); 67 assertEquals(15, t.headPosition().get().intValue()); 68 } 69 } -
modules/org.sophie2.base.model.book/src/test/java/org/sophie2/base/model/book/timelines/TimelinesIntegrationTest.java
1 package org.sophie2.base.model.book.timelines; 2 3 import org.junit.After; 4 import org.junit.Before; 5 import org.junit.Test; 6 import org.sophie2.base.model.book.Book; 7 import org.sophie2.base.model.book.Frame; 8 import org.sophie2.base.model.book.Page; 9 import org.sophie2.base.model.resources.ResourceSpace; 10 import org.sophie2.core.testing.IntegrationTestBase; 11 12 /** 13 * An integration test for timelines, channels and entries. Ensures they are 14 * corresponding to the page structure. 15 * 16 * @author boyan 17 */ 18 public class TimelinesIntegrationTest extends IntegrationTestBase { 19 20 /** 21 * A reference to a page that is needed in the {@link Timeline} constructor. 22 */ 23 public Page page; 24 25 @Before 26 @Override 27 public void setUp() throws Exception { 28 super.setUp(); 29 Book book = Book.createDefaultBook().get(Book.class); 30 Page p = ResourceSpace.createResource("New Page", Page.class, book); 31 this.page = p; 32 } 33 34 @After 35 @Override 36 public void tearDown() throws Exception { 37 this.page.delete(); 38 super.tearDown(); 39 } 40 41 /** 42 * Tests that channels are automatically created and removed according to 43 * the groups of elements on the page. 44 */ 45 @Test 46 public void testChannels() { 47 Timeline t = new Timeline(this.page); 48 assertEquals(0, t.channels().size()); 49 50 this.page.addNewFrame("newFrame"); 51 assertEquals(1, t.channels().size()); 52 53 this.page.frames().get().clear(); 54 assertEquals(0, t.channels().size()); 55 } 56 57 /** 58 * Tests timeline entries are added/removed corerctly. An entry holding a 59 * different element from the one the channel holds should not be added to 60 * that channel. 61 */ 62 @Test 63 public void testAddRemoveEntries() { 64 Timeline t = new Timeline(this.page); 65 Frame f = this.page.addNewFrame("newFrame"); 66 assertEquals(1, t.channels().size()); 67 Channel ch = t.channels().get(1); 68 69 assertEquals(1, ch.entries().size()); 70 ch.addEntry(new TimelineEntry(f)); 71 assertEquals(2, ch.entries().size()); 72 ch.addEntry(new TimelineEntry(this.page.addNewFrame("Another Frame"))); 73 assertEquals(2, ch.entries().size()); 74 ch.removeEntry(ch.entries().get(0)); 75 assertEquals(1, ch.entries().size()); 76 } 77 } -
modules/org.sophie2.main.func.timelines/pom.xml
10 10 <relativePath>../../pom.xml</relativePath> 11 11 </parent> 12 12 <groupId>org.sophie2</groupId> 13 <artifactId>org.sophie2. proto.project</artifactId>13 <artifactId>org.sophie2.main.func.timelines</artifactId> 14 14 <version>2.0-SNAPSHOT</version> 15 <name>Sophie 2 ProtoProject Component</name>15 <name>Sophie 2 Timelines Manipulation Support</name> 16 16 <packaging>bundle</packaging> 17 <description> Copy from this one to create a sophie2 module</description>17 <description>Provides a UI and interactions for timeline manipulation.</description> 18 18 <dependencies> 19 <dependency> 20 <groupId>log4j</groupId> 21 <artifactId>log4j</artifactId> 22 <version>1.2.14</version> 23 <type>jar</type> 24 <exclusions> 25 <exclusion> 26 <groupId>com.sun.jdmk</groupId> 27 <artifactId>jmxtools</artifactId> 28 </exclusion> 29 <exclusion> 30 <groupId>com.sun.jmx</groupId> 31 <artifactId>jmxri</artifactId> 32 </exclusion> 33 </exclusions> 34 </dependency> 35 <dependency> 36 <groupId>junit</groupId> 37 <artifactId>junit</artifactId> 38 <version>4.4</version> 39 <type>jar</type> 40 <scope>test</scope> 41 </dependency> 19 <dependency> 20 <groupId>org.sophie2</groupId> 21 <artifactId>org.sophie2.core.modularity</artifactId> 22 <version>2.0-SNAPSHOT</version> 23 </dependency> 24 <dependency> 25 <groupId>org.sophie2</groupId> 26 <artifactId>org.sophie2.base.visual</artifactId> 27 <version>2.0-SNAPSHOT</version> 28 </dependency> 29 <dependency> 30 <groupId>org.sophie2</groupId> 31 <artifactId>org.sophie2.base.layout</artifactId> 32 <version>2.0-SNAPSHOT</version> 33 </dependency> 34 <dependency> 35 <groupId>org.sophie2</groupId> 36 <artifactId>org.sophie2.base.model.book</artifactId> 37 <version>2.0-SNAPSHOT</version> 38 </dependency> 39 <dependency> 40 <groupId>org.sophie2</groupId> 41 <artifactId>org.sophie2.main.app.commons</artifactId> 42 <version>2.0-SNAPSHOT</version> 43 </dependency> 44 <dependency> 45 <groupId>org.sophie2</groupId> 46 <artifactId>org.sophie2.main.func.links</artifactId> 47 <version>2.0-SNAPSHOT</version> 48 </dependency> 42 49 </dependencies> 43 50 <build> 44 51 <plugins> … … 49 56 <extensions>true</extensions> 50 57 <configuration> 51 58 <instructions> 52 <!-- 53 Uncomment next line and set appropriate main class of the bundle 54 if it is runnable Normally only App module should be runnable 55 --> 56 <!-- <Main-Class>org.sophie2.proto.project.ProtoModule</Main-Class> --> 57 <!-- 58 Uncomment next line and change to the class extending SopheModule 59 if such is available 60 --> 61 <!-- 62 <Bundle-Activator>org.sophie2.proto.project.ProtoModule</Bundle-Activator> 63 --> 64 <Export-Package>org.sophie2.proto.project.*</Export-Package> 65 <!-- 66 <Private-Package>org.apache.felix.moduleloader.*,org.apache.felix.framework.*,org.apache.felix.main,org.osgi.*,org.apache.log4j.*</Private-Package> 67 --> 59 <Bundle-Activator>org.sophie2.main.func.timelines.MainFuncTimelinesModule</Bundle-Activator> 60 <Export-Package>org.sophie2.main.func.timelines.*</Export-Package> 68 61 <Embed-Dependency>*;scope=compile|runtime;groupId=!org.sophie2|org.osgi|log4j</Embed-Dependency> 69 62 <Import-Package>*;resolution:=optional</Import-Package> 70 63 </instructions> -
modules/org.sophie2.main.func.timelines/src/main/java/org/sophie2/main/func/timelines/MainFuncTimelinesModule.java
1 package org.sophie2.main.func.timelines; 2 3 import java.util.List; 4 5 import org.sophie2.base.visual.AutoVisualProvider; 6 import org.sophie2.core.modularity.SophieExtension; 7 import org.sophie2.core.modularity.SophieExtensionPoint; 8 import org.sophie2.core.modularity.SophieModule; 9 10 /** 11 * Module class for timeline UI and interactions functionalities. 12 * 13 * @author boyan 14 */ 15 public class MainFuncTimelinesModule extends SophieModule { 16 17 @Override 18 protected void defineExtensionPoints(List<SophieExtensionPoint<?>> res) { 19 // TODO Auto-generated method stub 20 } 21 22 @Override 23 protected void defineExtensions(List<SophieExtension<?>> res) { 24 AutoVisualProvider.fillExtensions(res, TimelinesTab.class); 25 AutoVisualProvider.fillExtensions(res, TimelinesPalette.class); 26 } 27 } -
modules/org.sophie2.main.func.timelines/src/main/java/org/sophie2/main/func/timelines/TimelinesPalette.java
1 package org.sophie2.main.func.timelines; 2 3 import javax.swing.JTable; 4 5 import org.sophie2.base.layout.model.TablePalette; 6 import org.sophie2.core.prolib.interfaces.Prop; 7 8 /** 9 * The palette displaying the current timeline. By default in the bottom flap. 10 * 11 * @author boyan 12 */ 13 public class TimelinesPalette extends TablePalette { 14 15 @Override 16 public Prop<JTable> table() { 17 // nothing for now 18 return null; 19 } 20 } -
modules/org.sophie2.main.func.timelines/src/main/java/org/sophie2/main/func/timelines/TimelinesTab.java
1 package org.sophie2.main.func.timelines; 2 3 import org.sophie2.base.layout.model.Tab; 4 5 /** 6 * The Timelines tab. 7 * 8 * @author boyan 9 */ 10 public class TimelinesTab extends Tab { 11 // nothing for now 12 } -
modules/org.sophie2.main.func.timelines/src/test/java/org/sophie2/main/func/timelines/TimelinesUITest.java
1 package org.sophie2.main.func.timelines; 2 3 import org.junit.After; 4 import org.junit.Before; 5 import org.junit.Test; 6 import org.sophie2.base.model.book.Book; 7 import org.sophie2.base.model.book.Page; 8 import org.sophie2.base.model.book.timelines.Timeline; 9 import org.sophie2.base.model.resources.ResourceSpace; 10 import org.sophie2.base.visual.BaseVisualElement; 11 import org.sophie2.base.visual.BaseVisualModule; 12 import org.sophie2.core.modularity.FakeModuleRegistry; 13 import org.sophie2.core.testing.IntegrationTestBase; 14 15 /** 16 * Tests the user interface and interactivity provided for timelines. 17 * 18 * @author boyan 19 */ 20 public class TimelinesUITest extends IntegrationTestBase { 21 22 /** 23 * A reference to a page that is needed in the {@link Timeline} constructor. 24 */ 25 public Page page; 26 27 /** 28 * A reference to the {@link TimelinesPalette}. 29 */ 30 public TimelinesPalette palette; 31 32 @Before 33 @SuppressWarnings("unchecked") 34 @Override 35 public void setUp() throws Exception { 36 super.setUp(); 37 Book book = Book.createDefaultBook().get(Book.class); 38 Page p = ResourceSpace.createResource("New Page", Page.class, book); 39 this.page = p; 40 41 FakeModuleRegistry.start(BaseVisualModule.class, 42 MainFuncTimelinesModule.class); 43 44 DummyElement dummy = new DummyElement(); 45 TimelinesPalette tp = dummy.findNearestElement(null, 46 TimelinesPalette.class); 47 this.palette = tp; 48 } 49 50 @After 51 @Override 52 public void tearDown() throws Exception { 53 this.page.delete(); 54 FakeModuleRegistry.stop(); 55 super.tearDown(); 56 } 57 58 /** 59 * A dummy class for testing purposes. 60 * 61 * @author boyan 62 */ 63 public static class DummyElement extends BaseVisualElement { 64 // nothing for now 65 } 66 67 /** 68 * Tests whether each channel is displayed in the table of the palette. This 69 * test should be significantly changed on every UI change. 70 */ 71 @Test 72 public void testChannelsDisplay() { 73 Timeline t = new Timeline(this.page); 74 assertEquals(t.channels().size(), this.palette.table().get() 75 .getRowCount()); 76 this.page.addNewFrame("New Frame"); 77 assertEquals(t.channels().size(), this.palette.table().get() 78 .getRowCount()); 79 this.page.frames().get().clear(); 80 assertEquals(0, this.palette.table().get().getRowCount()); 81 } 82 83 /** 84 * Tests that entries startTime and length are correctly changed when 85 * checkboxes in the UI are clicked. 86 */ 87 @Test 88 public void testEntries() { 89 // Checks that length corresponds to the default length of the timeline 90 // (all checkboxes are checked). 91 // Unchecks some of the checkboxes (changes the duration of the entry) 92 // and ensures changes are propagated. 93 } 94 95 /** 96 * Test navigation through the user interface (play/pause). 97 */ 98 @Test 99 public void testNavigation() { 100 // Checks that clicking on play/pause button or loop button 101 // actually changes the state of the timeline. 102 } 103 }