/* license-start
*
* Copyright (C) 2008 - 2013 Crispico, <http://www.crispico.com/>.
*
* 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 version 3.
*
* 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, at <http://www.gnu.org/licenses/>.
*
* Contributors:
* Crispico - Initial API and implementation
*
* license-end
*/
package org.flowerplatform.web.git.explorer;
import java.io.File;
import java.util.List;
import org.eclipse.jgit.lib.Repository;
import org.flowerplatform.communication.stateful_service.StatefulServiceInvocationContext;
import org.flowerplatform.communication.tree.GenericTreeContext;
import org.flowerplatform.communication.tree.INodeDataProvider;
import org.flowerplatform.communication.tree.remote.PathFragment;
import org.flowerplatform.communication.tree.remote.TreeNode;
import org.flowerplatform.web.git.GitPlugin;
/**
* @author Cristina Constantienscu
*/
public class RepositoryNodeDataProvider implements INodeDataProvider {
public static final String REPOSITORY_KEY = "gitRepository";
@Override
public boolean populateTreeNode(Object source, TreeNode destination, GenericTreeContext context) {
Repository repository = (Repository) source;
destination.setLabel(repository.getDirectory().getParentFile().getParentFile().getName());
destination.setIcon(GitPlugin.getInstance().getResourceUrl("images/full/obj16/repository_rep.gif"));
return true;
}
@Override
public PathFragment getPathFragmentForNode(Object node, String nodeType, GenericTreeContext context) {
Repository repository = (Repository) node;
File mainRepoFile = repository.getDirectory().getParentFile();
return new PathFragment(mainRepoFile.getParentFile().getName(), nodeType);
}
@Override
public String getLabelForLog(Object node, String nodeType) {
Repository repository = (Repository) node;
return repository.getDirectory().getParentFile().getParentFile().getName();
}
@Override
public String getInplaceEditorText(StatefulServiceInvocationContext context, List<PathFragment> fullPath) {
throw new UnsupportedOperationException();
}
@Override
public boolean setInplaceEditorText(StatefulServiceInvocationContext context, List<PathFragment> path, String text) {
throw new UnsupportedOperationException();
}
}