use of org.pentaho.gwt.widgets.client.filechooser.RepositoryFileTree in project pentaho-platform by pentaho.
the class FolderCommand method execute.
public void execute() {
if (popupMenu != null) {
popupMenu.hide();
}
SolutionBrowserPanel sbp = SolutionBrowserPanel.getInstance();
if (mode == COMMAND.PROPERTIES) {
new FilePropertiesCommand(repositoryFile).execute();
} else if (mode == COMMAND.DELETE) {
TreeItem item = sbp.getSolutionTree().getSelectedItem();
RepositoryFileTree tree = (RepositoryFileTree) item.getUserObject();
new DeleteFolderCommand(tree.getFile()).execute();
} else if (mode == COMMAND.CREATE_FOLDER) {
TreeItem item = sbp.getSolutionTree().getSelectedItem();
RepositoryFileTree tree = (RepositoryFileTree) item.getUserObject();
new NewFolderCommand(tree.getFile()).execute();
} else if (mode == COMMAND.EXPORT) {
new ExportFileCommand(repositoryFile).execute();
} else if (mode == COMMAND.IMPORT) {
new ImportFileCommand(repositoryFile).execute();
} else if (mode == COMMAND.PASTE) {
new PasteFilesCommand().execute();
} else if (mode == COMMAND.EMPTY_TRASH) {
new DeletePermanentFileCommand().execute();
}
}
use of org.pentaho.gwt.widgets.client.filechooser.RepositoryFileTree in project pentaho-platform by pentaho.
the class RepositoryFileTreeManager method fetchRepositoryFileTree.
public void fetchRepositoryFileTree(final AsyncCallback<RepositoryFileTree> callback, Integer depth, String filter, Boolean showHidden) {
// notify listeners that we are about to talk to the server (in case there's anything they want to do
// such as busy cursor or tree loading indicators)
beforeFetchRepositoryFileTree();
RequestBuilder builder = null;
// $NON-NLS-1$
String url = GWT.getHostPageBaseURL() + "api/repo/files/:/tree?";
if (depth == null) {
depth = -1;
}
if (filter == null) {
// $NON-NLS-1$
filter = "*";
}
if (showHidden == null) {
showHidden = Boolean.FALSE;
}
url = url + "depth=" + depth + "&filter=" + filter + "&showHidden=" + showHidden + "&ts=" + // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
System.currentTimeMillis();
builder = new RequestBuilder(RequestBuilder.GET, url);
builder.setHeader("Accept", "application/json");
builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
RequestCallback innerCallback = new RequestCallback() {
public void onError(Request request, Throwable exception) {
Window.alert(exception.toString());
}
public void onResponseReceived(Request request, Response response) {
if (response.getStatusCode() == Response.SC_OK) {
String json = response.getText();
System.out.println(json);
final JsonToRepositoryFileTreeConverter converter = new JsonToRepositoryFileTreeConverter(response.getText());
fileTree = converter.getTree();
String deletedFilesUrl = GWT.getHostPageBaseURL() + "api/repo/files/deleted?ts=" + System.currentTimeMillis();
RequestBuilder deletedFilesRequestBuilder = new RequestBuilder(RequestBuilder.GET, deletedFilesUrl);
deletedFilesRequestBuilder.setHeader("Accept", "application/json");
deletedFilesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
try {
deletedFilesRequestBuilder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
fireRepositoryFileTreeFetched();
Window.alert(exception.toString());
}
public void onResponseReceived(Request delRequest, Response delResponse) {
if (delResponse.getStatusCode() == Response.SC_OK) {
try {
trashItems = JsonToRepositoryFileTreeConverter.getTrashFiles(delResponse.getText());
} catch (Throwable t) {
// apparently this happens when you have no trash
}
fireRepositoryFileTreeFetched();
} else {
fireRepositoryFileTreeFetched();
}
}
});
} catch (Exception e) {
fireRepositoryFileTreeFetched();
}
if (callback != null) {
callback.onSuccess(fileTree);
}
} else {
fileTree = new RepositoryFileTree();
RepositoryFile errorFile = new RepositoryFile();
errorFile.setFolder(true);
errorFile.setName("!ERROR!");
fileTree.setFile(errorFile);
}
}
};
try {
builder.sendRequest(null, innerCallback);
} catch (RequestException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of org.pentaho.gwt.widgets.client.filechooser.RepositoryFileTree 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.RepositoryFileTree in project pentaho-platform by pentaho.
the class RepositoryFileUtils method convertFromRepositoryFileTree.
public static RepositoryFileTreeDto convertFromRepositoryFileTree(RepositoryFileTree tree) {
RepositoryFileTreeDto fileTreeDto = new RepositoryFileTreeDto();
List<RepositoryFileTreeDto> fileList = new ArrayList<RepositoryFileTreeDto>();
RepositoryFileDto file = convertFromRepositoryFile(tree.getFile());
fileTreeDto.setFile(file);
for (RepositoryFileTree treeItem : tree.getChildren()) {
fileList.add(convertFromRepositoryFileTree(treeItem));
}
fileTreeDto.setChildren(fileList);
return fileTreeDto;
}
use of org.pentaho.gwt.widgets.client.filechooser.RepositoryFileTree 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;
}
Aggregations