use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent 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.UIRepositoryContent in project pentaho-kettle by pentaho.
the class ExplorerHarness method main.
/**
* @param args
*/
@SuppressWarnings("nls")
public static void main(String[] args) {
KettleDatabaseRepositoryMeta repositoryMeta;
KettleDatabaseRepository repository;
@SuppressWarnings("unused") UserInfo userInfo;
repositoryMeta = new KettleDatabaseRepositoryMeta();
repositoryMeta.setName("Kettle Database Repository");
repositoryMeta.setDescription("Kettle database test repository");
DatabaseMeta connection = new DatabaseMeta();
connection.setDatabaseType("Hypersonic");
connection.setHostname("localhost");
connection.setDBName("kettle_repository_4x");
connection.setDBPort("9002");
connection.setUsername("sa");
repositoryMeta.setConnection(connection);
userInfo = new UserInfo("admin", "admin", "Administrator", "The system administrator", true);
repository = new KettleDatabaseRepository();
repository.init(repositoryMeta);
@SuppressWarnings("unused") RepositoryExplorerCallback cb = new RepositoryExplorerCallback() {
public boolean open(UIRepositoryContent element, String revision) throws Exception {
System.out.println("Name: ".concat(element.getName()));
System.out.println("Type: ".concat(element.getRepositoryElementType().name()));
System.out.println("Directory: ".concat(element.getRepositoryDirectory().toString()));
System.out.println("Revision: ".concat(revision == null ? "null" : revision));
// do not close explorer
return false;
}
@Override
public boolean error(String message) throws Exception {
System.out.println("Error message: ".concat(message));
return true;
}
};
/*
* try { repository.connect(userInfo.getLogin(), userInfo.getPassword()); //RepositoryExplorer explorer = new
* RepositoryExplorer(new Shell(), repository, cb, null); //explorer.show(); } catch (XulException e) {
* e.printStackTrace(); } catch (KettleSecurityException e) { e.printStackTrace(); } catch (KettleException e) {
* e.printStackTrace(); }
*/
}
use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent in project pentaho-kettle by pentaho.
the class RepositoryLockController method areAnyRepositoryObjectsLocked.
private boolean areAnyRepositoryObjectsLocked(DropEvent event, UIRepositoryObjects repositoryObjects) throws KettleException {
for (UIRepositoryObject ro : repositoryObjects) {
if (ro instanceof ILockObject) {
final UIRepositoryContent contentToLock = (UIRepositoryContent) ro;
if (((ILockObject) contentToLock).isLocked()) {
// Content is locked, move is not allowed.
event.setAccepted(false);
// $NON-NLS-1$
messageBox.setTitle(BaseMessages.getString(PKG, "Dialog.Error"));
// $NON-NLS-1$
messageBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
// $NON-NLS-1$
messageBox.setMessage(BaseMessages.getString(PKG, "BrowseController.FolderMoveNotAllowed"));
messageBox.open();
return true;
}
}
}
return false;
}
use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent in project pentaho-kettle by pentaho.
the class RevisionController method createBindings.
private void createBindings() {
// $NON-NLS-1$
filePropertiesTabbox = (XulTabbox) document.getElementById("file-properties-tabs");
// $NON-NLS-1$
historyTab = (XulTab) document.getElementById("history");
// $NON-NLS-1$
revisionTable = (XulTree) document.getElementById("revision-table");
// $NON-NLS-1$
folderTree = (XulTree) document.getElementById("folder-tree");
// $NON-NLS-1$
fileTable = (XulTree) document.getElementById("file-table");
// Hide the history tab if versioning is off
historyTab.setVisible(false);
bf.setBindingType(Binding.Type.ONE_WAY);
BindingConvertor<int[], Boolean> forButtons = new BindingConvertor<int[], Boolean>() {
@Override
public Boolean sourceToTarget(int[] value) {
return value != null && !(value.length <= 0);
}
@Override
public int[] targetToSource(Boolean value) {
return null;
}
};
Binding openButtonBinding = // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
bf.createBinding(revisionTable, "selectedRows", OPEN_REVISION_BUTTON, "!disabled", forButtons);
Binding restoreButtonBinding = // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
bf.createBinding(revisionTable, "selectedRows", RESTORE_REVISION_BUTTON, "!disabled", forButtons);
bf.setBindingType(Binding.Type.ONE_WAY);
// $NON-NLS-1$ //$NON-NLS-2$
bf.createBinding(folderTree, "selectedItems", this, "historyTabVisibility");
// $NON-NLS-1$ //$NON-NLS-2$
revisionBinding = bf.createBinding(this, "revisionObjects", revisionTable, "elements");
revisionBinding = // $NON-NLS-1$ //$NON-NLS-2$
bf.createBinding(// $NON-NLS-1$ //$NON-NLS-2$
browseController, // $NON-NLS-1$ //$NON-NLS-2$
"repositoryItems", // $NON-NLS-1$ //$NON-NLS-2$
this, // $NON-NLS-1$ //$NON-NLS-2$
"revisionObjects", new BindingConvertor<List<UIRepositoryObject>, UIRepositoryObjectRevisions>() {
private void disableButtons() {
document.getElementById(OPEN_REVISION_BUTTON).setDisabled(true);
document.getElementById(RESTORE_REVISION_BUTTON).setDisabled(true);
}
@Override
public UIRepositoryObjectRevisions sourceToTarget(List<UIRepositoryObject> ro) {
if (ro == null || ro.isEmpty() || !masterVersioningEnabled) {
return new UIRepositoryObjectRevisions();
}
if (ro.get(0) instanceof UIRepositoryDirectory) {
historyTab.setVisible(false);
filePropertiesTabbox.setSelectedIndex(0);
disableButtons();
return null;
}
UIRepositoryObjectRevisions revisions = null;
try {
UIRepositoryContent rc = (UIRepositoryContent) ro.get(0);
if (rc instanceof IRevisionObject) {
Boolean versioningEnabled = ((IRevisionObject) rc).getVersioningEnabled();
// Show/hide the Verison History tab
historyTab.setVisible(versioningEnabled);
if (!versioningEnabled) {
return new UIRepositoryObjectRevisions();
}
Boolean versionCommentEnabled = ((IRevisionObject) rc).getVersionCommentEnabled();
// Show/Hide the version comment column
setRevisionTableColumns(versionCommentEnabled);
revisions = ((IRevisionObject) rc).getRevisions();
} else {
throw new IllegalStateException(BaseMessages.getString(PKG, // $NON-NLS-1$
"RevisionsController.RevisionsNotSupported"));
}
} catch (KettleException e) {
if (mainController == null || !mainController.handleLostRepository(e)) {
// convert to runtime exception so it bubbles up through the UI
throw new RuntimeException(e);
}
}
return revisions;
}
@Override
public List<UIRepositoryObject> targetToSource(UIRepositoryObjectRevisions elements) {
return null;
}
});
try {
openButtonBinding.fireSourceChanged();
restoreButtonBinding.fireSourceChanged();
revisionBinding.fireSourceChanged();
} catch (Exception e) {
if (mainController == null || !mainController.handleLostRepository(e)) {
// convert to runtime exception so it bubbles up through the UI
throw new RuntimeException(e);
}
}
}
use of org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent in project pentaho-kettle by pentaho.
the class RevisionController method openRevision.
public void openRevision() {
Collection<UIRepositoryContent> content = fileTable.getSelectedItems();
UIRepositoryContent contentToOpen = content.iterator().next();
Collection<UIRepositoryObjectRevision> revision = revisionTable.getSelectedItems();
// TODO: Is it a requirement to allow opening multiple revisions?
UIRepositoryObjectRevision revisionToOpen = revision.iterator().next();
if (mainController != null && mainController.getCallback() != null) {
try {
// TODO: fire request to close dialog
mainController.getCallback().open(contentToOpen, revisionToOpen.getName());
} catch (Exception e) {
if (mainController != null) {
mainController.handleLostRepository(e);
}
}
}
}
Aggregations