use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory in project pentaho-kettle by pentaho.
the class BrowseController method init.
// end PDI-3326 hack
@SuppressWarnings("deprecation")
public void init(Repository repository) throws ControllerInitializationException {
try {
this.repository = repository;
mainController = (MainController) this.getXulDomContainer().getEventHandler("mainController");
RepositoryDirectoryInterface root;
try {
if (repository instanceof RepositoryExtended) {
root = ((RepositoryExtended) repository).loadRepositoryDirectoryTree("/", "*.ktr|*.kjb", -1, BooleanUtils.isTrue(repository.getUserInfo().isAdmin()), true, true);
} else {
root = repository.loadRepositoryDirectoryTree();
}
this.repositoryDirectory = UIObjectRegistry.getInstance().constructUIRepositoryDirectory(root, null, repository);
} catch (UIObjectCreationException uoe) {
this.repositoryDirectory = new UIRepositoryDirectory(repository.loadRepositoryDirectoryTree(), null, repository);
}
dirMap = new HashMap<ObjectId, UIRepositoryDirectory>();
populateDirMap(repositoryDirectory);
bf = new SwtBindingFactory();
bf.setDocument(this.getXulDomContainer().getDocumentRoot());
messageBox = (XulMessageBox) document.createElement("messagebox");
createBindings();
} catch (Exception e) {
throw new ControllerInitializationException(e);
}
}
use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory in project pentaho-kettle by pentaho.
the class BrowseController method openContent.
public void openContent(Object[] items) {
if ((items != null) && (items.length > 0)) {
for (Object o : items) {
if (o instanceof UIRepositoryDirectory) {
((UIRepositoryDirectory) o).toggleExpanded();
List<Object> selectedFolder = new ArrayList<Object>();
selectedFolder.add(o);
folderTree.setSelectedItems(selectedFolder);
} else if ((mainController != null && mainController.getCallback() != null) && (o instanceof UIRepositoryContent)) {
try {
mainController.getCallback().open((UIRepositoryContent) o, null);
} catch (Exception e) {
mainController.handleLostRepository(e);
}
// TODO: fire request to close dialog
}
}
}
}
use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory in project pentaho-kettle by pentaho.
the class BrowseController method deleteContent.
public void deleteContent() throws Exception {
for (Object object : fileTable.getSelectedItems()) {
if (object instanceof UIRepositoryObject) {
final UIRepositoryObject repoObject = (UIRepositoryObject) object;
Callable<Void> deleteCallable = new Callable<Void>() {
@Override
public Void call() throws Exception {
deleteContent(repoObject);
return null;
}
};
// otherwise we will end this method call
if (repoObject instanceof UIRepositoryDirectory) {
confirm("BrowseController.DeleteNonEmptyFolderWarningTitle", "BrowseController.DeleteFolderWarningMessage", deleteCallable);
} else {
confirm("BrowseController.DeleteFileWarningTitle", "BrowseController.DeleteFileWarningMessage", deleteCallable);
}
}
}
}
use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory in project pdi-dataservice-server-plugin by pentaho.
the class DeleteRepositoryObjectExtensionPointPlugin method callExtensionPoint.
@Override
public void callExtensionPoint(LogChannelInterface log, Object object) throws KettleException {
RepositoryExtension repositoryExtension = (RepositoryExtension) object;
UIRepositoryObject repositoryObject = repositoryExtension.getRepositoryObject();
// if a directory get all transformations recursively
if (repositoryObject instanceof UIRepositoryDirectory) {
List<UIRepositoryObject> transformationList = new ArrayList<UIRepositoryObject>();
getAllTransformations((UIRepositoryDirectory) repositoryObject, transformationList);
for (UIRepositoryObject uiRepositoryObject : transformationList) {
Repository repository = uiRepositoryObject.getRepository();
metaStoreUtil.clearReferences(repository.loadTransformation(uiRepositoryObject.getObjectId(), null));
}
} else if (repositoryObject.getRepositoryElementType().equals(RepositoryObjectType.TRANSFORMATION)) {
Repository repository = repositoryObject.getRepository();
metaStoreUtil.clearReferences(repository.loadTransformation(repositoryObject.getObjectId(), null));
}
}
use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory in project pentaho-kettle by pentaho.
the class BrowseControllerTest method setUp.
@Before
public void setUp() throws Exception {
DocumentFactory.registerElementClass(ElementDom4J.class);
controller = new BrowseController();
controller.setRepositoryDirectory(mock(UIRepositoryDirectory.class));
directoryMap = new HashMap<>(8);
controller.setDirMap(directoryMap);
document = mock(Document.class);
XulDomContainer xulDomContainer = mock(XulDomContainer.class);
when(xulDomContainer.getDocumentRoot()).thenReturn(document);
controller.setXulDomContainer(xulDomContainer);
UIRepositoryDirectory someDirectory = mock(UIRepositoryDirectory.class);
selectedFolder = mock(UIRepositoryDirectory.class);
when(selectedFolder.createFolder(FOLDER_NAME)).thenReturn(someDirectory);
XulTree folderTree = mock(XulTree.class);
when(folderTree.getSelectedItems()).thenReturn(Collections.<Object>singleton(selectedFolder));
controller.setFolderTree(folderTree);
directoryBinding = mock(Binding.class);
controller.setDirectoryBinding(directoryBinding);
selectedItemsBinding = mock(Binding.class);
controller.setSelectedItemsBinding(selectedItemsBinding);
}
Aggregations