use of org.knime.workbench.ui.masterkey.CredentialVariablesDialog in project knime-core by knime.
the class OpenCredentialVariablesDialogAction method run.
/**
* {@inheritDoc}
*/
@Override
public void run() {
super.run();
// get workflow
final WorkflowManager wf = getWorkflow();
// open the dialog
final Display d = Display.getDefault();
// run in UI thread
d.asyncExec(new Runnable() {
@Override
public void run() {
CredentialsStore store = wf.getCredentialsStore();
CredentialVariablesDialog dialog = new CredentialVariablesDialog(d.getActiveShell(), store, wf.getName());
if (dialog.open() == Window.OK) {
for (String name : store.listNames()) {
store.remove(name);
}
List<Credentials> credentials = dialog.getCredentials();
for (Credentials cred : credentials) {
store.add(cred);
}
}
}
});
}
use of org.knime.workbench.ui.masterkey.CredentialVariablesDialog in project knime-core by knime.
the class GUIWorkflowLoadHelper method loadCredentials.
/**
* {@inheritDoc}
*/
@Override
public List<Credentials> loadCredentials(final List<Credentials> credentialsList) {
// set the ones that were already prompted for into the result list ... don't prompt them again
final List<Credentials> newCredentialsList = new ArrayList<Credentials>();
final List<Credentials> credentialsToBePromptedList = new ArrayList<Credentials>();
for (Credentials c : credentialsList) {
Credentials updatedCredentials = m_promptedCredentials.get(c.getName());
if (updatedCredentials != null) {
newCredentialsList.add(updatedCredentials);
} else {
credentialsToBePromptedList.add(c);
}
}
// prompt for details for the credentials that haven't been prompted for
if (!credentialsToBePromptedList.isEmpty()) {
// run sync'ly in UI thread
m_display.syncExec(new Runnable() {
@Override
public void run() {
CredentialVariablesDialog dialog = new CredentialVariablesDialog(m_display.getActiveShell(), credentialsToBePromptedList, m_workflowName);
if (dialog.open() == Window.OK) {
List<Credentials> updateCredentialsList = dialog.getCredentials();
newCredentialsList.addAll(updateCredentialsList);
updateCredentialsList.stream().filter(c -> StringUtils.isNotEmpty(c.getPassword())).forEach(c -> m_promptedCredentials.put(c.getName(), c));
} else {
newCredentialsList.addAll(credentialsToBePromptedList);
}
}
});
}
return newCredentialsList;
}
Aggregations