Example #1
0
 public String getValueForVisualization() {
   if (typeSelection.getSelectedItem().equals(MappingTypes.DATA_FIELD)) {
     return fieldSelection.getSelectedItem().toString();
   } else {
     return literalEntry.getText() + " (literal)";
   }
 }
Example #2
0
    @Override
    public void actionPerformed(ActionEvent e) {
      // TODO Auto-generated method stub

      Object source = e.getSource();
      if (source == ok) {
        response = APPLY_OPTION;
        this.setVisible(false);
      } else if (source == cancel) {
        response = CANCEL_OPTION;
        this.setVisible(false);
      } else if (source == sizeCombo) {
        // get the number from the source
        JComboBox number = (JComboBox) source;
        String numberItem = (String) number.getSelectedItem();
        Font temp = example.getFont();
        // then set the font
        int newSize = Integer.parseInt(numberItem);
        example.setFont(new Font(temp.getFamily(), temp.getStyle(), newSize));
      } else if (source == fontCombo) {
        JComboBox font = (JComboBox) source;
        String s = (String) font.getSelectedItem();
        Font tmp = example.getFont();
        example.setFont(new Font(s, tmp.getStyle(), tmp.getSize()));
      } else if (source == foreground) {
        Color tmp = JColorChooser.showDialog(this, "Choose text color", example.getForeground());
        MenuBar.shapeLBG.setBackground(tmp);
        if (tmp != null) example.setForeground(tmp);
      }
    }
Example #3
0
  /**
   * Method performed when button clicked.
   *
   * @param event event that triggers action, here clicking of the button.
   */
  public void actionPerformed(ActionEvent event) {

    if (choiceBox.getSelectedItem().equals(CUSTOM)) {
      JFileChooser chooser = new JFileChooser(System.getProperty("user.home"));
      int returnVal = chooser.showOpenDialog(settingsPanel);
      if (returnVal == JFileChooser.APPROVE_OPTION) {
        specifiedOntology = CUSTOM;
        openFile = chooser.getSelectedFile();
        choiceBox.setEditable(true);
        choiceBox.setSelectedItem(openFile.toString());
        choiceBox.setEditable(false);
        def = false;
        if (((String) choiceBox.getSelectedItem()).endsWith(".obo")) {
          settingsPanel.getNamespacePanel().choiceBox.setEnabled(true);
        } else {
          settingsPanel.getNamespacePanel().choiceBox.setEnabled(false);
        }
      }
      if (returnVal == JFileChooser.CANCEL_OPTION) {
        choiceBox.setSelectedItem(NONE);
        specifiedOntology = NONE;
        def = true;
        settingsPanel.getNamespacePanel().choiceBox.setEnabled(false);
      }
    } else if (choiceBox.getSelectedItem().equals(NONE)) {
      specifiedOntology = NONE;
      def = true;
      settingsPanel.getNamespacePanel().choiceBox.setEnabled(false);
    } else {
      specifiedOntology = (String) choiceBox.getSelectedItem();
      def = true;
      settingsPanel.getNamespacePanel().choiceBox.setEnabled(false);
    }
  }
Example #4
0
  /**
   * submit
   *
   * @param a
   * @param b
   * @return boolean
   */
  public boolean submit(String a, String b) {
    int selected[];
    int i;
    StringBuffer extra = new StringBuffer();

    waitCursor();

    for (int j = 0; j < nSection; j++) {
      selected = lk[j].getSelectedIndices();
      for (i = 0; i < selected.length; i++)
        CDSMethods.append(
            extra,
            (String) vq.getNameKey().elementAt(j),
            (String) lk[j].getModel().getElementAt(selected[i]));
    }

    boolean res =
        vq.submit(
            a,
            b,
            (String) unit.getSelectedItem(),
            (String) coordinate.getSelectedItem(),
            tauthor.getText(),
            extra.toString(),
            outputMode,
            resList.getList());
    defaultCursor();
    return res;
  }
 public void actionPerformed(ActionEvent e) {
   if (cyear.getSelectedItem() != null) {
     String b = cyear.getSelectedItem().toString();
     currentYear = Integer.parseInt(b);
     refreshCalendar(currentMonth, currentYear);
   }
 }
Example #6
0
  /**
   * return the String id of the chosen server name
   *
   * @return the server name
   */
  public String getServer() {
    Object selected = serverSelector.getSelectedItem();
    if (selected == null) {
      return null;
    }
    AddeServer server;
    if (selected instanceof AddeServer) {
      server = (AddeServer) selected;
      return server.getName();
    }
    String serverName = selected.toString();
    server = getIdv().getIdvChooserManager().addAddeServer(serverName);
    addeServers = getIdv().getIdvChooserManager().getAddeServers(getGroupType());

    Object selectedGroup = groupSelector.getSelectedItem();
    AddeServer.Group group = null;
    if (selectedGroup != null) {
      group =
          getIdv()
              .getIdvChooserManager()
              .addAddeServerGroup(server, selectedGroup.toString(), getGroupType());
    }

    boolean old = ignoreStateChangedEvents;
    ignoreStateChangedEvents = true;
    GuiUtils.setListData(serverSelector, addeServers);
    serverSelector.setSelectedItem(server);
    setGroups();
    if (group != null) {
      groupSelector.setSelectedItem(group);
    }
    ignoreStateChangedEvents = old;
    return server.getName();
  }
  /*
   * Gets the user choice for font, style and size and redraws the text
   *     accordingly.
   */
  public void setSampleFont() {
    // Get the font name from the JComboBox
    fontName = (String) facenameCombo.getSelectedItem();

    sampleField.setText(textField.getText());

    // Get the font style from the JCheckBoxes
    fontStyle = 0;
    if (italicCheckBox.isSelected()) fontStyle += Font.ITALIC;
    if (boldCheckBox.isSelected()) fontStyle += Font.BOLD;

    // Get the font size
    fontSize = 0;

    fontSize = Integer.parseInt((String) sizeCombo.getSelectedItem());

    // THE FOLLOWING IS NO LONGER NEEDED
    //            if(smallButton.isSelected())
    //                  fontSize=SMALL;
    //            else if(mediumButton.isSelected())
    //                  fontSize=MEDIUM;
    //            else if(largeButton.isSelected())
    //                  fontSize=LARGE;

    // Set the font of the text field
    sampleField.setFont(new Font(fontName, fontStyle, fontSize));
    sampleField.setForeground(fontColor);
    sampleField.repaint();

    pack();
  } // end setSampleFont method
Example #8
0
 @Override
 public void actionPerformed(ActionEvent e) {
   ID = (Integer) hashRoomType.get(boxRoomTypeID.getSelectedItem().toString());
   IDSTATUS = (Integer) hashRoomStatus.get(boxRoomStatusID.getSelectedItem().toString());
   if (e.getSource() == buttonInsert) {
     try {
       Rooms rooms = new Rooms(txtRoomNumber.getText(), txtDescription.getText(), ID, IDSTATUS);
       RoomsController.roomsController.save(rooms);
       int c = model.getRowCount();
       for (int i = c - 1; i >= 0; i--) {
         model.removeRow(i);
         jRoom.revalidate();
       }
       all();
       JOptionPane.showMessageDialog(this, "ok");
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
   if (e.getSource() == buttonUpdate) {
     try {
       Rooms rooms = new Rooms(txtRoomNumber.getText(), txtDescription.getText(), ID, IDSTATUS);
       rooms.setRoomID(IDROOM);
       RoomsController.roomsController.update(rooms);
       int c = model.getRowCount();
       for (int i = c - 1; i >= 0; i--) {
         model.removeRow(i);
         jRoom.revalidate();
       }
       all();
       JOptionPane.showMessageDialog(this, "Update to succeed !");
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
   if (e.getSource() == buttonDelete) {
     try {
       List<CheckIn> temp = CheckInController.checkInController.all();
       for (int i = 0; i < temp.size(); i++) {
         if (IDROOM == temp.get(i).getRoomID()) {
           this.error = 0;
         } else {
           this.error = 0;
           RoomsController.roomsController.delete(IDROOM);
           int c = model.getRowCount();
           for (int ii = c - 1; ii >= 0; ii--) {
             model.removeRow(ii);
             jRoom.revalidate();
           }
           all();
         }
       }
       JOptionPane.showMessageDialog(this, "Delete to succeed !");
     } catch (Exception ex) {
       JOptionPane.showMessageDialog(this, "can't delete row bcause check still !");
     }
   }
   if (e.getSource() == buttonRefresh) {}
 }
Example #9
0
 /**
  * Create a default filename given the current date selection. If custom dates are selected, use
  * those dates; otherwise, use year and week numbers.
  *
  * @return The default filename.
  */
 private String getDefaultFilename() {
   if (yearCB.getSelectedIndex() == 0 || weekCB.getSelectedIndex() == 0)
     return "timesheet-"
         + dateFormat.format(fromDate.getDate()).replaceAll("/", "")
         + "-"
         + dateFormat.format(toDate.getDate()).replaceAll("/", "")
         + ".txt";
   return "timesheet-" + yearCB.getSelectedItem() + "wk" + weekCB.getSelectedItem() + ".txt";
 }
  @NotNull
  public AnalysisScope getScope(
      @NotNull AnalysisUIOptions uiOptions,
      @NotNull AnalysisScope defaultScope,
      @NotNull Project project,
      Module module) {
    AnalysisScope scope;
    if (isProjectScopeSelected()) {
      scope = new AnalysisScope(project);
      uiOptions.SCOPE_TYPE = AnalysisScope.PROJECT;
    } else {
      final SearchScope customScope = getCustomScope();
      if (customScope != null) {
        scope = new AnalysisScope(customScope, project);
        uiOptions.SCOPE_TYPE = AnalysisScope.CUSTOM;
        uiOptions.CUSTOM_SCOPE_NAME = customScope.getDisplayName();
      } else if (isModuleScopeSelected()) {
        scope = new AnalysisScope(module);
        uiOptions.SCOPE_TYPE = AnalysisScope.MODULE;
      } else if (isUncommitedFilesSelected()) {
        final ChangeListManager changeListManager = ChangeListManager.getInstance(project);
        List<VirtualFile> files;
        if (myChangeLists.getSelectedItem() == ALL) {
          files = changeListManager.getAffectedFiles();
        } else {
          files = new ArrayList<VirtualFile>();
          for (ChangeList list : changeListManager.getChangeListsCopy()) {
            if (!Comparing.strEqual(list.getName(), (String) myChangeLists.getSelectedItem()))
              continue;
            final Collection<Change> changes = list.getChanges();
            for (Change change : changes) {
              final ContentRevision afterRevision = change.getAfterRevision();
              if (afterRevision != null) {
                final VirtualFile vFile = afterRevision.getFile().getVirtualFile();
                if (vFile != null) {
                  files.add(vFile);
                }
              }
            }
          }
        }
        scope = new AnalysisScope(project, new HashSet<VirtualFile>(files));
        uiOptions.SCOPE_TYPE = AnalysisScope.UNCOMMITTED_FILES;
      } else {
        scope = defaultScope;
        uiOptions.SCOPE_TYPE = defaultScope.getScopeType(); // just not project scope
      }
    }
    uiOptions.ANALYZE_TEST_SOURCES = isInspectTestSources();
    scope.setIncludeTestSource(isInspectTestSources());
    scope.setScope(getCustomScope());

    FindSettings.getInstance().setDefaultScopeName(scope.getDisplayName());
    return scope;
  }
 @Override
 public void actionPerformed(ActionEvent arg0) {
   if (version.getItemCount() > 0) {
     Settings.getSettings()
         .setPackVer(
             (String.valueOf(version.getSelectedItem()).equalsIgnoreCase("recommended")
                 ? "Recommended Version"
                 : String.valueOf(version.getSelectedItem())));
     Settings.getSettings().save();
   }
 }
Example #12
0
  /**
   * This method is used to create the ISAField for use in creating the xml when saving the mappings
   * out to file
   *
   * @return ISAField
   */
  public ISAField createISAField() {
    String mappingValue;

    if (typeSelection.getSelectedItem() == MappingTypes.DATA_FIELD) {
      mappingValue = fieldSelection.getSelectedItem().toString();
    } else {
      mappingValue = literalEntry.getText();
    }

    return new ISAField(
        MappingTypes.resolveTypeFromString(typeSelection.getSelectedItem().toString()),
        mappingValue);
  }
  private void onOK() {

    if (nameTextField.getText().length() < 3
        || nameTextField.getText().length() > 24
        || !nameTextField.getText().matches("[a-z0-9]+")) {
      JOptionPane.showMessageDialog(
          this,
          "Invalid storage account name. The name should be between 3 and 24 characters long and \n"
              + "can contain only lowercase letters and numbers.",
          "Error creating the storage account",
          JOptionPane.ERROR_MESSAGE);
      return;
    }

    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    createProgressBar.setVisible(true);

    try {
      String name = nameTextField.getText();
      String region =
          (regionOrAffinityGroupComboBox.getSelectedItem() instanceof Location)
              ? regionOrAffinityGroupComboBox.getSelectedItem().toString()
              : "";
      String affinityGroup =
          (regionOrAffinityGroupComboBox.getSelectedItem() instanceof AffinityGroup)
              ? regionOrAffinityGroupComboBox.getSelectedItem().toString()
              : "";
      String replication = replicationComboBox.getSelectedItem().toString();

      storageAccount =
          new StorageAccount(
              name, replication, region, affinityGroup, "", subscription.getId().toString());
      AzureSDKManagerImpl.getManager().createStorageAccount(storageAccount);
      AzureSDKManagerImpl.getManager().refreshStorageAccountInformation(storageAccount);

      onCreate.run();
    } catch (AzureCmdException e) {
      storageAccount = null;
      UIHelper.showException(
          "An error occurred while trying to create the specified storage account.",
          e,
          "Error Creating Storage Account",
          false,
          true);
    }

    setCursor(Cursor.getDefaultCursor());

    this.setVisible(false);
    dispose();
  }
Example #14
0
  /**
   * Get the Lincese text from a text file specified in the PropertyBox.
   *
   * @return String - License text.
   */
  public String getLicenseText() {
    StringBuffer textBuffer = new StringBuffer();
    try {
      String fileName = RuntimeProperties.GPL_EN_LICENSE_FILE_NAME;
      if (cbLang != null
          && cbLang.getSelectedItem() != null
          && cbLang.getSelectedItem().toString().equalsIgnoreCase("Eesti")) {
        fileName = RuntimeProperties.GPL_EE_LICENSE_FILE_NAME;
      }

      InputStream is = this.getClass().getClassLoader().getResourceAsStream(fileName);

      if (is == null) return "";

      BufferedReader in = new BufferedReader(new InputStreamReader(is));
      String str;
      while ((str = in.readLine()) != null) {
        textBuffer.append(str);
        textBuffer.append("\n");
      }
      in.close();
    } catch (IOException e) {
      logger.error(null, e);
    }
    return textBuffer.toString();
  } // getLicenseText
  @Nullable
  public LocalChangeList getSelectedList(Project project) {
    ChangeListManager manager = ChangeListManager.getInstance(project);
    if (myRbNew.isSelected()) {
      String newText = myNewListPanel.getChangeListName();
      if (manager.findChangeList(newText) != null) {
        Messages.showErrorDialog(
            project,
            VcsBundle.message("changes.newchangelist.warning.already.exists.text", newText),
            VcsBundle.message("changes.newchangelist.warning.already.exists.title"));
        return null;
      }
    }
    final boolean existingSelected = myRbExisting.isSelected();
    VcsConfiguration.getInstance(myProject).PRESELECT_EXISTING_CHANGELIST = existingSelected;

    if (existingSelected) {
      return (LocalChangeList) myExistingListsCombo.getSelectedItem();
    } else {
      LocalChangeList changeList =
          manager.addChangeList(
              myNewListPanel.getChangeListName(), myNewListPanel.getDescription());
      myNewListPanel.changelistCreatedOrChanged(changeList);
      if (myNewListPanel.getMakeActiveCheckBox().isSelected()) {
        manager.setDefaultChangeList(changeList);
      }
      VcsConfiguration.getInstance(project).MAKE_NEW_CHANGELIST_ACTIVE =
          myNewListPanel.getMakeActiveCheckBox().isSelected();

      return changeList;
    }
  }
  private void handleEntryAction(ActionEvent actionEvent)
      throws IOException, ParserConfigurationException, XPathExpressionException, SAXException,
          NoItemException {
    if (this.getGazetteer() == null) {
      Util.getLogger().severe("No gazeteer is registered");
      return;
    }

    String lookupString;

    JComboBox cmb = ((JComboBox) actionEvent.getSource());
    lookupString = cmb.getSelectedItem().toString();

    if (lookupString == null || lookupString.length() < 1) return;

    java.util.List<PointOfInterest> results = this.gazetteer.findPlaces(lookupString);
    if (results == null || results.size() == 0) return;

    this.controller.moveToLocation(results.get(0));

    // Add it to the list if not already there
    for (int i = 0; i < cmb.getItemCount(); i++) {
      Object oi = cmb.getItemAt(i);
      if (oi != null && oi.toString().trim().equals(lookupString)) return; // item exists
    }
    cmb.insertItemAt(lookupString, 0);
  }
Example #17
0
 public int getThreadPoolSize() {
   if (threadsCombo.getSelectedIndex() == 0) {
     // Automatic
     return -1;
   }
   return (Integer) threadsCombo.getSelectedItem();
 }
  private void copyFile() throws Exception {
    // Load the JDBC driver
    Class.forName(((String) jcboDriver.getSelectedItem()).trim());
    System.out.println("Driver loaded");

    // Establish a connection
    Connection conn =
        DriverManager.getConnection(
            ((String) jcboURL.getSelectedItem()).trim(),
            jtfUsername.getText().trim(),
            String.valueOf(jtfPassword.getPassword()).trim());
    System.out.println("Database connected");

    // Read each line from the text file and insert it to the table
    insertRows(conn);
  }
Example #19
0
 private String getContextPath() throws SettingsException {
   String contextPath = (String) contextPathComboBox.getSelectedItem();
   if (contextPath.contains(" ") || !contextPath.startsWith("/")) {
     throw new SettingsException("Please specify a valid context path.");
   }
   return contextPath;
 }
  private void initializeUI() {
    this.setLayout(new BorderLayout());
    this.setPreferredSize(new Dimension(400, 200));

    JLabel label = new JLabel("Tab size: ");
    Object[] items = {2, 4, 8, 10, 20};
    final JComboBox comboBox = new JComboBox(items);

    JPanel tabPanel = new JPanel(new FlowLayout());
    tabPanel.add(label);
    tabPanel.add(comboBox);

    this.add(tabPanel, BorderLayout.NORTH);

    final JTextArea textArea = new JTextArea();
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);

    //
    // Sets the number of characters to expand tabs to.
    //
    textArea.setTabSize((Integer) comboBox.getSelectedItem());
    comboBox.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            textArea.setTabSize((Integer) comboBox.getSelectedItem());
          }
        });

    JScrollPane pane = new JScrollPane(textArea);
    pane.setPreferredSize(new Dimension(400, 200));
    pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

    this.add(pane, BorderLayout.CENTER);
  }
Example #21
0
 @Override
 public void onExit() {
   // save all painters
   for (EntryListPanel panel : listPanelSet) {
     myjava.gui.syntax.Painter painter = panel.getPainter();
     if (!painter.equals(myjava.gui.syntax.Painter.getDefaultInstance())) {
       myjava.gui.syntax.Painter.add(painter);
       setConfig("painter.userDefined." + painter.getName(), painter.toWritableString());
     }
     if (painter.equals(painterComboBox.getSelectedItem())) {
       // selected painter
       setConfig("syntax.selectedPainter", painter.getName());
       myjava.gui.syntax.Painter.setCurrentInstance(painter);
     }
   }
   // remove "removed painters"
   for (myjava.gui.syntax.Painter removed : removedPainters) {
     removeConfig0("painter.userDefined." + removed.getName());
     myjava.gui.syntax.Painter.remove(removed);
   }
   // highlight?
   boolean _highlightSyntax = highlightSyntax.isSelected();
   boolean _matchBracket = matchBracket.isSelected();
   MyUmbrellaLayerUI.setHighlightingStatus(_highlightSyntax, _matchBracket);
   setConfig("syntax.highlight", _highlightSyntax + "");
   setConfig("syntax.matchBrackets", _matchBracket + "");
 }
Example #22
0
 private void gcChanged() {
   GCWrapper wrap = (GCWrapper) gcSelection.getSelectedItem();
   // assert wrap != null;
   GraphicsConfiguration gc = wrap.getGC();
   // assert gc != null;
   // Image Caps
   ImageCapabilities imageCaps = gc.getImageCapabilities();
   imageAccelerated.setSelected(imageCaps.isAccelerated());
   imageTrueVolatile.setSelected(imageCaps.isTrueVolatile());
   // Buffer Caps
   BufferCapabilities bufferCaps = gc.getBufferCapabilities();
   flipping.setSelected(bufferCaps.isPageFlipping());
   flippingMethod.setText(getFlipText(bufferCaps.getFlipContents()));
   fullScreen.setSelected(bufferCaps.isFullScreenRequired());
   multiBuffer.setSelected(bufferCaps.isMultiBufferAvailable());
   // Front buffer caps
   imageCaps = bufferCaps.getFrontBufferCapabilities();
   fbAccelerated.setSelected(imageCaps.isAccelerated());
   fbTrueVolatile.setSelected(imageCaps.isTrueVolatile());
   imageCaps = bufferCaps.getFrontBufferCapabilities();
   // Back buffer caps
   imageCaps = bufferCaps.getBackBufferCapabilities();
   bbAccelerated.setSelected(imageCaps.isAccelerated());
   bbTrueVolatile.setSelected(imageCaps.isTrueVolatile());
 }
Example #23
0
 public String getValueEntered() {
   if (typeSelection.getSelectedItem().equals(MappingTypes.DATA_FIELD)) {
     return "<<" + fieldSelection.getSelectedIndex() + ">>";
   } else {
     return literalEntry.getText();
   }
 }
Example #24
0
 /**
  * Get the selected AddeServer
  *
  * @return the server or null
  */
 private AddeServer getAddeServer() {
   Object selected = serverSelector.getSelectedItem();
   if ((selected != null) && (selected instanceof AddeServer)) {
     return (AddeServer) selected;
   }
   return null;
 }
Example #25
0
  /**
   * Get the image group from the gui.
   *
   * @return The iamge group.
   */
  protected String getGroup() {
    Object selected = groupSelector.getSelectedItem();
    if (selected == null) {
      return null;
    }
    if (selected instanceof AddeServer.Group) {
      AddeServer.Group group = (AddeServer.Group) selected;
      return group.getName();
    }

    String groupName = selected.toString().trim();
    if ((groupName.length() > 0)) {
      // Force the get in case they typed a server name
      getServer();
      AddeServer server = getAddeServer();
      if (server != null) {
        AddeServer.Group group =
            getIdv().getIdvChooserManager().addAddeServerGroup(server, groupName, getGroupType());
        if (!group.getActive()) {
          getIdv().getIdvChooserManager().activateAddeServerGroup(server, group);
        }
        // Now put the list of groups back in to the selector
        setGroups();
        groupSelector.setSelectedItem(group);
      }
    }

    return groupName;
  }
 /*
  * Checks if the preferences have changed from the cached preferences.
  */
 private boolean prefsChanged() {
   return (prefs.getResolution() != resolution.getSelectedItem())
       || (prefs.getFullscreen() != fullscreen.isSelected())
       || (prefs.getBitrate() != bitrate.getValue())
       || (prefs.getUseOpenGlRenderer() != openGlRenderer.isSelected())
       || (prefs.getLocalAudio() != localAudio.isSelected());
 }
Example #27
0
 protected void save() {
   data.name = nameField.getText();
   try {
     costField.commitEdit();
     data.cost = ((Long) costField.getValue()).intValue();
   } catch (ParseException e) {
     data.cost = 0;
   }
   data.color = colorBox.getSelectedItem().toString();
   data.text = charField.getText();
   data.weight = Float.parseFloat(weightField.getText());
   if (spellBox.getSelectedItem() != null) {
     data.spell = spellBox.getSelectedItem().toString();
   }
   data.setPath(Editor.getStore().getActive().get("id"));
 }
Example #28
0
  /**
   * Create preview component.
   *
   * @param type type
   * @param comboBox the options.
   * @param prefSize the preferred size
   * @return the component.
   */
  private static Component createPreview(int type, final JComboBox comboBox, Dimension prefSize) {
    JComponent preview = null;

    if (type == DeviceConfigurationComboBoxModel.AUDIO) {
      Object selectedItem = comboBox.getSelectedItem();

      if (selectedItem instanceof AudioSystem) {
        AudioSystem audioSystem = (AudioSystem) selectedItem;

        if (!NoneAudioSystem.LOCATOR_PROTOCOL.equalsIgnoreCase(audioSystem.getLocatorProtocol())) {
          preview = new TransparentPanel(new GridBagLayout());
          createAudioSystemControls(audioSystem, preview);
        }
      }
    } else if (type == DeviceConfigurationComboBoxModel.VIDEO) {
      JLabel noPreview =
          new JLabel(
              NeomediaActivator.getResources().getI18NString("impl.media.configform.NO_PREVIEW"));

      noPreview.setHorizontalAlignment(SwingConstants.CENTER);
      noPreview.setVerticalAlignment(SwingConstants.CENTER);

      preview = createVideoContainer(noPreview);
      preview.setPreferredSize(prefSize);

      Object selectedItem = comboBox.getSelectedItem();
      CaptureDeviceInfo device = null;
      if (selectedItem instanceof DeviceConfigurationComboBoxModel.CaptureDevice)
        device = ((DeviceConfigurationComboBoxModel.CaptureDevice) selectedItem).info;

      Exception exception;
      try {
        createVideoPreview(device, preview);
        exception = null;
      } catch (IOException ex) {
        exception = ex;
      } catch (MediaException ex) {
        exception = ex;
      }
      if (exception != null) {
        logger.error("Failed to create preview for device " + device, exception);
        device = null;
      }
    }

    return preview;
  }
 /*
  * Writes the preferences to the disk.
  */
 private void writePreferences() {
   prefs.setFullscreen(fullscreen.isSelected());
   prefs.setBitrate(bitrate.getValue());
   prefs.setResolution((Resolution) resolution.getSelectedItem());
   prefs.setUseOpenGlRenderer(openGlRenderer.isSelected());
   prefs.setLocalAudio(localAudio.isSelected());
   PreferencesManager.writePreferences(prefs);
 }
  public void actionPerformed(ActionEvent e) {

    parent
        .getParent()
        .getGrid()
        .setHeatMap(species.getSelectedItem().toString()); // I now regret the parent model
    parent.getParent().refresh();
  }