BrightSide Workbench Full Report + Source Code
SyncTask.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.turro.wd.tree;
19 
20 import java.text.ParseException;
21 import org.apache.pivot.wtk.TreeView;
22 import org.turro.wd.files.WorkFile;
23 
28 public class SyncTask extends DefaultTask {
29 
30  private String commentCommit, commentUpdate;
31  private int updateAction, commitAction;
32 
33  public static final int
35  UPDATE_UPDATE = 1,
36  UPDATE_UPDATE_FOR_EDITING = 2,
37  COMMIT_DO_NOTHING = 0,
38  COMMIT_UNLOCK_ALL = 1,
39  COMMIT_KEEP_LOCK = 2,
40  COMMIT_UNLOCK = 3;
41 
42  public SyncTask(TreeView treeView, String caption,
43  String commentCommit, int commitAction,
44  String commentUpdate, int updateAction) {
45  super(treeView, caption);
46  this.commentCommit = commentCommit;
47  this.commitAction = commitAction;
48  this.commentUpdate = commentUpdate;
49  this.updateAction = updateAction;
50  }
51 
52  @Override
53  protected String done() {
54  return "Done sync!";
55  }
56 
57  @Override
58  protected String failed() {
59  return "Failed!";
60  }
61 
62  @Override
63  protected void process(TreeDirectory dir) throws ParseException {
64  }
65 
66  @Override
67  protected void process(TreeWorkFile file) throws ParseException {
68  WorkFile wf = file.getWorkFile();
69  if(wf.isUploadable()) {
70  wf.doUpload(commentCommit, commitAction);
71  } else if(wf.isDownloadable() || (updateAction == UPDATE_UPDATE_FOR_EDITING)) {
72  wf.doDownload(updateAction);
73  } else if(wf.isServerLocked() && commitAction == COMMIT_UNLOCK_ALL) {
74  wf.doUnlock();
75  }
76  }
77 
78 }
void doDownload(int updateAction)
Definition: WorkFile.java:196
void doUpload(String comment, int commitAction)
Definition: WorkFile.java:173
void process(TreeDirectory dir)
Definition: SyncTask.java:63
static final int UPDATE_DO_NOTHING
Definition: SyncTask.java:34
void process(TreeWorkFile file)
Definition: SyncTask.java:67
SyncTask(TreeView treeView, String caption, String commentCommit, int commitAction, String commentUpdate, int updateAction)
Definition: SyncTask.java:42