monotone

monotone Commit Details

Date:2005-04-02 16:08:06 (14 years 2 months ago)
Author:jcrisp@s-r-s.co.uk
Branch:net.venge.monotone.contrib, net.venge.monotone.contrib.monotree
Commit:8a121346ce2920b6f85df68b3b620de96bd14a8d
Parents: 4a8fcc7359009e45bd576c86a444cf205f0ede0f
Message:Miscellaneous cleanup of GUI actions

Changes:
Mcontrib/monotree/GXLViewer.java (7 diffs)
Mcontrib/monotree/Makefile (2 diffs)

File differences

contrib/monotree/GXLViewer.java
219219
220220
221221
222
222223
223224
224225
......
239240
240241
241242
243
244
245
246
247
248
242249
243
244250
251
245252
253
246254
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
255
256
267257
268258
269259
......
284274
285275
286276
287
288277
289278
290279
......
293282
294283
295284
296
297
298
299
300
285
301286
302287
303
288
289
290
291
292
293
294
304295
305296
306297
307298
308299
309
300
310301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
311348
312349
313350
314351
315
352
316353
317354
318355
......
325362
326363
327364
365
366
367
368
369
370
371
372
328373
329374
330375
......
347392
348393
349394
395
396
397
350398
351399
352
400
353401
354402
355403
......
357405
358406
359407
408
360409
361410
362411
JSplitPane splitter=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,new JScrollPane(tree),new JSVGScrollPane(svgCanvas));
panel.add("North", p);
panel.add("Center",splitter);
splitter.setDividerLocation(200);
JLabel help=new JLabel();
panel.add("South",help);
help.setText("C-LMB = drag zoom, S-RMB = move zoom, S-LMB = pan, C-S-RMB = reset");
tree.addTreeSelectionListener(new TreeSelectionListener() {
/**
* Listen for selection changes on the tree and if a head revision is selected
* draw the ancestor graph for it
*
* @param e the tree selection event from the branch tree
*/
public void valueChanged(TreeSelectionEvent e) {
if(progress!=null) return; // another job in progress
Object node=e.getPath().getLastPathComponent();
// Check that our selection is a leaf node (all heads are leaf nodes) and ignore if not
if(!((DefaultMutableTreeNode)node).isLeaf()) return;
// Extract the id from the leaf node (should really use a proper user object for this!)
final String id=node.toString().substring(0,node.toString().indexOf(' ')-1);
new Thread(new Runnable() { public void run() {
try {
//if(e.getPaths().length==1) return; // Root node.
logger.fine("Getting log for "+id);
label.setText("Reading log...");
final InputStream svgStream=database.getSVGLog(id);
SAXSVGDocumentFactory factory=new SAXSVGDocumentFactory(XMLResourceDescriptor.getXMLParserClassName());
SVGDocument doc=factory.createSVGDocument("http://local",svgStream);
svgCanvas.setSVGDocument(doc);
svgCanvas.setDocumentState(JSVGComponent.ALWAYS_DYNAMIC);
svgCanvas.setEnableZoomInteractor(true);
InputMap keys=svgCanvas.getInputMap();
keys.put(KeyStroke.getKeyStroke("="),JSVGCanvas.ZOOM_IN_ACTION);
keys.put(KeyStroke.getKeyStroke("-"),JSVGCanvas.ZOOM_OUT_ACTION);
svgCanvas.setInputMap(JComponent.WHEN_FOCUSED,keys);
} catch (IOException ex) {
ex.printStackTrace();
}
}}).start();
label.setText("Reading log...");
new DisplayLog(GXLViewer.this,id);
setProgressWindow("Reading log for revision");
}
});
}
public void gvtBuildCompleted(GVTTreeBuilderEvent e) {
label.setText("Build Done.");
// frame.pack();
}
});
label.setText("Rendering Started...");
}
public void gvtRenderingCompleted(GVTTreeRendererEvent e) {
label.setText("");
svgCanvas.requestFocusInWindow();
progress.setVisible(false);
progress.dispose();
progress=null;
finishJob("");
}
});
svgCanvas.setEnableZoomInteractor(true);
InputMap keys=svgCanvas.getInputMap();
keys.put(KeyStroke.getKeyStroke("="),JSVGCanvas.ZOOM_IN_ACTION);
keys.put(KeyStroke.getKeyStroke("-"),JSVGCanvas.ZOOM_OUT_ACTION);
svgCanvas.setInputMap(JComponent.WHEN_FOCUSED,keys);
button.setEnabled(true);
return panel;
}
/**
* Background thread to read the branche list from a monotone datababase
* Background thread to read the log for a revision and display the ancestry graph in SVG
*/
class DisplayLog extends Thread {
/**
* The revision id for which the ancestor graph should be drawn
*/
private final String id;
/**
* The parent viewer for this thread
*/
private final GXLViewer parent;
/**
* Create and start a new background thread to read the log for a revision
* and display the ancestry graph in SVG
*
* @param parent the parent viewer to populate
* @param id the revision identifier for which the ancestor graph should be drawn
*/
public DisplayLog(final GXLViewer parent,final String id) {
this.parent=parent;
this.id=id;
start();
}
/**
* Thread to read the log for a revision and display the ancestry graph in SVG
*/
public void run() {
try {
logger.fine("Getting log for "+id);
final InputStream svgStream=database.getSVGLog(id);
SAXSVGDocumentFactory factory=new SAXSVGDocumentFactory(XMLResourceDescriptor.getXMLParserClassName());
final SVGDocument doc=factory.createSVGDocument("http://local",svgStream);
SwingUtilities.invokeLater(new Runnable() { public void run() {
svgCanvas.setSVGDocument(doc);
svgCanvas.setDocumentState(JSVGComponent.ALWAYS_DYNAMIC);
}});
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
/**
* Background thread to read the branch list from a monotone datababase
*/
class ReadBranches extends Thread {
/**
* The parent viewer for this thread
*/
final GXLViewer parent;
private final GXLViewer parent;
/**
* Create and start a new thread to read the branches from the specified viewer's database in the background
start();
}
/**
* Recurse down from the root of the tree building nodes for each fragment in the branch name
* unless the node already exists. Fragments are separated by '.'
*
* @param root the root of the tree
* @param branch the name of the branch
* @return the terminal node representing the full branch name
*/
private DefaultMutableTreeNode buildTree(DefaultMutableTreeNode root,String branch) {
String[] path=branch.split("\\.");
DefaultMutableTreeNode currentNode=root;
return currentNode;
}
/**
* Thread to build a tree from the branches in the database
*/
public void run() {
Monotone database=parent.getDatabase();
DefaultMutableTreeNode root=new DefaultMutableTreeNode("Monotone "+database.getName());
DefaultMutableTreeNode root=new DefaultMutableTreeNode("Monotone: "+database.getName());
try {
logger.fine("Reading branches...");
List<String> branches=database.listBranches();
logger.finest(branch);
DefaultMutableTreeNode node=buildTree(root,branch);
// Now create leaf nodes for each head in the monotone branch
try {
List<String>heads=database.listHeads(branch);
for(String head: heads) {
contrib/monotree/Makefile
33
44
55
6
6
77
88
99
......
1111
1212
1313
14
14
1515
1616
1717
all: monotree.jar
monotree.jar: Log2Gxl.class Monotone.class GXLViewer.class META-INF/MANIFEST.MF
jar cvmf META-INF/MANIFEST.MF monotree.jar Log2Gxl.class Monotone.class GXLViewer.class GXLViewer\$$1.class GXLViewer\$$2.class GXLViewer\$$3.class GXLViewer\$$4.class GXLViewer\$$5.class GXLViewer\$$6.class Monotone\$$ErrorReader.class Monotone\$$StreamCopier.class GXLViewer\$$3\$$1.class GXLViewer\$$ReadBranches.class GXLViewer\$$MonotoneFileFilter.class GXLViewer\$$ReadBranches\$$1.class
jar cvmf META-INF/MANIFEST.MF monotree.jar Log2Gxl.class Monotone.class GXLViewer.class GXLViewer\$$1.class GXLViewer\$$2.class GXLViewer\$$3.class GXLViewer\$$4.class GXLViewer\$$5.class GXLViewer\$$6.class Monotone\$$ErrorReader.class Monotone\$$StreamCopier.class GXLViewer\$$ReadBranches.class GXLViewer\$$MonotoneFileFilter.class GXLViewer\$$ReadBranches\$$1.class GXLViewer\$$DisplayLog.class GXLViewer\$$DisplayLog\$$1.class
Log2Gxl.class: Log2Gxl.java
javac -g -classpath "gxl/gxl-0.92/gxl.jar;." Log2Gxl.java
Monotone.class Monotone$$ErrorReader.class Monotone$$StreamCopier.class: Monotone.java Log2Gxl.class
javac -g Monotone.java
GXLViewer$$ReadBranches.class GXLViewer$$2$$1.class GXLViewer$$3$$1.class GXLViewer$$1.class GXLViewer$$2.class GXLViewer$$3.class GXLViewer$$4.class GXLViewer$$5 GXLViewer$$6 GXLViewer.class GXLViewer$$MonotoneFileFilter.class GXLViewer$$ReadBranches$$1.class : GXLViewer.java Monotone.class
GXLViewer$$ReadBranches.class GXLViewer$$2$$1.class GXLViewer$$DisplayLog.class GXLViewer$$1.class GXLViewer$$2.class GXLViewer$$3.class GXLViewer$$4.class GXLViewer$$5 GXLViewer$$6 GXLViewer.class GXLViewer$$MonotoneFileFilter.class GXLViewer$$ReadBranches$$1.class GXLViewer$$DisplayLog$$1.class: GXLViewer.java Monotone.class
javac -g -classpath "batik/batik-1.5.1/batik.jar;." GXLViewer.java
clean:

Archive Download the corresponding diff file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status