Performing a Lookup

Suppose the user selects a new group...   

the combo box has a listener...

    groupCombo.addActionListener(
        new BaseAction(TOOLBAR_GROUP_CHANGE));

so BaseAction passes the event to the gopher...

    public void actionPerformed(ActionEvent event) {
        actionHandler.performAction(this, event);
    }

who happens to be PartsLookupManager...

    public void performAction(BaseAction action, 
                              ActionEvent event) {
        switch (action.getID()) {
        case TOOLBAR_GROUP_CHANGE: groupChange(); break;

who sets the group and does a lookup...

    private void groupChange() {
        Group group = categoryManager.getComboGroup();

        if (group != null) {
            lookup.setGroup(group);
            doLookup();
        }
    }

after releasing the Swing event thread...

    private void doLookup() {

        SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                checkSpecificConditions();
                lookupData();
                recordLookup();
            }
        });
    }

first checking the specific conditions...

    private void checkSpecificConditions() {

        boolean primary = lookup.isPrimary();
        Vehicle vehicle = lookup.getVehicle();
        Group   group   = lookup.getGroup();

        Question[] questions = PartsServer
                    .getQuestions(primary, vehicle, group);

        QuestionDialog dialog = lookupManager
                    .getQuestionDialog("Parts", questions);
        dialog.setVisible(true);

        vehicle.addQuestions(questions);
    }

then going to the server for the data...

    private void lookupData() {

        Object[] data = new Object[0];

        boolean primary = lookup.isPrimary();
        Vehicle vehicle = lookup.getVehicle();
        Group   group   = lookup.getGroup();

        data = PartsServer.getParts(primary, vehicle, group);

        dataList.setData(data, lookup.toString());
    }

and finally asking Lookup Manager to record the lookup...

    private void recordLookup() {
        supplierManager.setLookupFromState(lookup);
        vehicleManager .setLookupFromState(lookup);
        categoryManager.setLookupFromState(lookup);

        lookupManager.addLookup(lookup);
    }
JComboBox
+ JComboBox(ComboBoxModel)
+ addActionListener(ActionListener)
+ getSelectedItem() : Object
CategoryToolBar
+ CategoryToolBar(CategoryManager)
BaseAction
+ BaseAction(int)
+ getID() : int
+ setActionHandler(ActionHandler)
+ actionPerformed(ActionEvent)
« Interface »
ActionHandler
+ performAction(BaseAction, ActionEvent)
PartsLookupManager
- lookup : PartsLookup
+ PartsLookupManager(LookupManager)
+ performAction(BaseAction, ActionEvent)
- groupChange()
- doLookup()
- checkSpecificConditions()
- lookupData()
- recordLookup()
CategoryManager
+ getComboGroup() : Group
+ setLookupFromState(LookupByCategory)
PartsLookup
+ PartsLookup()
+ isValid() : boolean
+ isPrimary() : boolean
+ getVehicle() : Vehicle
+ getGroup() : Group
+ setPrimary(boolean)
+ setVehicle(Vehicle)
+ setGroup(Group)
+ makeCopy() : Lookup
Vehicle
+ Vehicle(Year, Make, Model, Engine)
+ getYear() : Year
+ getMake() : Make
+ getModel() : Model
+ getEngine() : Engine
+ addQuestions(Question[])
Group
+ Group(String, String, String, String)
+ getCode() : String
+ getName() : String
Question
+ Question(int, String, Answer[])
+ isBoolean() : boolean
+ isMultiChoice() : boolean
+ isMultiAnswer() : boolean
+ getQuestion() : String
+ getAnswers() : Answer[]
Answer
+ Answer(String, String)
+ getCode() : String
+ getName() : String
+ isAnswered() : boolean
+ isYes() : boolean
+ setYes(boolean)
QuestionDialog
+ QuestionDialog(Frame, String, Question[])
+ isCanceled() : boolean
- createBooleanCombo(Question question)
- createMultiCombo(Question question)
- createMultiList(Question question)
- setAnswer(Question, JComboBox)
PartsServer
+ PartsServer()
+ getQuestions(boolean, Vehicle, Group) : Question[]
+ getParts(boolean, Vehicle, Group) : Object[]
Part
+ Part(int, boolean, String...)
+ isPosted() : boolean
+ getLineNumber() : int
+ hasC2C() : boolean
+ getPerCarQty() : String
+ getDescription() : String
Manufacturer
+ Manufacturer(String...)
+ getRedLineText() : String
Header
+ Header(String[])
+ getFields() : String[]
LookupManager
+ LookupManager(MainScreen)
+ addLookup(Lookup)
+ getQuestionDialog(Question[]) : QuestionDialog
+ handleTabChange(int)
+ performAction(BaseAction, ActionEvent)
+ saveAndExit()