View Javadoc
1   /***
2    * Copyright (C) 2008 Jeremy Thomerson (jthomerson@users.sourceforge.net)
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *         http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package net.sf.vcaperture.web;
18  
19  import net.sf.vcaperture.model.AbstractRepository;
20  import net.sf.vcaperture.web.models.RepoAndPathContext;
21  import net.sf.vcaperture.web.panels.FilesPanel;
22  import net.sf.vcaperture.web.panels.LineHistoryPanel;
23  import net.sf.vcaperture.web.panels.RecentChangelogPanel;
24  import net.sf.vcaperture.web.panels.SubdirectoriesPanel;
25  
26  import org.apache.wicket.markup.html.basic.Label;
27  import org.apache.wicket.model.IModel;
28  import org.apache.wicket.model.LoadableDetachableModel;
29  import org.apache.wicket.model.PropertyModel;
30  
31  /***
32   * Homepage for VC Aperture web application.
33   * 
34   * @author Jeremy Thomerson (jthomerson@users.sourceforge.net)
35   */
36  public class BasicDirectoryViewPage extends ApertureBasePage {
37  
38  	private static final long serialVersionUID = 1L;
39  
40  	private final String mPath;
41  	/***
42  	 * @param pathModel The model that contains the path to the directory to be browsed.
43  	 */
44  	public BasicDirectoryViewPage(IModel/*<AbstractRepository>*/ repoModel, String path) {
45  		super(repoModel);
46  		mPath = path;
47  		constructComponentHierarchy();
48  	}
49  
50      protected void constructComponentHierarchy() {
51  	    add(new Label("path", mPath));
52  	    add(new Label("repo", new PropertyModel(getModel(), "name")));
53  	    IModel model = new LoadableDetachableModel() {
54              private static final long serialVersionUID = 1L;
55  
56  			@Override
57  	    	protected Object load() {
58  	    	    return new RepoAndPathContext((AbstractRepository) BasicDirectoryViewPage.this.getModelObject(), BasicDirectoryViewPage.this.getRelativePath());
59  	    	}
60  	    };
61  	    add(new LineHistoryPanel("lineHistory", model));
62  	    add(new SubdirectoriesPanel("subdirectories", model));
63  	    add(new RecentChangelogPanel("recentChangelog", model));
64  	    add(new FilesPanel("files", model));
65      }
66  
67  	public String getDirectoryPath() {
68  		return mPath;
69  	}
70  	
71  	@Override
72  	public String getProject() {
73  	    return ((AbstractRepository) getModelObject()).getName();
74  	}
75  	
76  	@Override
77  	public String getRelativePath() {
78  	    return getDirectoryPath();
79  	}
80  }