use of org.pentaho.di.ui.repo.dialog.RepositoryDialog 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.ui.repo.dialog.RepositoryDialog 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);
}
});
}
use of org.pentaho.di.ui.repo.dialog.RepositoryDialog in project pentaho-kettle by pentaho.
the class SessionTimeoutHandler method showLoginScreen.
boolean showLoginScreen(RepositoryConnectController repositoryConnectController) {
String message = BaseMessages.getString(PKG, "Repository.Reconnection.Message");
RepositoryDialog loginDialog = new RepositoryDialog(getSpoon().getShell(), repositoryConnectController);
RepositoryMeta repositoryMeta = repositoryConnectController.getConnectedRepository();
return loginDialog.openRelogin(repositoryMeta, message);
}
use of org.pentaho.di.ui.repo.dialog.RepositoryDialog in project pentaho-kettle by pentaho.
the class RepositorySpoonStartExtensionPoint method callExtensionPoint.
@Override
public void callExtensionPoint(LogChannelInterface log, Object object) throws KettleException {
if (!(object instanceof CommandLineOption[])) {
return;
}
CommandLineOption[] options = (CommandLineOption[]) object;
StringBuilder optionRepname = getCommandLineOption(options, "rep").getArgument();
StringBuilder optionFilename = getCommandLineOption(options, "file").getArgument();
StringBuilder optionUsername = getCommandLineOption(options, "user").getArgument();
StringBuilder optionPassword = getCommandLineOption(options, "pass").getArgument();
if (!Utils.isEmpty(optionRepname) && Utils.isEmpty(optionFilename)) {
RepositoryMeta repositoryMeta = repositoryConnectController.getRepositoryMetaByName(optionRepname.toString());
if (repositoryMeta != null && !Utils.isEmpty(optionUsername) && !Utils.isEmpty(optionPassword)) {
repositoryConnectController.connectToRepository(repositoryMeta, optionUsername.toString(), optionPassword.toString());
} else if (repositoryMeta != null) {
repositoryConnectController.connectToRepository(repositoryMeta, null, null);
}
if (!repositoryConnectController.isConnected()) {
String msg = BaseMessages.getString(PKG, "Repository.NoConnected.Message");
// "No repositories defined on this system."
log.logError(msg);
MessageBox mb = new MessageBox(getSpoon().getShell(), SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "Repository.NoConnected.Message", optionRepname.toString()));
mb.setText(BaseMessages.getString(PKG, "Repository.NoConnected.Message.Title"));
mb.open();
}
} else if (Utils.isEmpty(optionFilename)) {
RepositoryMeta repositoryMeta = repositoryConnectController.getDefaultRepositoryMeta();
if (repositoryMeta != null) {
if (repositoryMeta.getId().equals("KettleFileRepository")) {
repositoryConnectController.connectToRepository(repositoryMeta);
} else {
new RepositoryDialog(getSpoon().getShell(), repositoryConnectController).openLogin(repositoryMeta);
}
}
}
}
use of org.pentaho.di.ui.repo.dialog.RepositoryDialog in project pentaho-kettle by pentaho.
the class RequestLoginToRepositoryExtensionPoint method loginToRepository.
void loginToRepository(RepositoryMeta repositoryMeta, ILoginCallback loginCallback) {
RepositoryDialog dialog = getRepositoryDialog();
boolean result = dialog.openLogin(repositoryMeta);
if (result) {
loginCallback.onSuccess(repositoryConnectController.getConnectedRepositoryInstance());
} else {
loginCallback.onCancel();
}
}
Aggregations