Jtimer-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
November 2009
- 2 participants
- 24 discussions
Author: echatellier
Date: 2009-11-16 10:22:22 +0100 (Mon, 16 Nov 2009)
New Revision: 2695
Modified:
trunk/pom.xml
Log:
Remove useless dep
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-11-16 09:21:54 UTC (rev 2694)
+++ trunk/pom.xml 2009-11-16 09:22:22 UTC (rev 2695)
@@ -227,7 +227,7 @@
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
- <version>2.1.2</version>
+ <version>2.1.2</version>
<configuration>
<developerConnection>${project.scm.connection}</developerConnection>
</configuration>
@@ -330,6 +330,10 @@
<groupId>org.swinglabs</groupId>
<artifactId>swing-worker</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>com.jhlabs</groupId>
+ <artifactId>filters</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
@@ -481,9 +485,5 @@
<id>nuiton.release</id>
<url>http://maven.nuiton.org/release</url>
</pluginRepository>
- <!-- <pluginRepository>
- <id>apache.snapshot</id>
- <url>http://repository.apache.org/snapshots</url>
- </pluginRepository> -->
</pluginRepositories>
</project>
1
0
r2694 - in trunk/src/main: java/org/chorem/jtimer/ui/tasks resources/org/chorem/jtimer/ui/tasks/resources
by echatellier@users.chorem.org 16 Nov '09
by echatellier@users.chorem.org 16 Nov '09
16 Nov '09
Author: echatellier
Date: 2009-11-16 10:21:54 +0100 (Mon, 16 Nov 2009)
New Revision: 2694
Added:
trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/appointment-new.png
Removed:
trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/alert.png
Modified:
trunk/src/main/java/org/chorem/jtimer/ui/tasks/IdleDialog.java
trunk/src/main/java/org/chorem/jtimer/ui/tasks/RunTaskJob.java
trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/IdleDialog.properties
trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/IdleDialog_fr.properties
Log:
Affichage de la dur?\195?\169e d'inactivit?\195?\169
Modified: trunk/src/main/java/org/chorem/jtimer/ui/tasks/IdleDialog.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/tasks/IdleDialog.java 2009-11-16 09:19:51 UTC (rev 2693)
+++ trunk/src/main/java/org/chorem/jtimer/ui/tasks/IdleDialog.java 2009-11-16 09:21:54 UTC (rev 2694)
@@ -22,15 +22,18 @@
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
+import java.util.Timer;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
-import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSeparator;
+import javax.swing.SwingConstants;
+import javax.swing.WindowConstants;
+import org.apache.commons.lang.time.DurationFormatUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.jtimer.JTimerFactory;
@@ -41,7 +44,7 @@
import org.jdesktop.application.SingleFrameApplication;
/**
- * Idle dialog showed to user when idle has been detected.
+ * Modal idle dialog showed to user when idle has been detected.
*
* Composed of an unique blocking show method.
*
@@ -66,23 +69,42 @@
/** log */
private static Log log = LogFactory.getLog(IdleDialog.class);
+ /** Mutex object (multiples running tasks are waiting on it) */
+ protected static Object mutex = new Object();
+
+ /** Singleton dialog instance. */
+ protected static IdleDialog idleDialog;
+
+ /** Resume option. */
+ protected static int lastResumeOption;
+
+ /** Parent application. */
protected SingleFrameApplication application;
+ /** I18N resource map. */
protected ResourceMap resourceMap;
-
- protected static IdleDialog mutex;
- protected static int lastResumeOption;
+ /** Timer (for idle duration scheduling). */
+ protected Timer timer;
+ /** Current Idle duration refresh task. */
+ protected UpdateIdleTime updateIdleTime;
+
+ /** Timestamp when idle starts. */
+ protected long idleStartTimestamp;
+
+ /** Duration label. */
protected JLabel idleDurationLabel;
- /** Option after idle detect */
+ /** Revert option after idle detect. */
public static final int REVERT = 0;
- /** Option after idle detect */
+
+ /** Continue option after idle detect. */
public static final int CONTINUE = 1;
- /** Option after idle detect */
+
+ /** Resume option after idle detect. */
public static final int RESUME = 2;
-
+
/**
* IdleDialog constructor.
*
@@ -91,23 +113,28 @@
* @param parent parent application
*/
protected IdleDialog(SingleFrameApplication application) {
- super(application.getMainFrame());
-
+ // don't make reference on other parent
+ // windows, cause idle to unlock some task
+ // if parent window is hidden by systray
+ super();
+
// init resources map
this.application = application;
ApplicationContext ctxt = application.getContext();
ResourceManager mgr = ctxt.getResourceManager();
resourceMap = mgr.getResourceMap(IdleDialog.class);
-
- //setName("idleFrame");
+
+ setName("idleFrame");
setTitle(resourceMap.getString("idleTitle"));
setResizable(false);
-
- // TODO : must be modal , but break mecanism
- //setModal(true);
-
- getRootPane().setLayout(new BorderLayout(1,1));
+ setModal(true);
+ setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
+
+ getRootPane().setLayout(new BorderLayout(1, 1));
getRootPane().add(getMainComponent(), BorderLayout.CENTER);
+
+ // timer
+ timer = new Timer();
}
/**
@@ -121,103 +148,117 @@
// label
JLabel idleIcon = new JLabel(resourceMap.getIcon("idleIcon"));
mainComponent.add(idleIcon, new GridBagConstraints(0, 0, 1, 5, 0, 1,
- GridBagConstraints.NORTH, GridBagConstraints.NONE,
- new Insets(10, 10, 10, 10), 0, 0));
-
+ GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(
+ 10, 5, 10, 10), 0, 0));
+
// label
- JLabel idleLabel = new JLabel(resourceMap.getString("idleMessage",
- Long.valueOf(JTimerFactory.getIdleTime() / (60 * 1000))));
+ JLabel idleLabel = new JLabel(resourceMap.getString("idleMessage", Long
+ .valueOf(JTimerFactory.getIdleTime() / (60 * 1000))));
mainComponent.add(idleLabel, new GridBagConstraints(1, 0, 3, 1, 1, 0,
GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(5, 0, 0, 3), 0, 0));
idleDurationLabel = new JLabel(" ");
- mainComponent.add(idleDurationLabel, new GridBagConstraints(1, 1, 3, 1, 1, 0,
- GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
- new Insets(5, 0, 5, 5), 0, 0));
-
+ mainComponent.add(idleDurationLabel, new GridBagConstraints(1, 1, 3, 1,
+ 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
+ new Insets(5, 0, 3, 5), 0, 0));
+
// separator
- mainComponent.add(new JSeparator(), new GridBagConstraints(1, 2, 3, 1, 1, 0,
- GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
+ mainComponent.add(new JSeparator(), new GridBagConstraints(1, 2, 3, 1,
+ 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(0, 0, 0, 5), 0, 0));
-
+
// label
JLabel idleRestart = new JLabel(resourceMap.getString("idleRestart"));
mainComponent.add(idleRestart, new GridBagConstraints(1, 3, 3, 1, 1, 0,
GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
- new Insets(5, 0, 0, 3), 0, 0));
-
+ new Insets(3, 0, 0, 5), 0, 0));
+
JButton revertButton = new JButton();
- revertButton.setHorizontalAlignment(JLabel.LEFT);
- revertButton.setAction(application.getContext().getActionMap(this).get("chooseRevertOption"));
- mainComponent.add(revertButton, new GridBagConstraints(1, 4, 1, 1, 1, 0,
- GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
- new Insets(5, 0, 5, 5), 0, 0));
+ revertButton.setHorizontalAlignment(SwingConstants.LEFT);
+ revertButton.setAction(application.getContext().getActionMap(this).get(
+ "chooseRevertOption"));
+ mainComponent.add(revertButton, new GridBagConstraints(1, 4, 1, 1, 1,
+ 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
+ new Insets(3, 0, 5, 5), 0, 0));
JButton continueButton = new JButton();
- continueButton.setHorizontalAlignment(JLabel.LEFT);
- continueButton.setAction(application.getContext().getActionMap(this).get("chooseContinueOption"));
- mainComponent.add(continueButton, new GridBagConstraints(2, 4, 1, 1, 1, 0,
- GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
- new Insets(5, 0, 5, 5), 0, 0));
+ continueButton.setHorizontalAlignment(SwingConstants.LEFT);
+ continueButton.setAction(application.getContext().getActionMap(this)
+ .get("chooseContinueOption"));
+ mainComponent.add(continueButton, new GridBagConstraints(2, 4, 1, 1, 1,
+ 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
+ new Insets(3, 0, 5, 5), 0, 0));
JButton resumeButton = new JButton();
- resumeButton.setHorizontalAlignment(JLabel.LEFT);
- resumeButton.setAction(application.getContext().getActionMap(this).get("chooseResumeOption"));
- mainComponent.add(resumeButton, new GridBagConstraints(3, 4, 1, 1, 1, 0,
- GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
- new Insets(5, 0, 5, 5), 0, 0));
+ resumeButton.setHorizontalAlignment(SwingConstants.LEFT);
+ resumeButton.setAction(application.getContext().getActionMap(this).get(
+ "chooseResumeOption"));
+ mainComponent.add(resumeButton, new GridBagConstraints(3, 4, 1, 1, 1,
+ 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
+ new Insets(3, 0, 5, 5), 0, 0));
return mainComponent;
}
- public void run () {
- idleDurationLabel.setText(resourceMap.getString("idleDuration",
- Long.valueOf(JTimerFactory.getIdleTime() / (60 * 1000))));
- }
/**
- * Init dialog mutex instance.
+ * Init dialog idleDialog instance.
*
* @param parent parent reference
*/
public static void init(SingleFrameApplication parent) {
- mutex = new IdleDialog(parent);
+ idleDialog = new IdleDialog(parent);
}
+ /**
+ * Revert button action.
+ */
@Action
public void chooseRevertOption() {
lastResumeOption = REVERT;
idleEnded();
}
+ /**
+ * Continue button action.
+ */
@Action
public void chooseContinueOption() {
lastResumeOption = CONTINUE;
idleEnded();
}
-
+
+ /**
+ * Resume button action.
+ */
@Action
public void chooseResumeOption() {
lastResumeOption = RESUME;
idleEnded();
}
+ /**
+ * Unblock all waiting threads on {@link #mutex}.
+ */
protected void idleEnded() {
- synchronized(this) {
- notifyAll();
+ synchronized (mutex) {
+ mutex.notifyAll();
}
setVisible(false);
}
- protected synchronized void waitForIdleEnd() {
- try {
- wait();
- log.debug("Thread unwaiting");
- } catch (InterruptedException e) {
- if (log.isErrorEnabled()) {
- log.error("Thread inturrupted", e);
- }
+ @Override
+ public void setVisible(boolean b) {
+
+ if (b) {
+ updateIdleTime = new UpdateIdleTime();
+ timer.schedule(updateIdleTime, 0, 1000 * 60 /* every minutes */);
+ } else {
+ updateIdleTime.cancel();
+ timer.purge();
}
+
+ super.setVisible(b);
}
/**
@@ -226,19 +267,55 @@
* This function is thread safe and show only one dialog even if
* function is called multiples times.
*
- * @param lastActivityTimestamp
+ * @param idleStartTimestamp time stamp when idle start
* @return idle option
*/
- public static int showIdleDialog(long lastActivityTimestamp) {
- //synchronized(mutex) {
- if (!mutex.isVisible()) {
- mutex.application.show(mutex);
- mutex.run();
+ public static int showIdleDialog(long idleStartTimestamp) {
+
+ // only the first call must display dialog
+ // (can happen if multiples task are running)
+ boolean mustShow = false;
+ synchronized (idleDialog) {
+ mustShow = !idleDialog.isVisible();
+ }
+
+ // the first frame will be blocked by show modal
+ // blocking status...
+ if (mustShow) {
+ idleDialog.idleStartTimestamp = idleStartTimestamp;
+ idleDialog.application.show(idleDialog);
+ } else {
+ // ...the others by wait();
+ synchronized (mutex) {
+ try {
+ mutex.wait();
+ } catch (InterruptedException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Thread inturrupted", e);
+ }
+ }
}
- //}
+ }
- mutex.waitForIdleEnd();
-
return lastResumeOption;
}
+
+ /**
+ * Task to update idle time duration while dialog is showed.
+ */
+ protected class UpdateIdleTime extends java.util.TimerTask {
+
+ /*
+ * @see java.util.TimerTask#run()
+ */
+ @Override
+ public void run() {
+ if (log.isDebugEnabled()) {
+ log.debug("Update idle duration");
+ }
+ String duration = DurationFormatUtils.formatDuration(
+ System.currentTimeMillis() - idleStartTimestamp, "HH:mm");
+ idleDurationLabel.setText(resourceMap.getString("idleDuration", duration));
+ }
+ }
}
Modified: trunk/src/main/java/org/chorem/jtimer/ui/tasks/RunTaskJob.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/tasks/RunTaskJob.java 2009-11-16 09:19:51 UTC (rev 2693)
+++ trunk/src/main/java/org/chorem/jtimer/ui/tasks/RunTaskJob.java 2009-11-16 09:21:54 UTC (rev 2694)
@@ -104,7 +104,7 @@
TimerDataManager dataManager) {
super(parentApp);
this.parentApp = parentApp;
-
+
// init with False
bWantToStop = Boolean.FALSE;
@@ -140,10 +140,11 @@
Date now = new Date();
// check alert to be fired
for (TimerAlert alert : task.getAlerts()) {
- if (alert.getType().equals(Type.REACH_DAILY_TIME) && TimerTaskHelper.getTotalTime(task, now) > alert.getDuration()) {
+ if (alert.getType().equals(Type.REACH_DAILY_TIME)
+ && TimerTaskHelper.getTotalTime(task, now) > alert.getDuration()) {
alreadyTrownAlerts.add(alert.clone());
- }
- else if (alert.getType().equals(Type.REACH_TOTAL_TIME) && TimerTaskHelper.getAllTotalTime(task) > alert.getDuration()) {
+ } else if (alert.getType().equals(Type.REACH_TOTAL_TIME)
+ && TimerTaskHelper.getAllTotalTime(task) > alert.getDuration()) {
alreadyTrownAlerts.add(alert.clone());
}
}
@@ -153,7 +154,7 @@
if (task.getParent() != null) {
checkAlreadyThrownAlerts(task.getParent());
}
-
+
}
/**
@@ -282,17 +283,15 @@
// idle detected
// update time without idle time
offsetTimeInMs -= configIdleTime;
- publish(taskTimingBeforeStartInMs + loopTimestamp
- - taskStartCalendar.getTimeInMillis() + offsetTimeInMs);
+ publish(taskTimingBeforeStartInMs + loopTimestamp - taskStartCalendar.getTimeInMillis() + offsetTimeInMs);
// parent application
JTimer parentApplication = (JTimer)getApplication();
-
+
// send idle detect event
parentApplication.preIdleDetect();
// ask user what to do
- //int option = ((JTimer) getApplication()).askIdleOption();
- int option = IdleDialog.showIdleDialog(lastPublishTimestamp);
+ int option = IdleDialog.showIdleDialog(loopTimestamp - idleTime);
// send idle detect event
parentApplication.postIdleDetect();
@@ -356,8 +355,9 @@
// for example, if UI lag...
long currentDuration = durations.get(durations.size() - 1);
- dataManager.changeTaskTime(managedTask, new Date(), currentDuration / 1000);
-
+ dataManager.changeTaskTime(managedTask, new Date(),
+ currentDuration / 1000);
+
checkTaskAlerts(managedTask);
}
@@ -368,25 +368,22 @@
*/
protected void checkTaskAlerts(TimerTask task) {
Date now = new Date();
-
+
// check alert to be fired
for (TimerAlert alert : task.getAlerts()) {
if (!alreadyTrownAlerts.contains(alert)) {
- if (alert.getType().equals(Type.REACH_DAILY_TIME) && TimerTaskHelper.getTotalTime(task, now) >= alert.getDuration()) {
- //String alertMessage = "Task '%s' has reached %s for current day !";
- //displayAlert(String.format(alertMessage, task.getName(), DurationFormatUtils.formatDuration(alert.getDuration() * 1000, "HH:mm:ss")));
+ if (alert.getType().equals(Type.REACH_DAILY_TIME)
+ && TimerTaskHelper.getTotalTime(task, now) >= alert.getDuration()) {
displayAlert(task, Type.REACH_DAILY_TIME, alert.getDuration());
alreadyTrownAlerts.add(alert.clone());
- }
- else if (alert.getType().equals(Type.REACH_TOTAL_TIME) && TimerTaskHelper.getAllTotalTime(task) >= alert.getDuration()) {
- //String alertMessage = "Task '%s' has reached %s !";
- //displayAlert(String.format(alertMessage, task.getName(), DurationFormatUtils.formatDuration(alert.getDuration() * 1000, "HH:mm:ss")));
+ } else if (alert.getType().equals(Type.REACH_TOTAL_TIME)
+ && TimerTaskHelper.getAllTotalTime(task) >= alert.getDuration()) {
displayAlert(task, Type.REACH_TOTAL_TIME, alert.getDuration());
alreadyTrownAlerts.add(alert.clone());
}
}
}
-
+
// lance aussi les alertes sur les taches parentes
// par exemple, si une tache passe en temps journaliers a 1h
// sont parent y passe aussi, donc les alertes doivent être levée.
@@ -400,21 +397,24 @@
*
* @param alertMessage alert message
*/
- protected void displayAlert(final TimerTask task, final Type alertType, final long alertDuration) {
+ protected void displayAlert(final TimerTask task, final Type alertType,
+ final long alertDuration) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
String alertMessage = null;
String formattedTime = DurationFormatUtils.formatDuration(alertDuration * 1000, "HH:mm:ss");
if (Type.REACH_DAILY_TIME.equals(alertType)) {
- alertMessage = getResourceMap().getString("alert.dailyAlertMessage", task.getName(), formattedTime);
+ alertMessage = getResourceMap().getString(
+ "alert.dailyAlertMessage", task.getName(), formattedTime);
+ } else if (Type.REACH_TOTAL_TIME.equals(alertType)) {
+ alertMessage = getResourceMap().getString(
+ "alert.totalAlertMessage", task.getName(), formattedTime);
}
- else if (Type.REACH_TOTAL_TIME.equals(alertType)) {
- alertMessage = getResourceMap().getString("alert.totalAlertMessage", task.getName(), formattedTime);
- }
-
+
JOptionPane.showMessageDialog(null, alertMessage,
- getResourceMap().getString("alert.title"), JOptionPane.INFORMATION_MESSAGE,
- getResourceMap().getIcon("alert.alertIcon"));
+ getResourceMap().getString("alert.title"),
+ JOptionPane.INFORMATION_MESSAGE, getResourceMap()
+ .getIcon("alert.alertIcon"));
}
});
}
Modified: trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/IdleDialog.properties
===================================================================
--- trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/IdleDialog.properties 2009-11-16 09:19:51 UTC (rev 2693)
+++ trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/IdleDialog.properties 2009-11-16 09:21:54 UTC (rev 2694)
@@ -1,9 +1,9 @@
# idle i18n
idleTitle = Idle detect
-idleIcon = alert.png
+idleIcon = appointment-new.png
idleMessage = You have been idle for %d minutes.
idleRestart = Choose restart option :
-idleDuration = Idle duration : %s
+idleDuration = Idle duration : %s.
chooseRevertOption.Action.text=Stop
chooseRevertOption.Action.shortDescription=Stop task without counting elapsed time
Modified: trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/IdleDialog_fr.properties
===================================================================
--- trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/IdleDialog_fr.properties 2009-11-16 09:19:51 UTC (rev 2693)
+++ trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/IdleDialog_fr.properties 2009-11-16 09:21:54 UTC (rev 2694)
@@ -2,7 +2,7 @@
idleTitle = Inactivit\u00E9 d\u00E9tect\u00E9e
idleMessage = Vous avez \u00E9t\u00E9 inactif pendant %d minutes.
idleRestart = Choisissez une option :
-idleDuration = Dur\u00E9e d'inactivit\u00E9 : %s
+idleDuration = Dur\u00E9e de l'inactivit\u00E9 : %s.
chooseRevertOption.Action.text=Stopper
chooseRevertOption.Action.shortDescription=Annuler le temps \u00E9coul\u00E9 et stopper la t\u00E2che
Deleted: trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/alert.png
===================================================================
(Binary files differ)
Added: trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/appointment-new.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/appointment-new.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
1
0
r2693 - in trunk/src/main: java/org/chorem/jtimer/ui/treetable/dnd resources/org/chorem/jtimer/ui/treetable/dnd/resources
by echatellier@users.chorem.org 16 Nov '09
by echatellier@users.chorem.org 16 Nov '09
16 Nov '09
Author: echatellier
Date: 2009-11-16 10:19:51 +0100 (Mon, 16 Nov 2009)
New Revision: 2693
Modified:
trunk/src/main/java/org/chorem/jtimer/ui/treetable/dnd/TimerTaskTranferable.java
trunk/src/main/java/org/chorem/jtimer/ui/treetable/dnd/TimerTaskTransferHandler.java
trunk/src/main/resources/org/chorem/jtimer/ui/treetable/dnd/resources/TimerTaskTransferHandler.properties
trunk/src/main/resources/org/chorem/jtimer/ui/treetable/dnd/resources/TimerTaskTransferHandler_fr.properties
Log:
Display specific message if only one task is moved
Modified: trunk/src/main/java/org/chorem/jtimer/ui/treetable/dnd/TimerTaskTranferable.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/treetable/dnd/TimerTaskTranferable.java 2009-11-16 09:17:41 UTC (rev 2692)
+++ trunk/src/main/java/org/chorem/jtimer/ui/treetable/dnd/TimerTaskTranferable.java 2009-11-16 09:19:51 UTC (rev 2693)
@@ -22,7 +22,7 @@
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
-import java.util.Collection;
+import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -49,14 +49,14 @@
protected static DataFlavor myData;
/** Tasks to transfer. Chosen implementation must be serializable. */
- protected Collection<TimerTask> tasksToTransfer;
+ protected List<TimerTask> tasksToTransfer;
/**
* Constructor.
*
* @param tasks task to transfer
*/
- public TimerTaskTranferable(Collection<TimerTask> tasks) {
+ public TimerTaskTranferable(List<TimerTask> tasks) {
// save task
this.tasksToTransfer = tasks;
@@ -78,7 +78,7 @@
public Object getTransferData(DataFlavor flavor)
throws UnsupportedFlavorException, IOException {
- Collection<TimerTask> tasks = null;
+ List<TimerTask> tasks = null;
if (flavor == null) {
throw new IOException("flavor is null");
Modified: trunk/src/main/java/org/chorem/jtimer/ui/treetable/dnd/TimerTaskTransferHandler.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/treetable/dnd/TimerTaskTransferHandler.java 2009-11-16 09:17:41 UTC (rev 2692)
+++ trunk/src/main/java/org/chorem/jtimer/ui/treetable/dnd/TimerTaskTransferHandler.java 2009-11-16 09:19:51 UTC (rev 2693)
@@ -22,7 +22,6 @@
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
-import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
@@ -108,13 +107,19 @@
TimerTask destinationTask = selectedTasks.get(0);
Object myObject = transferable
.getTransferData(TimerTaskTranferable.myData);
- Collection<TimerTask> movedTasks = (Collection<TimerTask>) myObject;
+ List<TimerTask> movedTasks = (List<TimerTask>) myObject;
// can't move task to itself
boolean validMove = !TimerTaskHelper.collectionContainsTask(movedTasks, destinationTask);
if (validMove) {
- String title = resourceMap.getString("move.confirmation.title");
- String message = resourceMap.getString("move.confirmation.message", movedTasks.size(), destinationTask.getName());
+ String title = resourceMap.getString("move.task.title");
+ String message;
+ if (movedTasks.size() == 1) {
+ message = resourceMap.getString("move.task.message", movedTasks.get(0).getName(), destinationTask.getName());
+ }
+ else {
+ message = resourceMap.getString("move.tasks.message", movedTasks.size(), destinationTask.getName());
+ }
int answer = JOptionPane.showConfirmDialog(component,
message, title,
JOptionPane.YES_NO_OPTION,
@@ -154,7 +159,7 @@
// only task can be moved !
List<TimerTask> selectedTasks = treeTable.getSelectedTasks();
if (selectedTasks != null && !selectedTasks.isEmpty()) {
- Collection<TimerTask> tasks = new LinkedList<TimerTask>(selectedTasks);
+ List<TimerTask> tasks = new LinkedList<TimerTask>(selectedTasks);
transferable = new TimerTaskTranferable(tasks);
}
@@ -178,7 +183,7 @@
TimerTask destinationTask = selectedTasks.get(0);
Object myObject = transferable
.getTransferData(TimerTaskTranferable.myData);
- Collection<TimerTask> movedTasks = (Collection<TimerTask>) myObject;
+ List<TimerTask> movedTasks = (List<TimerTask>) myObject;
try {
dataManager.moveTask(destinationTask, movedTasks);
Modified: trunk/src/main/resources/org/chorem/jtimer/ui/treetable/dnd/resources/TimerTaskTransferHandler.properties
===================================================================
--- trunk/src/main/resources/org/chorem/jtimer/ui/treetable/dnd/resources/TimerTaskTransferHandler.properties 2009-11-16 09:17:41 UTC (rev 2692)
+++ trunk/src/main/resources/org/chorem/jtimer/ui/treetable/dnd/resources/TimerTaskTransferHandler.properties 2009-11-16 09:19:51 UTC (rev 2693)
@@ -1,6 +1,7 @@
#�Move UI i18n
-move.confirmation.title=Move task
-move.confirmation.message=Do you want to move %d task(s)\nto '%s' ?
+move.task.title=Move task
+move.task.confirmation.message=Do you want to move task '%s'\nto '%s' ?
+move.tasks.confirmation.message=Do you want to move %d tasks\nto '%s' ?
#�error
action.invalidActionTitle=Can't do action
Modified: trunk/src/main/resources/org/chorem/jtimer/ui/treetable/dnd/resources/TimerTaskTransferHandler_fr.properties
===================================================================
--- trunk/src/main/resources/org/chorem/jtimer/ui/treetable/dnd/resources/TimerTaskTransferHandler_fr.properties 2009-11-16 09:17:41 UTC (rev 2692)
+++ trunk/src/main/resources/org/chorem/jtimer/ui/treetable/dnd/resources/TimerTaskTransferHandler_fr.properties 2009-11-16 09:19:51 UTC (rev 2693)
@@ -1,6 +1,7 @@
#�Move UI i18n
-move.confirmation.title=D\u00E9placement de la t\u00E2che
-move.confirmation.message=\u00CAtes vous s\u00FBr de vouloir d\u00E9placer %d t\u00E2che(s)\nvers '%s' ?
+move.task.title=D\u00E9placement de la t\u00E2che
+move.task.message=\u00CAtes vous s\u00FBr de vouloir d\u00E9placer la t\u00E2che '%s'\nvers '%s' ?
+move.tasks.message=\u00CAtes vous s\u00FBr de vouloir d\u00E9placer %d t\u00E2ches\nvers '%s' ?
#�error
action.invalidActionTitle=Impossible d'effectuer cette action
1
0
r2692 - in trunk/src/main: java/org/chorem/jtimer java/org/chorem/jtimer/ui/systray resources/org/chorem/jtimer/ui/systray/resources
by echatellier@users.chorem.org 16 Nov '09
by echatellier@users.chorem.org 16 Nov '09
16 Nov '09
Author: echatellier
Date: 2009-11-16 10:17:41 +0100 (Mon, 16 Nov 2009)
New Revision: 2692
Modified:
trunk/src/main/java/org/chorem/jtimer/JTimer.java
trunk/src/main/java/org/chorem/jtimer/ui/systray/SystrayManager.java
trunk/src/main/resources/org/chorem/jtimer/ui/systray/resources/SystrayManager.properties
trunk/src/main/resources/org/chorem/jtimer/ui/systray/resources/SystrayManager_fr.properties
Log:
#76 : Add "Stop all tasks" action in systray popup menu
Modified: trunk/src/main/java/org/chorem/jtimer/JTimer.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/JTimer.java 2009-11-13 18:05:35 UTC (rev 2691)
+++ trunk/src/main/java/org/chorem/jtimer/JTimer.java 2009-11-16 09:17:41 UTC (rev 2692)
@@ -23,7 +23,6 @@
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
-import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@@ -639,6 +638,19 @@
}
/**
+ * Stop all running tasks.
+ */
+ public void stopAllTasks() {
+
+ TaskMonitor tm = this.getContext().getTaskMonitor();
+ for (Task<Void, Long> t : tm.getTasks()) {
+ // task
+ TimerTask ttask = ((RunTaskJob) t).getTask();
+ stopTask(ttask);
+ }
+ }
+
+ /**
* Close project.
*/
@Action(enabledProperty = "selectedSingleProject")
@@ -1173,21 +1185,12 @@
if (isSelectedSingleStoppedTask()) { // can only launch non running tasks
org.jdesktop.application.Task<?, ?> appTask = startTask();
- // TODO voir si c'est bien ca le lancement
if (appTask != null) {
+
+ // first, on dlb click stop all running tasks
+ stopAllTasks();
+
this.getContext().getTaskService().execute(appTask);
-
- // first, on dlb click stop all running tasks
- TaskMonitor tm = this.getContext().getTaskMonitor();
- for (Task<Void, Long> t : tm.getTasks()) {
- if (appTask != t) { // don't stop just started
- // task
- TimerTask ttask = ((RunTaskJob) t)
- .getTask();
- core.getData().stopTask(ttask);
- ((RunTaskJob) t).wantToStop();
- }
- }
}
}
else {
Modified: trunk/src/main/java/org/chorem/jtimer/ui/systray/SystrayManager.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/systray/SystrayManager.java 2009-11-13 18:05:35 UTC (rev 2691)
+++ trunk/src/main/java/org/chorem/jtimer/ui/systray/SystrayManager.java 2009-11-16 09:17:41 UTC (rev 2692)
@@ -22,7 +22,6 @@
import java.awt.EventQueue;
import java.awt.Image;
import java.awt.SystemTray;
-import java.awt.TrayIcon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
@@ -78,17 +77,20 @@
protected Image idleDetectImage;
/** Tray icon. (null values when tray is non available) */
- protected TrayIcon trayIcon;
+ protected JPopupTrayIcon trayIcon;
/** Reference how many tasks are running. */
protected int nbTasksRunning = 0;
- /** Popup menu instance. */
+ /** Non running popup menu instance. */
protected JPopupMenu popup;
/** Menu show. (used to change text) */
protected JMenuItem showItem;
+ /** Menu stop. (used to enable/disable) */
+ protected JMenuItem stopItem;
+
/**
* Default constructor.
*
@@ -124,16 +126,21 @@
// show
showItem = new JMenuItem(resourceMap.getString("hideMenuText"));
- // showItem.setName("trayShowMenu"); seems don't work with awt
- // components
showItem.addActionListener(this);
showItem.setActionCommand("showHide");
popup.add(showItem);
popup.addSeparator();
+ // stop task
+ stopItem = new JMenuItem(resourceMap.getString("stopMenuText"));
+ stopItem.addActionListener(this);
+ stopItem.setActionCommand("stop");
+ stopItem.setEnabled(false);
+ popup.add(stopItem);
+ popup.addSeparator();
+
// quit
JMenuItem quitItem = new JMenuItem(resourceMap.getString("quitMenuText"));
- // defaultItem.setName("quit");
quitItem.addActionListener(this);
quitItem.setActionCommand("quit");
popup.add(quitItem);
@@ -308,7 +315,7 @@
String message = null;
if (nbTasksRunning == 0) {
message = resourceMap.getString("tooltipIdleText");
-
+
trayIcon.setImage(idleImage);
} else {
trayIcon.setImage(runningImage);
@@ -318,7 +325,11 @@
message = resourceMap.getString("tooltipRunningTasksText", nbTasksRunning);
}
}
+
trayIcon.setToolTip(message);
+
+ // enable some menus
+ stopItem.setEnabled(nbTasksRunning > 0);
}
}
@@ -375,11 +386,12 @@
parent.show();
showItem.setText(resourceMap.getString("hideMenuText"));
}
+ } else if ("stop".equals(actionCommand)) {
+ parent.stopAllTasks();
+ } else if ("quit".equals(actionCommand)) {
+ parent.quit(e);
}
- if ("quit".equals(actionCommand)) {
- parent.quit(e);
- }
}
/*
Modified: trunk/src/main/resources/org/chorem/jtimer/ui/systray/resources/SystrayManager.properties
===================================================================
--- trunk/src/main/resources/org/chorem/jtimer/ui/systray/resources/SystrayManager.properties 2009-11-13 18:05:35 UTC (rev 2691)
+++ trunk/src/main/resources/org/chorem/jtimer/ui/systray/resources/SystrayManager.properties 2009-11-16 09:17:41 UTC (rev 2692)
@@ -9,4 +9,5 @@
tooltipRunningTasksText = ${Application.title} - %d tasks running
showMenuText = Show
hideMenuText = Hide
+stopMenuText = Stop all tasks
quitMenuText = Quit
\ No newline at end of file
Modified: trunk/src/main/resources/org/chorem/jtimer/ui/systray/resources/SystrayManager_fr.properties
===================================================================
--- trunk/src/main/resources/org/chorem/jtimer/ui/systray/resources/SystrayManager_fr.properties 2009-11-13 18:05:35 UTC (rev 2691)
+++ trunk/src/main/resources/org/chorem/jtimer/ui/systray/resources/SystrayManager_fr.properties 2009-11-16 09:17:41 UTC (rev 2692)
@@ -4,4 +4,5 @@
tooltipRunningTasksText = ${Application.title} - %d t\u00E2ches en cours
showMenuText = Montrer
hideMenuText = Cacher
+stopMenuText = Arr\u00EAter toutes les t\u00E2ches
quitMenuText = Quitter
\ No newline at end of file
1
0
r2691 - in trunk/src/main: java/org/chorem/jtimer java/org/chorem/jtimer/ui/tasks resources/org/chorem/jtimer/resources resources/org/chorem/jtimer/ui/resources resources/org/chorem/jtimer/ui/tasks/resources
by echatellier@users.chorem.org 13 Nov '09
by echatellier@users.chorem.org 13 Nov '09
13 Nov '09
Author: echatellier
Date: 2009-11-13 19:05:35 +0100 (Fri, 13 Nov 2009)
New Revision: 2691
Added:
trunk/src/main/java/org/chorem/jtimer/ui/tasks/IdleDialog.java
trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/IdleDialog.properties
trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/IdleDialog_fr.properties
trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/alert.png
trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/go-jump.png
trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/go-next.png
trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/process-stop.png
Removed:
trunk/src/main/resources/org/chorem/jtimer/ui/resources/jtimer-logo-bleu-little.jpg
Modified:
trunk/src/main/java/org/chorem/jtimer/JTimer.java
trunk/src/main/java/org/chorem/jtimer/ui/tasks/RunTaskJob.java
trunk/src/main/resources/org/chorem/jtimer/resources/JTimer.properties
trunk/src/main/resources/org/chorem/jtimer/resources/JTimer_fr.properties
Log:
Modify idle frame (now multi tasks support, beautiful icons :-)...)
Modified: trunk/src/main/java/org/chorem/jtimer/JTimer.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/JTimer.java 2009-11-13 18:04:45 UTC (rev 2690)
+++ trunk/src/main/java/org/chorem/jtimer/JTimer.java 2009-11-13 18:05:35 UTC (rev 2691)
@@ -59,6 +59,7 @@
import org.chorem.jtimer.ui.alert.AlertEditor;
import org.chorem.jtimer.ui.report.ReportView;
import org.chorem.jtimer.ui.systray.SystrayManager;
+import org.chorem.jtimer.ui.tasks.IdleDialog;
import org.chorem.jtimer.ui.tasks.RefreshTreeTask;
import org.chorem.jtimer.ui.tasks.RunTaskJob;
import org.chorem.jtimer.ui.treetable.ProjectsAndTasksTable;
@@ -168,6 +169,8 @@
// Systray mgr
systrayManager = new SystrayManager(this);
core.getData().addDataEventListener(systrayManager);
+
+ IdleDialog.init(this);
}
/**
@@ -1103,59 +1106,6 @@
}
/**
- * Ask user what to do in idle case.
- *
- * @return chosen option
- */
- public int askIdleOption() {
-
- int option;
-
- String[] dialogOption = new String[] {
- resourceMap.getString("idleDetect.askOptionResume"),
- resourceMap.getString("idleDetect.askOptionContinue"),
- resourceMap.getString("idleDetect.askOptionRevert") };
-
- // get instance for current locale
- DateFormat formatter = DateFormat.getTimeInstance(DateFormat.SHORT);
-
- // calculate idle date
- Date idleDate = new Date();
- idleDate.setTime(System.currentTimeMillis()
- - JTimerFactory.getIdleTime());
-
- // build complete message
- // and replace vars
- String title = resourceMap.getString("idleDetect.askTitle");
- String message = resourceMap.getString("idleDetect.askMessage",
- Long.valueOf(JTimerFactory.getIdleTime() / (60 * 1000)), formatter
- .format(idleDate));
-
- int answer = JOptionPane.showOptionDialog(getMainFrame(), message,
- title, JOptionPane.DEFAULT_OPTION,
- JOptionPane.QUESTION_MESSAGE, null, dialogOption,
- dialogOption[0]);
-
- if (log.isDebugEnabled()) {
- log.debug("Answer for idle response = " + answer);
- }
-
- switch (answer) {
- case 0:
- option = RunTaskJob.RESUME;
- break;
- case 1:
- option = RunTaskJob.CONTINUE;
- break;
- default:
- option = RunTaskJob.REVERT;
- break;
- }
-
- return option;
- }
-
- /**
* Get action for named component.
*
* Util method.
Added: trunk/src/main/java/org/chorem/jtimer/ui/tasks/IdleDialog.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/tasks/IdleDialog.java (rev 0)
+++ trunk/src/main/java/org/chorem/jtimer/ui/tasks/IdleDialog.java 2009-11-13 18:05:35 UTC (rev 2691)
@@ -0,0 +1,244 @@
+/* *##%
+ * Copyright (C) 2009 Code Lutin, Chatellier Eric
+ *
+ * This program 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
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+
+package org.chorem.jtimer.ui.tasks;
+
+import java.awt.BorderLayout;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JSeparator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.jtimer.JTimerFactory;
+import org.jdesktop.application.Action;
+import org.jdesktop.application.ApplicationContext;
+import org.jdesktop.application.ResourceManager;
+import org.jdesktop.application.ResourceMap;
+import org.jdesktop.application.SingleFrameApplication;
+
+/**
+ * Idle dialog showed to user when idle has been detected.
+ *
+ * Composed of an unique blocking show method.
+ *
+ * Also composed of three resume option :
+ * <ul>
+ * <li>Stop task
+ * <li>Continue (with idle time summed)
+ * <li>Resume (without idle time summed)
+ * </ul>
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class IdleDialog extends JDialog {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 7669429291708466753L;
+
+ /** log */
+ private static Log log = LogFactory.getLog(IdleDialog.class);
+
+ protected SingleFrameApplication application;
+
+ protected ResourceMap resourceMap;
+
+ protected static IdleDialog mutex;
+
+ protected static int lastResumeOption;
+
+ protected JLabel idleDurationLabel;
+
+ /** Option after idle detect */
+ public static final int REVERT = 0;
+ /** Option after idle detect */
+ public static final int CONTINUE = 1;
+ /** Option after idle detect */
+ public static final int RESUME = 2;
+
+ /**
+ * IdleDialog constructor.
+ *
+ * Protected to force use of show static method.
+ *
+ * @param parent parent application
+ */
+ protected IdleDialog(SingleFrameApplication application) {
+ super(application.getMainFrame());
+
+ // init resources map
+ this.application = application;
+ ApplicationContext ctxt = application.getContext();
+ ResourceManager mgr = ctxt.getResourceManager();
+ resourceMap = mgr.getResourceMap(IdleDialog.class);
+
+ //setName("idleFrame");
+ setTitle(resourceMap.getString("idleTitle"));
+ setResizable(false);
+
+ // TODO : must be modal , but break mecanism
+ //setModal(true);
+
+ getRootPane().setLayout(new BorderLayout(1,1));
+ getRootPane().add(getMainComponent(), BorderLayout.CENTER);
+ }
+
+ /**
+ * Build main component UI.
+ *
+ * @return component ui.
+ */
+ private JComponent getMainComponent() {
+ JPanel mainComponent = new JPanel(new GridBagLayout());
+
+ // label
+ JLabel idleIcon = new JLabel(resourceMap.getIcon("idleIcon"));
+ mainComponent.add(idleIcon, new GridBagConstraints(0, 0, 1, 5, 0, 1,
+ GridBagConstraints.NORTH, GridBagConstraints.NONE,
+ new Insets(10, 10, 10, 10), 0, 0));
+
+ // label
+ JLabel idleLabel = new JLabel(resourceMap.getString("idleMessage",
+ Long.valueOf(JTimerFactory.getIdleTime() / (60 * 1000))));
+ mainComponent.add(idleLabel, new GridBagConstraints(1, 0, 3, 1, 1, 0,
+ GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
+ new Insets(5, 0, 0, 3), 0, 0));
+
+ idleDurationLabel = new JLabel(" ");
+ mainComponent.add(idleDurationLabel, new GridBagConstraints(1, 1, 3, 1, 1, 0,
+ GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
+ new Insets(5, 0, 5, 5), 0, 0));
+
+ // separator
+ mainComponent.add(new JSeparator(), new GridBagConstraints(1, 2, 3, 1, 1, 0,
+ GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
+ new Insets(0, 0, 0, 5), 0, 0));
+
+ // label
+ JLabel idleRestart = new JLabel(resourceMap.getString("idleRestart"));
+ mainComponent.add(idleRestart, new GridBagConstraints(1, 3, 3, 1, 1, 0,
+ GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
+ new Insets(5, 0, 0, 3), 0, 0));
+
+ JButton revertButton = new JButton();
+ revertButton.setHorizontalAlignment(JLabel.LEFT);
+ revertButton.setAction(application.getContext().getActionMap(this).get("chooseRevertOption"));
+ mainComponent.add(revertButton, new GridBagConstraints(1, 4, 1, 1, 1, 0,
+ GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
+ new Insets(5, 0, 5, 5), 0, 0));
+
+ JButton continueButton = new JButton();
+ continueButton.setHorizontalAlignment(JLabel.LEFT);
+ continueButton.setAction(application.getContext().getActionMap(this).get("chooseContinueOption"));
+ mainComponent.add(continueButton, new GridBagConstraints(2, 4, 1, 1, 1, 0,
+ GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
+ new Insets(5, 0, 5, 5), 0, 0));
+
+ JButton resumeButton = new JButton();
+ resumeButton.setHorizontalAlignment(JLabel.LEFT);
+ resumeButton.setAction(application.getContext().getActionMap(this).get("chooseResumeOption"));
+ mainComponent.add(resumeButton, new GridBagConstraints(3, 4, 1, 1, 1, 0,
+ GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
+ new Insets(5, 0, 5, 5), 0, 0));
+
+ return mainComponent;
+ }
+
+ public void run () {
+ idleDurationLabel.setText(resourceMap.getString("idleDuration",
+ Long.valueOf(JTimerFactory.getIdleTime() / (60 * 1000))));
+ }
+ /**
+ * Init dialog mutex instance.
+ *
+ * @param parent parent reference
+ */
+ public static void init(SingleFrameApplication parent) {
+ mutex = new IdleDialog(parent);
+ }
+
+ @Action
+ public void chooseRevertOption() {
+ lastResumeOption = REVERT;
+ idleEnded();
+ }
+
+ @Action
+ public void chooseContinueOption() {
+ lastResumeOption = CONTINUE;
+ idleEnded();
+ }
+
+ @Action
+ public void chooseResumeOption() {
+ lastResumeOption = RESUME;
+ idleEnded();
+ }
+
+ protected void idleEnded() {
+ synchronized(this) {
+ notifyAll();
+ }
+ setVisible(false);
+ }
+
+ protected synchronized void waitForIdleEnd() {
+ try {
+ wait();
+ log.debug("Thread unwaiting");
+ } catch (InterruptedException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Thread inturrupted", e);
+ }
+ }
+ }
+
+ /**
+ * Called function on idle detect.
+ *
+ * This function is thread safe and show only one dialog even if
+ * function is called multiples times.
+ *
+ * @param lastActivityTimestamp
+ * @return idle option
+ */
+ public static int showIdleDialog(long lastActivityTimestamp) {
+ //synchronized(mutex) {
+ if (!mutex.isVisible()) {
+ mutex.application.show(mutex);
+ mutex.run();
+ }
+ //}
+
+ mutex.waitForIdleEnd();
+
+ return lastResumeOption;
+ }
+}
Property changes on: trunk/src/main/java/org/chorem/jtimer/ui/tasks/IdleDialog.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Modified: trunk/src/main/java/org/chorem/jtimer/ui/tasks/RunTaskJob.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/tasks/RunTaskJob.java 2009-11-13 18:04:45 UTC (rev 2690)
+++ trunk/src/main/java/org/chorem/jtimer/ui/tasks/RunTaskJob.java 2009-11-13 18:05:35 UTC (rev 2691)
@@ -91,13 +91,6 @@
/** Want to stop flag */
protected Boolean bWantToStop;
- /** Option after idle detect */
- public static final int REVERT = 0;
- /** Option after idle detect */
- public static final int CONTINUE = 1;
- /** Option after idle detect */
- public static final int RESUME = 2;
-
/**
* Constructor.
*
@@ -298,7 +291,8 @@
// send idle detect event
parentApplication.preIdleDetect();
// ask user what to do
- int option = ((JTimer) getApplication()).askIdleOption();
+ //int option = ((JTimer) getApplication()).askIdleOption();
+ int option = IdleDialog.showIdleDialog(lastPublishTimestamp);
// send idle detect event
parentApplication.postIdleDetect();
@@ -308,12 +302,12 @@
switch (option) {
- case REVERT:
+ case IdleDialog.REVERT:
// just stop the task
((JTimer) getApplication()).stopTask(managedTask);
break;
- case CONTINUE:
+ case IdleDialog.CONTINUE:
// refresh time
// remove idle time previously added
offsetTimeInMs += configIdleTime;
Modified: trunk/src/main/resources/org/chorem/jtimer/resources/JTimer.properties
===================================================================
--- trunk/src/main/resources/org/chorem/jtimer/resources/JTimer.properties 2009-11-13 18:04:45 UTC (rev 2690)
+++ trunk/src/main/resources/org/chorem/jtimer/resources/JTimer.properties 2009-11-13 18:05:35 UTC (rev 2691)
@@ -144,13 +144,6 @@
vetoable.saver.invalid.task.characters=Task name contains invalid characters !
vetoable.ws.chorem.cant.modify.synchronized.project=Can't do this action on a synchronized project !
-# idle i18n
-idleDetect.askTitle = Idle detect
-idleDetect.askMessage = You have been idle for %d minutes (%s)\n\nYou may now:\n - revert to back before the idle\n - continue timing, ignoring the idle\n - resume timing from when the idle started
-idleDetect.askOptionContinue = Continue
-idleDetect.askOptionRevert = Revert
-idleDetect.askOptionResume = Resume
-
#�Start fail i18n
startFail.title=Error
startFail.message=${Application.title} fail to init.\nCheck that ${Application.title} is not already launched.
Modified: trunk/src/main/resources/org/chorem/jtimer/resources/JTimer_fr.properties
===================================================================
--- trunk/src/main/resources/org/chorem/jtimer/resources/JTimer_fr.properties 2009-11-13 18:04:45 UTC (rev 2690)
+++ trunk/src/main/resources/org/chorem/jtimer/resources/JTimer_fr.properties 2009-11-13 18:05:35 UTC (rev 2691)
@@ -124,13 +124,6 @@
vetoable.saver.invalid.characters=Le nom contient des caract\u00E8res invalide !
vetoable.ws.chorem.cant.modify.synchronized.project=Impossible d'effectuer cette action sur un projet synchronis\u00E9 !
-# jtimer main class
-idleDetect.askTitle = Inactivit\u00E9 d\u00E9tect\u00E9e
-idleDetect.askMessage = Vous avez \u00E9t\u00E9 inactif pendant %d minutes (%s)\n\nVous pouvez maintenant :\n - revenir avant l'inactivit\u00E9\n - continuer en ignorant l'inactivit\u00E9\n - reprendre depuis la d\u00E9tection de l'inactivit\u00E9
-idleDetect.askOptionContinue = Continuer
-idleDetect.askOptionRevert = Revenir
-idleDetect.askOptionResume = Reprendre
-
#�Start fail i18n
startFail.title=Erreur
startFail.message=${Application.title} n'a pas r\u00E9ussi \u00E0 s'initiliser.\nV\u00E9rifiez que ${Application.title} n'est pas d\u00E9j\u00E0 lanc\u00E9.
\ No newline at end of file
Deleted: trunk/src/main/resources/org/chorem/jtimer/ui/resources/jtimer-logo-bleu-little.jpg
===================================================================
(Binary files differ)
Added: trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/IdleDialog.properties
===================================================================
--- trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/IdleDialog.properties (rev 0)
+++ trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/IdleDialog.properties 2009-11-13 18:05:35 UTC (rev 2691)
@@ -0,0 +1,18 @@
+# idle i18n
+idleTitle = Idle detect
+idleIcon = alert.png
+idleMessage = You have been idle for %d minutes.
+idleRestart = Choose restart option :
+idleDuration = Idle duration : %s
+
+chooseRevertOption.Action.text=Stop
+chooseRevertOption.Action.shortDescription=Stop task without counting elapsed time
+chooseRevertOption.Action.icon=process-stop.png
+
+chooseContinueOption.Action.text=Continue
+chooseContinueOption.Action.shortDescription=Continue task counting elapsed time
+chooseContinueOption.Action.icon=go-next.png
+
+chooseResumeOption.Action.text=Resume
+chooseResumeOption.Action.shortDescription=Resume task without counting elapsed time
+chooseResumeOption.Action.icon=go-jump.png
Added: trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/IdleDialog_fr.properties
===================================================================
--- trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/IdleDialog_fr.properties (rev 0)
+++ trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/IdleDialog_fr.properties 2009-11-13 18:05:35 UTC (rev 2691)
@@ -0,0 +1,17 @@
+# idle i18n
+idleTitle = Inactivit\u00E9 d\u00E9tect\u00E9e
+idleMessage = Vous avez \u00E9t\u00E9 inactif pendant %d minutes.
+idleRestart = Choisissez une option :
+idleDuration = Dur\u00E9e d'inactivit\u00E9 : %s
+
+chooseRevertOption.Action.text=Stopper
+chooseRevertOption.Action.shortDescription=Annuler le temps \u00E9coul\u00E9 et stopper la t\u00E2che
+chooseRevertOption.Action.icon=process-stop.png
+
+chooseContinueOption.Action.text=Continuer
+chooseContinueOption.Action.shortDescription=Continuer la t\u00E2che en comptant le temps \u00E9coul\u00E9
+chooseContinueOption.Action.icon=go-next.png
+
+chooseResumeOption.Action.text=Reprendre
+chooseResumeOption.Action.shortDescription=Reprendre la t\u00E2che en ne comptant pas le temps \u00E9coul\u00E9
+chooseResumeOption.Action.icon=go-jump.png
Added: trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/alert.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/alert.png
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ application/octet-stream
Added: trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/go-jump.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/go-jump.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/go-next.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/go-next.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/process-stop.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/resources/org/chorem/jtimer/ui/tasks/resources/process-stop.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
1
0
r2690 - in trunk: . src/main/resources/org/chorem/jtimer/ui/resources
by echatellier@users.chorem.org 13 Nov '09
by echatellier@users.chorem.org 13 Nov '09
13 Nov '09
Author: echatellier
Date: 2009-11-13 19:04:45 +0100 (Fri, 13 Nov 2009)
New Revision: 2690
Modified:
trunk/pom.xml
trunk/src/main/resources/org/chorem/jtimer/ui/resources/HelpFrame.properties
trunk/src/main/resources/org/chorem/jtimer/ui/resources/HelpFrame_fr.properties
Log:
Fix maven3 pom warnings. Add build date in about box.
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-11-06 13:27:59 UTC (rev 2689)
+++ trunk/pom.xml 2009-11-13 18:04:45 UTC (rev 2690)
@@ -175,6 +175,25 @@
<plugins>
<plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>buildnumber-maven-plugin</artifactId>
+ <version>1.0-beta-3</version>
+ <executions>
+ <execution>
+ <phase>validate</phase>
+ <goals>
+ <goal>create</goal>
+ </goals>
+ <configuration>
+ <format>{0,date,yyyy-MM-dd}</format>
+ <items>
+ <item>timestamp</item>
+ </items>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
@@ -200,7 +219,7 @@
<plugins>
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
- <!-- <version>2.4</version>-->
+ <version>2.3</version>
<configuration>
<!-- <configLocation>checkstyle.xml</configLocation>-->
<excludes>**/Xss.java,**/X11.java,**/Kernel32.java,**/User32.java</excludes>
@@ -208,7 +227,6 @@
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
- <!-- fix french characters -->
<version>2.1.2</version>
<configuration>
<developerConnection>${project.scm.connection}</developerConnection>
@@ -240,6 +258,7 @@
</plugin>
<plugin>
<artifactId>maven-changelog-plugin</artifactId>
+ <version>2.1</version>
<configuration>
<type>range</type>
<range>365</range>
@@ -247,6 +266,7 @@
</plugin>
<plugin>
<artifactId>maven-changes-plugin</artifactId>
+ <version>2.1</version>
<reportSets>
<reportSet>
<reports>
@@ -257,15 +277,18 @@
</plugin>
<plugin>
<artifactId>maven-pmd-plugin</artifactId>
+ <version>2.4</version>
<configuration>
<targetJdk>${maven.compiler.source}</targetJdk>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jxr-plugin</artifactId>
+ <version>2.1</version>
</plugin>
<plugin>
<artifactId>maven-surefire-report-plugin</artifactId>
+ <version>2.4.3</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
Modified: trunk/src/main/resources/org/chorem/jtimer/ui/resources/HelpFrame.properties
===================================================================
--- trunk/src/main/resources/org/chorem/jtimer/ui/resources/HelpFrame.properties 2009-11-06 13:27:59 UTC (rev 2689)
+++ trunk/src/main/resources/org/chorem/jtimer/ui/resources/HelpFrame.properties 2009-11-13 18:04:45 UTC (rev 2690)
@@ -4,7 +4,7 @@
#�About i18n
aboutTitle = About ${Application.title}
aboutHtmlTitle = About ${Application.title}
-aboutHtml = <html><b>${Application.title} (${Application.version})</b><br /><br />Copyright 2007 - 2009, Code Lutin.<br /><br /><a href=\"${project.url}\">${project.url}</a><br /><br />Please, report any bug you can found.<html>
+aboutHtml = <html><b>${Application.title} - ${Application.version} (${buildNumber})</b><br /><br />Copyright 2007 - 2009, Code Lutin.<br /><br /><a href=\"${project.url}\">${project.url}</a><br /><br />Please, report any bug you can found.<html>
aboutLicenseTitle = License
aboutLicense = You can modify and redistribute the program under the conditions of the GNU General Public License (version 2 or later). A copy of the GPL is in the file "LICENSE.txt" provided with ${Application.title}. All rights reserved. No guarantees are provided for use of this program.
Modified: trunk/src/main/resources/org/chorem/jtimer/ui/resources/HelpFrame_fr.properties
===================================================================
--- trunk/src/main/resources/org/chorem/jtimer/ui/resources/HelpFrame_fr.properties 2009-11-06 13:27:59 UTC (rev 2689)
+++ trunk/src/main/resources/org/chorem/jtimer/ui/resources/HelpFrame_fr.properties 2009-11-13 18:04:45 UTC (rev 2690)
@@ -1,7 +1,7 @@
#�About i18n
aboutTitle = \u00C0 propos de ${Application.title}
aboutHtmlTitle = \u00C0 propos de ${Application.title}
-aboutHtml = <html><b>${Application.title} (${Application.version})</b><br /><br />Copyright 2007 - 2009, Code Lutin.<br /><br /><a href=\"${project.url}\">${project.url}</a><br /><br />Merci de rapporter les bugs de ${Application.title}.<html>
+aboutHtml = <html><b>${Application.title} - ${Application.version} (${buildNumber})</b><br /><br />Copyright 2007 - 2009, Code Lutin.<br /><br /><a href=\"${project.url}\">${project.url}</a><br /><br />Merci de rapporter les bugs de ${Application.title}.<html>
aboutLicenseTitle = Licence
aboutLicense = Vous pouvez modifier et redistribuer ce programme sous les conditions \u00E9nonc\u00E9es par la licence GNU GPL (version 2 ou ult\u00E9rieure). Une copie de la licence GPL est dans le fichier \u00AB\u00A0LICENSE.txt\u00A0\u00BB fourni avec ${Application.title}. Tous droits r\u00E9serv\u00E9s. Aucune garantie n'est fournie pour l'utilisation de ce programme.
1
0
r2689 - in trunk/src: main/java/org/chorem/jtimer/data main/java/org/chorem/jtimer/entities main/java/org/chorem/jtimer/ui/treetable/dnd main/resources/org/chorem/jtimer/ui/treetable/dnd/resources test/java/org/chorem/jtimer/data
by echatellier@users.chorem.org 06 Nov '09
by echatellier@users.chorem.org 06 Nov '09
06 Nov '09
Author: echatellier
Date: 2009-11-06 14:27:59 +0100 (Fri, 06 Nov 2009)
New Revision: 2689
Modified:
trunk/src/main/java/org/chorem/jtimer/data/CommonVetoable.java
trunk/src/main/java/org/chorem/jtimer/entities/TimerTaskHelper.java
trunk/src/main/java/org/chorem/jtimer/ui/treetable/dnd/TimerTaskTranferable.java
trunk/src/main/java/org/chorem/jtimer/ui/treetable/dnd/TimerTaskTransferHandler.java
trunk/src/main/resources/org/chorem/jtimer/ui/treetable/dnd/resources/TimerTaskTransferHandler.properties
trunk/src/main/resources/org/chorem/jtimer/ui/treetable/dnd/resources/TimerTaskTransferHandler_fr.properties
trunk/src/test/java/org/chorem/jtimer/data/CommonVetoableTest.java
Log:
Finish multiple task move (UI part)
Modified: trunk/src/main/java/org/chorem/jtimer/data/CommonVetoable.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/data/CommonVetoable.java 2009-11-04 10:23:46 UTC (rev 2688)
+++ trunk/src/main/java/org/chorem/jtimer/data/CommonVetoable.java 2009-11-06 13:27:59 UTC (rev 2689)
@@ -26,6 +26,7 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.jtimer.entities.TimerProject;
import org.chorem.jtimer.entities.TimerTask;
+import org.chorem.jtimer.entities.TimerTaskHelper;
/**
* Common jtimer vetoable politics.
@@ -183,6 +184,16 @@
@Override
public void checkMoveTask(TimerTask destination, Collection<TimerTask> tasksToMove) {
+ // check if destination is one task to move
+ // no sens
+ if (TimerTaskHelper.collectionContainsTask(tasksToMove, destination)) {
+ if (log.isDebugEnabled()) {
+ log.debug("Move task into himself, impossible");
+ }
+ throw new DataViolationException("Can't move task into himself",
+ MOVE_INVALID_TYPES_VIOLATION);
+ }
+
for (TimerTask taskToMove : tasksToMove) {
// can't move projects
Modified: trunk/src/main/java/org/chorem/jtimer/entities/TimerTaskHelper.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/entities/TimerTaskHelper.java 2009-11-04 10:23:46 UTC (rev 2688)
+++ trunk/src/main/java/org/chorem/jtimer/entities/TimerTaskHelper.java 2009-11-06 13:27:59 UTC (rev 2689)
@@ -20,6 +20,7 @@
import java.util.ArrayList;
import java.util.Calendar;
+import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
@@ -291,4 +292,28 @@
}
}
}
+
+ /**
+ * Check if task is present in tasks collection and recursive subtasks.
+ *
+ * @param tasks task collection to search into
+ * @param task task to search
+ * @return {@code true} if task has been found
+ */
+ public static boolean collectionContainsTask(Collection<TimerTask> tasks, TimerTask task) {
+
+ boolean present = false;
+
+ for (TimerTask oneTask : tasks) {
+ if (task == oneTask) {
+ present = true;
+ }
+
+ if (collectionContainsTask(oneTask.getSubTasks(), task)) {
+ present = true;
+ }
+ }
+
+ return present;
+ }
}
Modified: trunk/src/main/java/org/chorem/jtimer/ui/treetable/dnd/TimerTaskTranferable.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/treetable/dnd/TimerTaskTranferable.java 2009-11-04 10:23:46 UTC (rev 2688)
+++ trunk/src/main/java/org/chorem/jtimer/ui/treetable/dnd/TimerTaskTranferable.java 2009-11-06 13:27:59 UTC (rev 2689)
@@ -22,6 +22,7 @@
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
+import java.util.Collection;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -47,18 +48,18 @@
/** Data instance */
protected static DataFlavor myData;
- /** Task to transfer */
- protected TimerTask taskToTransfer;
+ /** Tasks to transfer. Chosen implementation must be serializable. */
+ protected Collection<TimerTask> tasksToTransfer;
/**
* Constructor.
*
- * @param task task to transfer
+ * @param tasks task to transfer
*/
- public TimerTaskTranferable(TimerTask task) {
+ public TimerTaskTranferable(Collection<TimerTask> tasks) {
// save task
- this.taskToTransfer = task;
+ this.tasksToTransfer = tasks;
// build new DataFlavor
try {
@@ -77,19 +78,19 @@
public Object getTransferData(DataFlavor flavor)
throws UnsupportedFlavorException, IOException {
- TimerTask task = null;
+ Collection<TimerTask> tasks = null;
if (flavor == null) {
throw new IOException("flavor is null");
}
if (flavor.equals(myData)) {
- task = taskToTransfer;
+ tasks = tasksToTransfer;
} else {
throw new UnsupportedFlavorException(flavor);
}
- return task;
+ return tasks;
}
/*
Modified: trunk/src/main/java/org/chorem/jtimer/ui/treetable/dnd/TimerTaskTransferHandler.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/treetable/dnd/TimerTaskTransferHandler.java 2009-11-04 10:23:46 UTC (rev 2688)
+++ trunk/src/main/java/org/chorem/jtimer/ui/treetable/dnd/TimerTaskTransferHandler.java 2009-11-06 13:27:59 UTC (rev 2689)
@@ -22,7 +22,8 @@
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
-import java.util.Collections;
+import java.util.Collection;
+import java.util.LinkedList;
import java.util.List;
import javax.swing.JComponent;
@@ -35,6 +36,7 @@
import org.chorem.jtimer.data.DataViolationException;
import org.chorem.jtimer.data.TimerDataManager;
import org.chorem.jtimer.entities.TimerTask;
+import org.chorem.jtimer.entities.TimerTaskHelper;
import org.chorem.jtimer.ui.treetable.ProjectsAndTasksTable;
import org.jdesktop.application.Application;
import org.jdesktop.application.ApplicationContext;
@@ -42,7 +44,7 @@
import org.jdesktop.application.ResourceMap;
/**
- * Transfert handler used to transfert task in table.
+ * Transfer handler used to transfer tasks in table.
*
* @author chatellier
* @version $Revision$
@@ -106,12 +108,13 @@
TimerTask destinationTask = selectedTasks.get(0);
Object myObject = transferable
.getTransferData(TimerTaskTranferable.myData);
- TimerTask movedTask = (TimerTask) myObject;
+ Collection<TimerTask> movedTasks = (Collection<TimerTask>) myObject;
// can't move task to itself
- if (movedTask != destinationTask) {
+ boolean validMove = !TimerTaskHelper.collectionContainsTask(movedTasks, destinationTask);
+ if (validMove) {
String title = resourceMap.getString("move.confirmation.title");
- String message = resourceMap.getString("move.confirmation.message", movedTask.getName(), destinationTask.getName());
+ String message = resourceMap.getString("move.confirmation.message", movedTasks.size(), destinationTask.getName());
int answer = JOptionPane.showConfirmDialog(component,
message, title,
JOptionPane.YES_NO_OPTION,
@@ -151,8 +154,8 @@
// only task can be moved !
List<TimerTask> selectedTasks = treeTable.getSelectedTasks();
if (selectedTasks != null && !selectedTasks.isEmpty()) {
- TimerTask task = selectedTasks.get(0);
- transferable = new TimerTaskTranferable(task);
+ Collection<TimerTask> tasks = new LinkedList<TimerTask>(selectedTasks);
+ transferable = new TimerTaskTranferable(tasks);
}
return transferable;
@@ -175,10 +178,10 @@
TimerTask destinationTask = selectedTasks.get(0);
Object myObject = transferable
.getTransferData(TimerTaskTranferable.myData);
- TimerTask movedTask = (TimerTask) myObject;
+ Collection<TimerTask> movedTasks = (Collection<TimerTask>) myObject;
try {
- dataManager.moveTask(destinationTask, Collections.singleton(movedTask));
+ dataManager.moveTask(destinationTask, movedTasks);
}
catch(DataViolationException e) {
String title = resourceMap.getString("action.invalidActionTitle");
Modified: trunk/src/main/resources/org/chorem/jtimer/ui/treetable/dnd/resources/TimerTaskTransferHandler.properties
===================================================================
--- trunk/src/main/resources/org/chorem/jtimer/ui/treetable/dnd/resources/TimerTaskTransferHandler.properties 2009-11-04 10:23:46 UTC (rev 2688)
+++ trunk/src/main/resources/org/chorem/jtimer/ui/treetable/dnd/resources/TimerTaskTransferHandler.properties 2009-11-06 13:27:59 UTC (rev 2689)
@@ -1,6 +1,6 @@
#�Move UI i18n
move.confirmation.title=Move task
-move.confirmation.message=Do you want to move task '%s'\nto '%s' ?
+move.confirmation.message=Do you want to move %d task(s)\nto '%s' ?
#�error
action.invalidActionTitle=Can't do action
Modified: trunk/src/main/resources/org/chorem/jtimer/ui/treetable/dnd/resources/TimerTaskTransferHandler_fr.properties
===================================================================
--- trunk/src/main/resources/org/chorem/jtimer/ui/treetable/dnd/resources/TimerTaskTransferHandler_fr.properties 2009-11-04 10:23:46 UTC (rev 2688)
+++ trunk/src/main/resources/org/chorem/jtimer/ui/treetable/dnd/resources/TimerTaskTransferHandler_fr.properties 2009-11-06 13:27:59 UTC (rev 2689)
@@ -1,6 +1,6 @@
#�Move UI i18n
move.confirmation.title=D\u00E9placement de la t\u00E2che
-move.confirmation.message=\u00CAtes vous s\u00FBr de vouloir d\u00E9placer la t\u00E2che '%s'\nvers '%s' ?
+move.confirmation.message=\u00CAtes vous s\u00FBr de vouloir d\u00E9placer %d t\u00E2che(s)\nvers '%s' ?
#�error
action.invalidActionTitle=Impossible d'effectuer cette action
Modified: trunk/src/test/java/org/chorem/jtimer/data/CommonVetoableTest.java
===================================================================
--- trunk/src/test/java/org/chorem/jtimer/data/CommonVetoableTest.java 2009-11-04 10:23:46 UTC (rev 2688)
+++ trunk/src/test/java/org/chorem/jtimer/data/CommonVetoableTest.java 2009-11-06 13:27:59 UTC (rev 2689)
@@ -18,8 +18,10 @@
package org.chorem.jtimer.data;
+import java.util.Collection;
import java.util.Collections;
import java.util.Date;
+import java.util.HashSet;
import java.util.List;
import junit.framework.Assert;
@@ -135,6 +137,41 @@
}
/**
+ * Test multiples tasks move move into one task to move.
+ */
+ @Test(expectedExceptions = DataViolationException.class)
+ public void testMoveMultiplesTasks() {
+
+ // first load all
+ // and make a move operation
+ TimerCore core = new TimerCore();
+ TimerDataManager dataManager = core.getData();
+
+ //core.init();
+ core.load();
+ List<TimerProject> projectsBefore = dataManager.getProjectsList();
+ TimerTask task1 = findTask(projectsBefore, "jTimer/Add workspace support");
+ TimerTask task2 = findTask(projectsBefore, "jTimer/Interact with chorem services");
+ TimerTask task3 = findTask(projectsBefore, "jTimer/Refactoring");
+ TimerTask task4 = findTask(projectsBefore, "jTimer/Unit tests");
+
+ Assert.assertNotNull(task1);
+ Assert.assertNotNull(task2);
+ Assert.assertNotNull(task3);
+ Assert.assertNotNull(task4);
+
+ Collection<TimerTask> tasksToMove = new HashSet<TimerTask>();
+ tasksToMove.add(task1);
+ tasksToMove.add(task2);
+ tasksToMove.add(task3);
+ tasksToMove.add(task4);
+
+ // move task 3 in task1 : forbidden
+ dataManager.moveTask(task1, tasksToMove);
+
+ }
+
+ /**
* Merge two projects and tasks.
*/
@Test(expectedExceptions = DataViolationException.class)
1
0
04 Nov '09
Author: echatellier
Date: 2009-11-04 11:23:46 +0100 (Wed, 04 Nov 2009)
New Revision: 2688
Modified:
trunk/src/main/java/org/chorem/jtimer/ui/tasks/RunTaskJob.java
Log:
Don't reset time to 0 after hibernation detect, set it to daily task time
Modified: trunk/src/main/java/org/chorem/jtimer/ui/tasks/RunTaskJob.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/tasks/RunTaskJob.java 2009-11-03 10:06:13 UTC (rev 2687)
+++ trunk/src/main/java/org/chorem/jtimer/ui/tasks/RunTaskJob.java 2009-11-04 10:23:46 UTC (rev 2688)
@@ -204,20 +204,22 @@
taskStartCalendar = Calendar.getInstance();
lastPublishTimestamp = taskStartCalendar.getTimeInMillis();
- // need to be 0 here not managedTask.getTodayTime();
+ // need to be 0 here not managedTask.getTime(new Date());
// for idle detected when 0hOO goes...
- taskTimingBeforeStartInMs = 0; // managedTask.getTodayTime();
+ //taskTimingBeforeStartInMs = managedTask.getTime(new Date());
+
+ // need to be this for hibernation in same day
+ taskTimingBeforeStartInMs = managedTask.getTime(new Date()) * 1000;
offsetTimeInMs = 0;
}
/**
* Check if task need to be reset.
*
- * Test if today number if different of taskStartTimestamp day number
+ * Test if today number if different of taskStartCalendar day number
*/
protected void checkReset() {
- // TODO Put it in JTimerUtil
Calendar nowCalendar = Calendar.getInstance();
// si les jours actuel et jours de debut de start ne sont
@@ -245,7 +247,7 @@
// reset on start just for init
resetTiming();
// redeclare taskTimingBeforeStartInSeconds
- taskTimingBeforeStartInMs = managedTask.getTime(new Date()) * 1000;
+ //taskTimingBeforeStartInMs = managedTask.getTime(new Date()) * 1000;
// get idle time
long configIdleTime = JTimerFactory.getIdleTime();
1
0
r2687 - in trunk: . src/main/java/org/chorem/jtimer/data src/main/java/org/chorem/jtimer/io src/main/java/org/chorem/jtimer/ui/treetable/dnd src/main/java/org/chorem/jtimer/ws/xmlrpc src/main/resources/org/chorem/jtimer/resources src/test/java/org/chorem/jtimer/data
by echatellier@users.chorem.org 03 Nov '09
by echatellier@users.chorem.org 03 Nov '09
03 Nov '09
Author: echatellier
Date: 2009-11-03 11:06:13 +0100 (Tue, 03 Nov 2009)
New Revision: 2687
Added:
trunk/src/test/java/org/chorem/jtimer/data/CommonVetoableTest.java
Modified:
trunk/changelog.txt
trunk/src/main/java/org/chorem/jtimer/data/CommonVetoable.java
trunk/src/main/java/org/chorem/jtimer/data/TimerDataManager.java
trunk/src/main/java/org/chorem/jtimer/data/VetoableDataEventListener.java
trunk/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java
trunk/src/main/java/org/chorem/jtimer/ui/treetable/dnd/TimerTaskTransferHandler.java
trunk/src/main/java/org/chorem/jtimer/ws/xmlrpc/ChoremXMLRPCClient.java
trunk/src/main/resources/org/chorem/jtimer/resources/JTimer.properties
trunk/src/main/resources/org/chorem/jtimer/resources/JTimer_fr.properties
trunk/src/test/java/org/chorem/jtimer/data/TimerDataManagerTest.java
Log:
Add multiples tasks move support.
Add test about forbidden actions.
Modified: trunk/changelog.txt
===================================================================
--- trunk/changelog.txt 2009-11-03 09:02:37 UTC (rev 2686)
+++ trunk/changelog.txt 2009-11-03 10:06:13 UTC (rev 2687)
@@ -3,6 +3,7 @@
jTimer (1.3.1) stable; urgency=low
+ * Add multiples task move support
* Readd jnlp launch
* Fix systray popup menu not closed on focus lost
* Force task selection on right clic
Modified: trunk/src/main/java/org/chorem/jtimer/data/CommonVetoable.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/data/CommonVetoable.java 2009-11-03 09:02:37 UTC (rev 2686)
+++ trunk/src/main/java/org/chorem/jtimer/data/CommonVetoable.java 2009-11-03 10:06:13 UTC (rev 2687)
@@ -1,5 +1,5 @@
/* *##%
- * Copyright (C) 2008 Code Lutin
+ * Copyright (C) 2008, 2009 Code Lutin
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -18,6 +18,7 @@
package org.chorem.jtimer.data;
+import java.util.Collection;
import java.util.Date;
import java.util.List;
@@ -50,7 +51,9 @@
protected static final String DUPLICATED_PROJECT_VIOLATION = "vetoable.common.duplicated.project.name";
/** Duplicated task violation key. */
protected static final String DUPLICATED_TASK_VIOLATION = "vetoable.common.duplicated.task.name";
- /** Violation if try to merge task and projet */
+ /** Violation if try to move project into task. */
+ protected static final String MOVE_INVALID_TYPES_VIOLATION = "vetoable.common.move.invalid.types";
+ /** Violation if try to merge task and project. */
protected static final String MERGE_INVALID_TYPES_VIOLATION = "vetoable.common.merge.invalid.types";
/** Data manager */
@@ -178,14 +181,27 @@
* {@inheritDoc}
*/
@Override
- public void checkMoveTask(TimerTask task, TimerTask taskToMoveTo) {
- // check duplicated task name
- if (isSameTaskName(task, taskToMoveTo.getSubTasks())) {
- if (log.isDebugEnabled()) {
- log.debug("Duplicated name, checkMoveTask won't pass");
+ public void checkMoveTask(TimerTask destination, Collection<TimerTask> tasksToMove) {
+
+ for (TimerTask taskToMove : tasksToMove) {
+
+ // can't move projects
+ if (taskToMove instanceof TimerProject) {
+ if (log.isDebugEnabled()) {
+ log.debug("Move project, impossible");
+ }
+ throw new DataViolationException("Can't move project",
+ MOVE_INVALID_TYPES_VIOLATION);
}
- throw new DataViolationException("Can't move task",
- DUPLICATED_TASK_VIOLATION);
+
+ // check duplicated task name
+ if (isSameTaskName(taskToMove, destination.getSubTasks())) {
+ if (log.isDebugEnabled()) {
+ log.debug("Duplicated name, checkMoveTask won't pass");
+ }
+ throw new DataViolationException("Can't move task",
+ DUPLICATED_TASK_VIOLATION);
+ }
}
}
Modified: trunk/src/main/java/org/chorem/jtimer/data/TimerDataManager.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/data/TimerDataManager.java 2009-11-03 09:02:37 UTC (rev 2686)
+++ trunk/src/main/java/org/chorem/jtimer/data/TimerDataManager.java 2009-11-03 10:06:13 UTC (rev 2687)
@@ -21,6 +21,7 @@
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
+import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
@@ -425,36 +426,37 @@
/**
* Move task.
*
- * @param taskToMove task to move
- * @param newParentTask task to move to
+ * @param destination task to move to
+ * @param tasksToMove tasks to move
*/
- public synchronized void moveTask(TimerTask taskToMove,
- TimerTask newParentTask) {
+ public synchronized void moveTask(TimerTask destination, Collection<TimerTask> tasksToMove) {
// fire vetoable event
Iterator<VetoableDataEventListener> itVetoableDataEventListener = vetoableDataEventListeners
.iterator();
while (itVetoableDataEventListener.hasNext()) {
- itVetoableDataEventListener.next().checkMoveTask(taskToMove,
- newParentTask);
+ itVetoableDataEventListener.next().checkMoveTask(destination, tasksToMove);
}
- // send notification (pre)
- Iterator<DataEventListener> itDataEventListener = dataEventListeners
- .iterator();
- while (itDataEventListener.hasNext()) {
- itDataEventListener.next().preMoveTask(taskToMove);
- }
+ for (TimerTask taskToMove : tasksToMove) {
- // move task
- TimerTask actualParent = taskToMove.getParent();
- actualParent.getSubTasks().remove(taskToMove);
- newParentTask.addTask(taskToMove);
+ // send notification (pre)
+ Iterator<DataEventListener> itDataEventListener = dataEventListeners
+ .iterator();
+ while (itDataEventListener.hasNext()) {
+ itDataEventListener.next().preMoveTask(taskToMove);
+ }
- // send notification (post)
- itDataEventListener = dataEventListeners.iterator();
- while (itDataEventListener.hasNext()) {
- itDataEventListener.next().moveTask(taskToMove);
+ // move task
+ TimerTask actualParent = taskToMove.getParent();
+ actualParent.getSubTasks().remove(taskToMove);
+ destination.addTask(taskToMove);
+
+ // send notification (post)
+ itDataEventListener = dataEventListeners.iterator();
+ while (itDataEventListener.hasNext()) {
+ itDataEventListener.next().moveTask(taskToMove);
+ }
}
}
@@ -524,7 +526,7 @@
log.debug("Moving task " + otherTaskSubTask.getName() + " to " + destinationTask.getName());
}
// just move
- moveTask(otherTaskSubTask, destinationTask);
+ moveTask(destinationTask, Collections.singleton(otherTaskSubTask));
}
else {
// task must be merged
Modified: trunk/src/main/java/org/chorem/jtimer/data/VetoableDataEventListener.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/data/VetoableDataEventListener.java 2009-11-03 09:02:37 UTC (rev 2686)
+++ trunk/src/main/java/org/chorem/jtimer/data/VetoableDataEventListener.java 2009-11-03 10:06:13 UTC (rev 2687)
@@ -18,6 +18,7 @@
package org.chorem.jtimer.data;
+import java.util.Collection;
import java.util.Date;
import java.util.EventListener;
import java.util.List;
@@ -106,10 +107,10 @@
/**
* Check move task.
*
- * @param task task to move
- * @param taskToMoveTo task to move to
+ * @param destination task to move to
+ * @param tasksToMove tasks to move
*/
- public void checkMoveTask(TimerTask task, TimerTask taskToMoveTo);
+ public void checkMoveTask(TimerTask destination, Collection<TimerTask> tasksToMove);
/**
* Check merge task.
Modified: trunk/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java 2009-11-03 09:02:37 UTC (rev 2686)
+++ trunk/src/main/java/org/chorem/jtimer/io/GTimerIncrementalSaver.java 2009-11-03 10:06:13 UTC (rev 2687)
@@ -1574,7 +1574,7 @@
* {@inheritDoc}
*/
@Override
- public void checkMoveTask(TimerTask task, TimerTask taskToMoveTo) {
+ public void checkMoveTask(TimerTask destination, Collection<TimerTask> tasksToMove) {
}
Modified: trunk/src/main/java/org/chorem/jtimer/ui/treetable/dnd/TimerTaskTransferHandler.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ui/treetable/dnd/TimerTaskTransferHandler.java 2009-11-03 09:02:37 UTC (rev 2686)
+++ trunk/src/main/java/org/chorem/jtimer/ui/treetable/dnd/TimerTaskTransferHandler.java 2009-11-03 10:06:13 UTC (rev 2687)
@@ -22,6 +22,7 @@
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
+import java.util.Collections;
import java.util.List;
import javax.swing.JComponent;
@@ -177,7 +178,7 @@
TimerTask movedTask = (TimerTask) myObject;
try {
- dataManager.moveTask(movedTask, destinationTask);
+ dataManager.moveTask(destinationTask, Collections.singleton(movedTask));
}
catch(DataViolationException e) {
String title = resourceMap.getString("action.invalidActionTitle");
Modified: trunk/src/main/java/org/chorem/jtimer/ws/xmlrpc/ChoremXMLRPCClient.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/ws/xmlrpc/ChoremXMLRPCClient.java 2009-11-03 09:02:37 UTC (rev 2686)
+++ trunk/src/main/java/org/chorem/jtimer/ws/xmlrpc/ChoremXMLRPCClient.java 2009-11-03 10:06:13 UTC (rev 2687)
@@ -1018,12 +1018,25 @@
* {@inheritDoc}
*/
@Override
- public void checkMoveTask(TimerTask task, TimerTask taskToMoveTo) {
+ public void checkMoveTask(TimerTask destination, Collection<TimerTask> tasksToMove) {
- TimerProject project1 = TimerTaskHelper.getTaskProject(task);
- TimerProject project2 = TimerTaskHelper.getTaskProject(taskToMoveTo);
+ boolean syncProject = false;
+ // destination (single)
+ TimerProject project1 = TimerTaskHelper.getTaskProject(destination);
+ if (project1.isSynchronized()) {
+ syncProject = true;
+ }
- if (project1.isSynchronized() || project2.isSynchronized()) {
+ // sources (multiples)
+ for (TimerTask taskToMove : tasksToMove) {
+ TimerProject project2 = TimerTaskHelper.getTaskProject(taskToMove);
+
+ if (project2.isSynchronized()) {
+ syncProject = true;
+ }
+ }
+
+ if (syncProject) {
if (log.isDebugEnabled()) {
log.debug("Project is synchronized, checkMoveTask won't pass");
}
Modified: trunk/src/main/resources/org/chorem/jtimer/resources/JTimer.properties
===================================================================
--- trunk/src/main/resources/org/chorem/jtimer/resources/JTimer.properties 2009-11-03 09:02:37 UTC (rev 2686)
+++ trunk/src/main/resources/org/chorem/jtimer/resources/JTimer.properties 2009-11-03 10:06:13 UTC (rev 2687)
@@ -139,6 +139,7 @@
vetoable.common.duplicated.project.name=A project already exists with that name at this level !
vetoable.common.duplicated.task.name=A task already exists with that name at this level !
vetoable.common.merge.invalid.types=Can't merge project and task !
+vetoable.common.move.invalid.types=Can't move project !
vetoable.saver.empty.task.name=Empty task name !
vetoable.saver.invalid.task.characters=Task name contains invalid characters !
vetoable.ws.chorem.cant.modify.synchronized.project=Can't do this action on a synchronized project !
Modified: trunk/src/main/resources/org/chorem/jtimer/resources/JTimer_fr.properties
===================================================================
--- trunk/src/main/resources/org/chorem/jtimer/resources/JTimer_fr.properties 2009-11-03 09:02:37 UTC (rev 2686)
+++ trunk/src/main/resources/org/chorem/jtimer/resources/JTimer_fr.properties 2009-11-03 10:06:13 UTC (rev 2687)
@@ -119,6 +119,7 @@
vetoable.common.duplicated.project.name=Un projet avec ce nom existe d\u00E9j\u00E0 \u00E0 ce niveau !
vetoable.common.duplicated.task.name=Une t\u00E2che avec ce nom existe d\u00E9j\u00E0 \u00E0 ce niveau !
vetoable.common.merge.invalid.types=Impossible de fusionner un projet et une t\u00E2che !
+vetoable.common.move.invalid.types=Impossible de d\u00E9placer un projet !
vetoable.saver.empty.name=Le nom est vide !
vetoable.saver.invalid.characters=Le nom contient des caract\u00E8res invalide !
vetoable.ws.chorem.cant.modify.synchronized.project=Impossible d'effectuer cette action sur un projet synchronis\u00E9 !
Added: trunk/src/test/java/org/chorem/jtimer/data/CommonVetoableTest.java
===================================================================
--- trunk/src/test/java/org/chorem/jtimer/data/CommonVetoableTest.java (rev 0)
+++ trunk/src/test/java/org/chorem/jtimer/data/CommonVetoableTest.java 2009-11-03 10:06:13 UTC (rev 2687)
@@ -0,0 +1,155 @@
+/* *##%
+ * Copyright (C) 2009 Code Lutin
+ *
+ * This program 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
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+
+package org.chorem.jtimer.data;
+
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.chorem.jtimer.AbstractJTimerTest;
+import org.chorem.jtimer.entities.TimerProject;
+import org.chorem.jtimer.entities.TimerTask;
+import org.testng.annotations.Test;
+
+/**
+ * Test that all forbidden operation by {@link CommonVetoable} throws
+ * excepted exception.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class CommonVetoableTest extends AbstractJTimerTest {
+
+ /**
+ * Test create with already existing name.
+ */
+ @Test(expectedExceptions = DataViolationException.class)
+ public void testAddProject() {
+ // first load all
+ // and make a move operation
+ TimerCore core = new TimerCore();
+ TimerDataManager dataManager = core.getData();
+
+ //core.init();
+ core.load();
+
+ // add new project
+ TimerProject project = new TimerProject("jTimer");
+ project.setCreationDate(new Date());
+ dataManager.addProject(project);
+ }
+
+ /**
+ * Test create task with already existing name.
+ */
+ @Test(expectedExceptions = DataViolationException.class)
+ public void testAddTask() {
+
+ // first load all
+ // and make a move operation
+ TimerCore core = new TimerCore();
+ TimerDataManager dataManager = core.getData();
+
+ //core.init();
+ core.load();
+ List<TimerProject> projectsBefore = dataManager.getProjectsList();
+ TimerTask task1 = findTask(projectsBefore, "IsisFish/UserInterface");
+
+ // add a new task
+ TimerTask newTask = new TimerTask("Debug");
+ newTask.setCreationDate(new Date());
+ dataManager.addTask(task1, newTask);
+ }
+
+ /**
+ * Test single task move, trying to move projects into tasks.
+ */
+ @Test(expectedExceptions = DataViolationException.class)
+ public void testMoveTask() {
+
+ // first load all
+ // and make a move operation
+ TimerCore core = new TimerCore();
+ TimerDataManager dataManager = core.getData();
+
+ //core.init();
+ core.load();
+ List<TimerProject> projectsBefore = dataManager.getProjectsList();
+ TimerTask task1 = findProject(projectsBefore, "Topia");
+ TimerTask task2 = findTask(projectsBefore, "jTimer/Add workspace support");
+
+ Assert.assertNotNull(task1);
+ Assert.assertNotNull(task2);
+
+ // move task
+ dataManager.moveTask(task2, Collections.singleton(task1));
+ }
+
+ /**
+ * Test single task move, into another task where name already exists.
+ */
+ @Test(expectedExceptions = DataViolationException.class)
+ public void testMoveTask2() {
+
+ // first load all
+ // and make a move operation
+ TimerCore core = new TimerCore();
+ TimerDataManager dataManager = core.getData();
+
+ //core.init();
+ core.load();
+ List<TimerProject> projectsBefore = dataManager.getProjectsList();
+ TimerTask task1 = findTask(projectsBefore, "Chorem/Add webservice");
+ TimerTask task2 = findTask(projectsBefore, "jTimer");
+
+ Assert.assertNotNull(task1);
+ Assert.assertNotNull(task2);
+
+ // rename tank before move
+ // (task jTimer/Add workspace support exists !)
+ dataManager.editTask(task1, "Add workspace support");
+
+ // move task
+ dataManager.moveTask(task2, Collections.singleton(task1));
+ }
+
+ /**
+ * Merge two projects and tasks.
+ */
+ @Test(expectedExceptions = DataViolationException.class)
+ public void testMergeTasks() {
+ // first load all
+ TimerCore core = new TimerCore();
+ TimerDataManager dataManager = core.getData();
+
+ //core.init();
+ core.load();
+ List<TimerProject> projectsBefore = dataManager.getProjectsList();
+ TimerTask task1 = findTask(projectsBefore, "Chorem");
+ TimerTask task2 = findTask(projectsBefore, "jTimer/Unit tests/UI tests");
+
+ // merge tasks
+ dataManager.mergeTasks(task2, Collections.singletonList(task1));
+ }
+}
Property changes on: trunk/src/test/java/org/chorem/jtimer/data/CommonVetoableTest.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Modified: trunk/src/test/java/org/chorem/jtimer/data/TimerDataManagerTest.java
===================================================================
--- trunk/src/test/java/org/chorem/jtimer/data/TimerDataManagerTest.java 2009-11-03 09:02:37 UTC (rev 2686)
+++ trunk/src/test/java/org/chorem/jtimer/data/TimerDataManagerTest.java 2009-11-03 10:06:13 UTC (rev 2687)
@@ -19,8 +19,10 @@
package org.chorem.jtimer.data;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.Date;
+import java.util.HashSet;
import java.util.List;
import org.chorem.jtimer.AbstractJTimerTest;
@@ -257,12 +259,10 @@
}
/**
- * Test move task.
- *
- * A task with subtasks should be valid.
+ * Test single task move.
*/
@Test
- public void testTaskMove() {
+ public void testMoveTask() {
// first load all
// and make a move operation
@@ -281,7 +281,7 @@
Assert.assertNull(task3);
// move task 3 in jTimer/3
- dataManager.moveTask(task2, task1);
+ dataManager.moveTask(task1, Collections.singleton(task2));
core.exit();
// second reload
@@ -297,7 +297,61 @@
Assert.assertNull(task2a);
Assert.assertNotNull(task3a);
}
+
+ /**
+ * Test multiples tasks move.
+ */
+ @Test
+ public void testMoveMultiplesTasks() {
+ // first load all
+ // and make a move operation
+ TimerCore core = new TimerCore();
+ TimerDataManager dataManager = core.getData();
+
+ //core.init();
+ core.load();
+ List<TimerProject> projectsBefore = dataManager.getProjectsList();
+ TimerProject project1 = findProject(projectsBefore, "Chorem");
+ TimerTask task1 = findTask(projectsBefore, "jTimer/Add workspace support");
+ TimerTask task2 = findTask(projectsBefore, "jTimer/Interact with chorem services");
+ TimerTask task3 = findTask(projectsBefore, "jTimer/Refactoring");
+ TimerTask task4 = findTask(projectsBefore, "jTimer/Unit tests");
+
+ Assert.assertNotNull(project1);
+ Assert.assertNotNull(task1);
+ Assert.assertNotNull(task2);
+ Assert.assertNotNull(task3);
+ Assert.assertNotNull(task4);
+
+ Collection<TimerTask> tasksToMove = new HashSet<TimerTask>();
+ tasksToMove.add(task1);
+ tasksToMove.add(task2);
+ tasksToMove.add(task3);
+ tasksToMove.add(task4);
+
+ // move task 3 in jTimer/3
+ dataManager.moveTask(project1, tasksToMove);
+ core.exit();
+
+ // second reload
+ // and test reloaded data
+ //core.init();
+ core.load();
+ List<TimerProject> projectsAfter = dataManager.getProjectsList();
+ TimerTask task1a = findTask(projectsAfter, "Chorem/Add workspace support");
+ TimerTask task2a = findTask(projectsAfter, "Chorem/Interact with chorem services");
+ TimerTask task3a = findTask(projectsAfter, "Chorem/Refactoring");
+ TimerTask task4a = findTask(projectsAfter, "Chorem/Unit tests");
+ TimerProject project1a = findProject(projectsBefore, "jTimer");
+
+ Assert.assertNotNull(task1a);
+ Assert.assertNotNull(task2a);
+ Assert.assertNotNull(task3a);
+ Assert.assertNotNull(task4a);
+ Assert.assertEquals(0, project1a.getSubTasks().size());
+ }
+
/*
* Merge two project together.
*
1
0
03 Nov '09
Author: echatellier
Date: 2009-11-03 10:02:37 +0100 (Tue, 03 Nov 2009)
New Revision: 2686
Modified:
trunk/src/main/java/org/chorem/jtimer/data/TimerDataManager.java
Log:
Add javadoc
Modified: trunk/src/main/java/org/chorem/jtimer/data/TimerDataManager.java
===================================================================
--- trunk/src/main/java/org/chorem/jtimer/data/TimerDataManager.java 2009-11-03 09:02:26 UTC (rev 2685)
+++ trunk/src/main/java/org/chorem/jtimer/data/TimerDataManager.java 2009-11-03 09:02:37 UTC (rev 2686)
@@ -603,7 +603,9 @@
}
/**
- * @param task
+ * Notify alert modification.
+ *
+ * @param task task where alert has been modified
*/
public synchronized void modifyAlert(TimerTask task) {
@@ -613,6 +615,6 @@
while (itDataEventListener.hasNext()) {
itDataEventListener.next().modifyTask(task);
}
-
+
}
}
1
0