use of org.pentaho.di.repository.RepositoryMeta in project pentaho-kettle by pentaho.
the class RepositoryConnectController method setDefaultRepository.
public boolean setDefaultRepository(String name) {
for (int i = 0; i < repositoriesMeta.nrRepositories(); i++) {
RepositoryMeta repositoryMeta = repositoriesMeta.getRepository(i);
repositoryMeta.setDefault(repositoryMeta.getName().equals(name));
}
try {
repositoriesMeta.writeData();
} catch (KettleException ke) {
log.logError("Unable to set default repository", ke);
return false;
}
return true;
}
use of org.pentaho.di.repository.RepositoryMeta in project pentaho-kettle by pentaho.
the class RepositoryConnectController method isCompatibleRepositoryEdit.
private boolean isCompatibleRepositoryEdit(RepositoryMeta repositoryMeta) {
if (repositoryMeta != null && repositoriesMeta.indexOfRepository(currentRepository) >= 0 && connectedRepository != null && repositoryEquals(connectedRepository, currentRepository)) {
// only name / description / default changed ?
RepositoryMeta clone = repositoryMeta.clone();
clone.setName(connectedRepository.getName());
clone.setDescription(connectedRepository.getDescription());
clone.setDefault(connectedRepository.isDefault());
return repositoryEquals(connectedRepository, clone);
}
return false;
}
use of org.pentaho.di.repository.RepositoryMeta in project pentaho-kettle by pentaho.
the class RepositoryConnectController method deleteRepository.
public boolean deleteRepository(String name) {
RepositoryMeta repositoryMeta = repositoriesMeta.findRepository(name);
int index = repositoriesMeta.indexOfRepository(repositoryMeta);
if (index != -1) {
repositoriesMeta.removeRepository(index);
save();
Spoon spoon = spoonSupplier.get();
Runnable execute = () -> {
if (spoon.getRepositoryName() != null && spoon.getRepositoryName().equals(repositoryMeta.getName())) {
spoon.closeRepository();
setConnectedRepository(null);
}
fireListeners();
};
if (spoon.getShell() != null) {
spoon.getShell().getDisplay().asyncExec(execute);
} else {
execute.run();
}
}
return true;
}
use of org.pentaho.di.repository.RepositoryMeta in project pentaho-kettle by pentaho.
the class RepositoryOpenRecentFileExtensionPoint method callExtensionPoint.
@Override
public void callExtensionPoint(LogChannelInterface log, Object object) throws KettleException {
if (!(object instanceof LastUsedFile)) {
return;
}
LastUsedFile recentFile = (LastUsedFile) object;
if (recentFile.isSourceRepository() && !repositoryConnectController.isConnected(recentFile.getRepositoryName())) {
if (getSpoon().promptForSave()) {
RepositoryMeta repositoryMeta = repositoryConnectController.getRepositoryMetaByName(recentFile.getRepositoryName());
if (repositoryMeta != null) {
if (repositoryMeta.getId().equals("KettleFileRepository")) {
getSpoon().closeRepository();
repositoryConnectController.connectToRepository(repositoryMeta);
} else {
new RepositoryDialog(getSpoon().getShell(), repositoryConnectController).openLogin(repositoryMeta);
}
if (repositoryConnectController.isConnected(repositoryMeta.getName())) {
getSpoon().loadLastUsedFile(recentFile, repositoryMeta.getName());
getSpoon().addMenuLast();
}
}
}
}
}
use of org.pentaho.di.repository.RepositoryMeta in project pentaho-kettle by pentaho.
the class RepositoryConnectMenu method renderConnectDropdown.
private void renderConnectDropdown() {
connectDropdown = new ToolItem(toolBar, SWT.DROP_DOWN, toolBar.getItems().length);
connectDropdown.setText(BaseMessages.getString(PKG, "RepositoryConnectMenu.Connect"));
connectDropdown.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
final Menu connectionMenu = new Menu(toolBar.getShell());
if (repositoriesMeta != null) {
for (int i = 0; i < repositoriesMeta.nrRepositories(); i++) {
MenuItem item = new MenuItem(connectionMenu, SWT.CHECK);
String truncatedName = truncateName(repositoriesMeta.getRepository(i).getName());
item.setText(truncatedName);
item.setData(repositoriesMeta.getRepository(i).getName());
if (spoon.rep != null && spoon.getRepositoryName().equals(repositoriesMeta.getRepository(i).getName())) {
item.setSelection(true);
continue;
}
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent selectionEvent) {
String repoName = (String) (selectionEvent.widget).getData();
RepositoryMeta repositoryMeta = repositoriesMeta.findRepository(repoName);
if (repositoryMeta != null) {
try {
if (!spoon.promptForSave()) {
return;
}
} catch (KettleException ke) {
log.logError("Error prompting for save", ke);
}
if (repositoryMeta.getId().equals("KettleFileRepository")) {
try {
repoConnectController.connectToRepository(repositoryMeta);
} catch (KettleException ke) {
log.logError("Error connecting to repository", ke);
}
} else {
new RepositoryDialog(spoon.getShell(), repoConnectController).openLogin(repositoryMeta);
}
renderAndUpdate();
}
}
});
}
}
new MenuItem(connectionMenu, SWT.SEPARATOR);
MenuItem managerItem = new MenuItem(connectionMenu, SWT.NONE);
managerItem.setText(BaseMessages.getString(PKG, "RepositoryConnectMenu.RepositoryManager"));
managerItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent selectionEvent) {
new RepositoryDialog(spoon.getShell(), repoConnectController).openManager();
RepositoryMeta current = repoConnectController.getCurrentRepository();
if (current != null) {
spoon.setRepositoryName(current.getName());
}
renderAndUpdate();
}
});
new MenuItem(connectionMenu, SWT.SEPARATOR);
MenuItem disconnectItem = new MenuItem(connectionMenu, SWT.NONE);
disconnectItem.setEnabled(spoon.rep != null);
disconnectItem.setText(BaseMessages.getString(PKG, "RepositoryConnectMenu.Disconnect"));
disconnectItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent selectionEvent) {
boolean cancelled = false;
try {
cancelled = !spoon.promptForSave();
} catch (KettleException e) {
log.logError("Error saving Job or Transformation", e);
}
if (!cancelled) {
spoon.closeRepository();
repoConnectController.setConnectedRepository(null);
renderAndUpdate();
}
}
});
ToolItem item = (ToolItem) event.widget;
Rectangle rect = item.getBounds();
org.eclipse.swt.graphics.Point pt = item.getParent().toDisplay(new org.eclipse.swt.graphics.Point(rect.x, rect.y + rect.height));
connectionMenu.setLocation(pt.x, pt.y);
connectionMenu.setVisible(true);
}
});
}
Aggregations