jhorvath commented on code in PR #5353:
URL: https://github.com/apache/netbeans/pull/5353#discussion_r1087788428
##########
enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/AddADBAction.java:
##########
@@ -65,80 +73,104 @@
"AddADB=Add Oracle Autonomous DB",
"SelectTenancy=Select Tenancy",
"SelectCompartment=Select Compartment",
- "SelectDatabase=Select Database"
+ "SelectDatabase=Select Compartment or Database",
+ "EnterUsername=Enter Username",
+ "EnterPassword=Enter Password"
})
public class AddADBAction implements ActionListener {
private static final Logger LOGGER =
Logger.getLogger(AddADBAction.class.getName());
+ private static final String DB = "db";
+ private static final String USERNAME = "username";
+ private static final String PASSWORD = "password";
@Override
public void actionPerformed(ActionEvent e) {
- List<TenancyItem> tenancies = new ArrayList<>();
- for (OCIProfile p : OCIManager.getDefault().getConnectedProfiles()) {
- p.getTenancy().ifPresent(tenancies::add);
- }
- Optional<TenancyItem> selectedTenancy = chooseOneItem(tenancies,
Bundle.SelectTenancy());
-
- Optional<CompartmentItem> selectedCompartment = Optional.empty();
-
- if (!selectedTenancy.isPresent()) {
- return;
- }
-
- List<CompartmentItem> compartments =
CompartmentNode.getCompartments().apply(selectedTenancy.get());
- selectedCompartment = chooseOneItem(compartments,
Bundle.SelectCompartment());
- DatabaseItem selectedDatabase = null;
+ Map<String, Object> result = new HashMap<> ();
- if (selectedCompartment.isPresent()) {
- while(selectedDatabase == null) {
- OCIItem item = chooseCopartmentOrDb(selectedCompartment.get());
- if (item == null) {
- return;
- }
- if (item instanceof DatabaseItem) {
- selectedDatabase = (DatabaseItem) item;
- }
- if (item instanceof CompartmentItem) {
- selectedCompartment = Optional.of((CompartmentItem) item);
+ NotifyDescriptor.ComposedInput ci = new
NotifyDescriptor.ComposedInput(Bundle.AddADB(), 2, new Callback() {
+ Map<Integer, List> values = new HashMap<> ();
+
+ @Override
+ public NotifyDescriptor createInput(NotifyDescriptor.ComposedInput
input, int number) {
+ if (number == 1) {
+ List<TenancyItem> tenancies = new ArrayList<>();
+ for (OCIProfile p :
OCIManager.getDefault().getConnectedProfiles()) {
+ p.getTenancy().ifPresent(tenancies::add);
+ }
+ String title;
+ if (tenancies.size() == 1) {
+ values.put(1, getCompartmentsAndDbs(tenancies.get(0)));
+ title = Bundle.SelectCompartment();
+ } else {
+ values.put(1, tenancies);
+ title = Bundle.SelectTenancy();
+ }
+ return createQuickPick(values.get(1), title);
+ } else {
+ NotifyDescriptor prev = input.getInputs()[number - 2];
+ OCIItem prevItem = null;
+ if (prev instanceof NotifyDescriptor.QuickPick) {
+ Optional<String> selected = ((QuickPick)
prev).getItems().stream().filter(item -> item.isSelected()).map(item ->
item.getLabel()).findFirst();
+ if (selected.isPresent()) {
+ Optional<? extends OCIItem> ti = values.get(number
-1).stream().filter(t -> ((OCIItem)
t).getName().equals(selected.get())).findFirst();
+ if (ti.isPresent()) {
+ prevItem = ti.get();
+ }
+ }
+ if (prevItem instanceof DatabaseItem) {
+ result.put(DB, prevItem);
+ return new
NotifyDescriptor.InputLine(Bundle.EnterUsername(), Bundle.EnterUsername());
+ }
+ values.put(number, getCompartmentsAndDbs(prevItem));
+ return createQuickPick(values.get(number),
Bundle.SelectDatabase());
+ } else if (prev instanceof NotifyDescriptor.PasswordLine) {
+ result.put(PASSWORD, ((NotifyDescriptor.PasswordLine)
prev).getInputText());
+ return null;
+ } else if (prev instanceof NotifyDescriptor.InputLine) {
+ result.put(USERNAME, ((NotifyDescriptor.InputLine)
prev).getInputText());
Review Comment:
Fixed, repeating input for empty username
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists