@Override public void resultChanged(LookupEvent lookupEvent) { nameField.setText("[no name]"); cityField.setText("[no city]"); // Get the query: Collection allQueries = customerQueryResult.allInstances(); Iterator it1 = allQueries.iterator(); while (it1.hasNext()) { query = (CustomerCollection) it1.next(); setDisplayName("Customers"); } // Get the customer: Collection allCustomers = customerResult.allInstances(); Iterator it2 = allCustomers.iterator(); while (it2.hasNext()) { customer = (Customer) it2.next(); nameField.setText(customer.getName()); cityField.setText(customer.getCity()); } // Get the node: Collection allNodes = customerNodeResult.allInstances(); Iterator it3 = allNodes.iterator(); while (it3.hasNext()) { customerNode = (Node) it3.next(); } // Need to Clear Save and Undo here nameText = nameField.getText(); cityText = cityField.getText(); // Remove New Type? Lookup.Result<NewType> newTypeResult = getLookup().lookupResult(NewType.class); Collection allNewTypes = newTypeResult.allInstances(); Iterator it4 = allNewTypes.iterator(); while (it4.hasNext()) { instanceContent.remove(it4.next()); } if (customerNode != null) { this.setActivatedNodes(new Node[] {customerNode}); for (NewType nt : customerNode.getNewTypes()) { instanceContent.add(nt); } } manager.discardAllEdits(); modify(); }
public CustomerEditorTopComponent() { initComponents(); setName(Bundle.CTL_CustomerEditorTopComponent()); setToolTipText(Bundle.HINT_CustomerEditorTopComponent()); nameField.getDocument().addUndoableEditListener(manager); cityField.getDocument().addUndoableEditListener(manager); manager.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { modify(); } }); instanceContent = new InstanceContent(); associateLookup(new AbstractLookup(instanceContent)); }