public SolverViewFrame(Frame frame) { identifierChooser = new JComboBoxEx(); for (CharacterFacade pcf : CharacterManager.getCharacters()) { String pcname = pcf.getNameRef().get(); CharID id = pcf.getCharID(); identifierChooser.addItem(new PCRef(pcname, id)); } identifierChooser.addActionListener(new IdentifierActionListener()); objectChooser = new JComboBoxEx(); objectChooser.addActionListener(new ObjectActionListener()); scopeChooser = new JComboBoxEx(); scopeChooser.addActionListener(new ScopeActionListener()); identifierChooser.setSelectedItem(identifierChooser.getItemAt(0)); scopeChooser.setSelectedItem(scopeChooser.getItemAt(0)); varName = new JTextField(); varName.setText(varNameText); varName.getDocument().addDocumentListener(new VarNameListener()); initialize(); objectChooser.setSelectedItem(objectChooser.getItemAt(0)); }
void showCompanion(boolean switchTabs) { CompanionFacade companion = getSelectedCompanion(); if (companion == null) { if (!switchTabs) { infoPane.setText(""); // $NON-NLS-1$ } return; } if (isCompanionOpen(companion)) { CharacterFacade character = CharacterManager.getCharacterMatching(companion); if (character != null) { if (switchTabs) { frame.setSelectedCharacter(character); return; } else { sheetSupport.setCharacter(character); sheetSupport.refresh(); } } // the companion was not found // TODO: show error, complain? } else if (switchTabs) { frame.loadCharacterFromFile(companion.getFileRef().getReference()); } else { // Display a message telling the user to open the companion. infoPane.setText( LanguageBundle.getString("in_companionLoadCompanionMessage")); // $NON-NLS-1$ } }
private boolean isCompanionOpen(CompanionFacade companion) { File compFile = companion.getFileRef().getReference(); if (compFile == null) { return true; } for (CharacterFacade character : CharacterManager.getCharacters()) { File charFile = character.getFileRef().getReference(); if (compFile.equals(charFile)) { return true; } } return false; }
@Override public void actionPerformed(ActionEvent e) { if (!"null".equals(e.getActionCommand())) { if ("SELECT".equals(e.getActionCommand()) || (JTreeTable.ACTION_DOUBLECLICK == e.getID())) { newCompanion = CharacterManager.createNewCharacter( character.getUIDelegate(), character.getDataSet()); CompanionStubFacade selected = (CompanionStubFacade) raceTable.getSelectedObject(); newCompanion.setRace(selected.getRaceRef().getReference()); character.getCompanionSupport().addCompanion(newCompanion, companionType); setVisible(false); } else { newCompanion = null; setVisible(false); } } }