Search in sources :

Example 1 with RepositoryDialog

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();
                }
            }
        }
    }
}
Also used : RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) RepositoryDialog(org.pentaho.di.ui.repo.dialog.RepositoryDialog) LastUsedFile(org.pentaho.di.core.LastUsedFile)

Example 2 with RepositoryDialog

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);
        }
    });
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Rectangle(org.eclipse.swt.graphics.Rectangle) MenuItem(org.eclipse.swt.widgets.MenuItem) Point(org.eclipse.swt.graphics.Point) RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) RepositoryDialog(org.pentaho.di.ui.repo.dialog.RepositoryDialog) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 3 with RepositoryDialog

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);
}
Also used : RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) RepositoryDialog(org.pentaho.di.ui.repo.dialog.RepositoryDialog)

Example 4 with RepositoryDialog

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);
            }
        }
    }
}
Also used : CommandLineOption(org.pentaho.di.pan.CommandLineOption) RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) RepositoryDialog(org.pentaho.di.ui.repo.dialog.RepositoryDialog) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 5 with RepositoryDialog

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();
    }
}
Also used : RepositoryDialog(org.pentaho.di.ui.repo.dialog.RepositoryDialog)

Aggregations

RepositoryDialog (org.pentaho.di.ui.repo.dialog.RepositoryDialog)6 RepositoryMeta (org.pentaho.di.repository.RepositoryMeta)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 ToolItem (org.eclipse.swt.widgets.ToolItem)2 Point (org.eclipse.swt.graphics.Point)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 Menu (org.eclipse.swt.widgets.Menu)1 MenuItem (org.eclipse.swt.widgets.MenuItem)1 MessageBox (org.eclipse.swt.widgets.MessageBox)1 LastUsedFile (org.pentaho.di.core.LastUsedFile)1 KettleException (org.pentaho.di.core.exception.KettleException)1 CommandLineOption (org.pentaho.di.pan.CommandLineOption)1