use of org.pentaho.gwt.widgets.client.filechooser.RepositoryFile in project pentaho-platform by pentaho.
the class SolutionTree method buildSolutionTree.
private void buildSolutionTree(FileTreeItem parentTreeItem, RepositoryFileTree repositoryFileTree) {
List<RepositoryFileTree> children = repositoryFileTree.getChildren();
// BISERVER-9599 - Custom Sort
Collections.sort(children, new Comparator<RepositoryFileTree>() {
@Override
public int compare(RepositoryFileTree repositoryFileTree, RepositoryFileTree repositoryFileTree2) {
return (new TreeItemComparator()).compare(repositoryFileTree.getFile().getTitle(), repositoryFileTree2.getFile().getTitle());
}
});
for (RepositoryFileTree treeItem : children) {
RepositoryFile file = treeItem.getFile();
boolean isDirectory = file.isFolder();
String fileName = file.getName();
if ((!file.isHidden() || isShowHiddenFiles()) && !StringUtils.isEmpty(fileName)) {
// TODO Mapping Title to LocalizedName
String localizedName = file.getTitle();
String description = file.getDescription();
FileTreeItem childTreeItem = new FileTreeItem();
childTreeItem.setStylePrimaryName("leaf-widget");
// $NON-NLS-1$
childTreeItem.getElement().setAttribute("id", file.getPath());
childTreeItem.setUserObject(treeItem);
childTreeItem.setRepositoryFile(file);
if (file.isHidden() && file.isFolder()) {
childTreeItem.addStyleDependentName("hidden");
}
if (treeItem != null && treeItem.getChildren() != null) {
for (RepositoryFileTree childItem : treeItem.getChildren()) {
if (childItem.getFile().isFolder()) {
childTreeItem.addStyleName("parent-widget");
break;
}
}
}
ElementUtils.killAllTextSelection(childTreeItem.getElement());
childTreeItem.setURL(fileName);
if (showLocalizedFileNames) {
childTreeItem.setText(localizedName);
if (isUseDescriptionsForTooltip() && !StringUtils.isEmpty(description)) {
childTreeItem.setTitle(description);
} else {
childTreeItem.setTitle(fileName);
}
} else {
childTreeItem.setText(fileName);
if (isUseDescriptionsForTooltip() && !StringUtils.isEmpty(description)) {
childTreeItem.setTitle(description);
} else {
childTreeItem.setTitle(localizedName);
}
}
childTreeItem.setFileName(fileName);
if (parentTreeItem == null && isDirectory) {
addItem(childTreeItem);
} else if (parentTreeItem != null) {
parentTreeItem.addItem(childTreeItem);
}
FileTreeItem tmpParent = childTreeItem;
String pathToChild = tmpParent.getFileName();
while (tmpParent.getParentItem() != null) {
tmpParent = (FileTreeItem) tmpParent.getParentItem();
// $NON-NLS-1$
pathToChild = tmpParent.getFileName() + "/" + pathToChild;
}
/*
* TODO Not sure what to do here if (parentTreeItem != null) { ArrayList<FileChooserRepositoryFile> files =
* (ArrayList<FileChooserRepositoryFile>) parentTreeItem.getUserObject(); if (files == null) { files = new
* ArrayList<FileChooserRepositoryFile>(); parentTreeItem.setUserObject(files); } files.add(file); }
*/
if (isDirectory) {
buildSolutionTree(childTreeItem, treeItem);
} else {
if (parentTreeItem != null) {
parentTreeItem.removeItem(childTreeItem);
}
}
}
}
}
use of org.pentaho.gwt.widgets.client.filechooser.RepositoryFile in project pentaho-platform by pentaho.
the class RepositoryFileUtils method convertToRepositoryFileTree.
public static RepositoryFileTree convertToRepositoryFileTree(RepositoryFileTreeDto tree) {
RepositoryFileTree fileTree = new RepositoryFileTree();
List<RepositoryFileTree> fileList = new ArrayList<RepositoryFileTree>();
RepositoryFile file = convertToRepositoryFile(tree.getFile());
fileTree.setFile(file);
for (RepositoryFileTreeDto treeItem : tree.getChildren()) {
fileList.add(convertToRepositoryFileTree(treeItem));
}
fileTree.setChildren(fileList);
return fileTree;
}
use of org.pentaho.gwt.widgets.client.filechooser.RepositoryFile in project pentaho-platform by pentaho.
the class RepositoryFileUtils method convertToRepositoryFile.
public static RepositoryFile convertToRepositoryFile(RepositoryFileDto file) {
RepositoryFile repositoryFile = new RepositoryFile();
repositoryFile.setCreatedDate(file.getCreatedDate());
repositoryFile.setDeletedDate(file.getDeletedDate());
repositoryFile.setDescription(file.getDescription());
repositoryFile.setFolder(file.isFolder());
repositoryFile.setHidden(file.isHidden());
repositoryFile.setId(file.getId());
repositoryFile.setLastModifiedDate(file.getLastModifiedDate());
repositoryFile.setLocale(file.getLocale());
repositoryFile.setLockDate(file.getLockDate());
repositoryFile.setLocked(file.isLocked());
repositoryFile.setLockMessage(file.getLockMessage());
repositoryFile.setLockOwner(file.getLockOwner());
repositoryFile.setName(file.getName());
repositoryFile.setOriginalParentFolderId(file.getOriginalParentFolderPath());
repositoryFile.setOriginalParentFolderPath(file.getOriginalParentFolderPath());
repositoryFile.setOwner(file.getOwner());
repositoryFile.setPath(file.getPath());
repositoryFile.setTitle(file.getTitle());
repositoryFile.setVersionId(file.getVersionId());
return repositoryFile;
}
use of org.pentaho.gwt.widgets.client.filechooser.RepositoryFile in project pentaho-platform by pentaho.
the class AbstractFilePropertiesCommand method performOperation.
public void performOperation() {
final SolutionFileActionEvent event = new SolutionFileActionEvent();
event.setAction(this.getClass().getName());
if (getRepositoryFile() != null) {
final RepositoryFile item = getRepositoryFile();
// Checking if the user has access to manage permissions
String url = contextURL + "api/repo/files/" + SolutionBrowserPanel.pathToId(item.getPath()) + "/canAccess?permissions=" + // $NON-NLS-1$ //$NON-NLS-2$
MANAGE_ACLS;
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
try {
builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
builder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
FilePropertiesDialog dialog = new FilePropertiesDialog(item, new PentahoTabPanel(), null, getActiveTab(), false);
dialog.showTab(getActiveTab());
dialog.center();
event.setMessage(exception.getMessage());
EventBusUtil.EVENT_BUS.fireEvent(event);
}
public void onResponseReceived(Request request, Response response) {
FilePropertiesDialog dialog = new FilePropertiesDialog(item, new PentahoTabPanel(), null, getActiveTab(), Boolean.parseBoolean(response.getText()));
dialog.showTab(getActiveTab());
dialog.center();
event.setMessage("Success");
EventBusUtil.EVENT_BUS.fireEvent(event);
}
});
} catch (RequestException e) {
FilePropertiesDialog dialog = new FilePropertiesDialog(item, new PentahoTabPanel(), null, getActiveTab(), false);
dialog.showTab(getActiveTab());
dialog.center();
event.setMessage(e.getMessage());
EventBusUtil.EVENT_BUS.fireEvent(event);
}
}
}
use of org.pentaho.gwt.widgets.client.filechooser.RepositoryFile in project pentaho-platform by pentaho.
the class SolutionTree method onFetchRepositoryFileTree.
public void onFetchRepositoryFileTree(RepositoryFileTree fileTree, List<RepositoryFile> repositoryTrashItems) {
if (fileTree == null) {
WaitPopup.getInstance().setVisible(false);
return;
}
repositoryFileTree = fileTree;
trashItems = repositoryTrashItems;
// remember selectedItem, so we can reselect it after the tree is loaded
clear();
// get document root item
RepositoryFile rootRepositoryFile = repositoryFileTree.getFile();
if (!rootRepositoryFile.isHidden() || isShowHiddenFiles()) {
FileTreeItem rootItem = null;
if (createRootNode) {
rootItem = new FileTreeItem();
rootItem.setText(rootRepositoryFile.getPath());
rootItem.setTitle(rootRepositoryFile.getPath());
rootItem.getElement().setId(rootRepositoryFile.getPath());
// added so we can traverse the true names
// $NON-NLS-1$
rootItem.setFileName("/");
rootItem.setRepositoryFile(rootRepositoryFile);
addItem(rootItem);
buildSolutionTree(rootItem, repositoryFileTree);
} else {
buildSolutionTree(null, repositoryFileTree);
// sort the root elements
ArrayList<TreeItem> roots = new ArrayList<TreeItem>();
for (int i = 0; i < getItemCount(); i++) {
roots.add(getItem(i));
}
// BISERVER-9599 - Custom Sort
Collections.sort(roots, new TreeItemComparator());
clear();
for (TreeItem myRootItem : roots) {
addItem(myRootItem);
}
}
}
fixLeafNodes();
if (selectedPath != null) {
select(selectedPath);
} else if (selectedItem != null) {
ArrayList<TreeItem> parents = new ArrayList<TreeItem>();
while (selectedItem != null) {
parents.add(selectedItem);
selectedItem = selectedItem.getParentItem();
}
Collections.reverse(parents);
selectFromList(parents);
} else {
for (int i = 0; i < getItemCount(); i++) {
getItem(i).setState(true);
}
}
WaitPopup.getInstance().setVisible(false);
}
Aggregations