Exemplo n.º 1
0
  @SuppressWarnings("nls")
  @Override
  public void widgetSelected(SelectionEvent e) {
    if (e.getSource() != selectScannerBtn) return;

    ScanLibResult scanlibResult = ScanLib.getInstance().selectSourceAsDefault();

    if (scanlibResult.getResultCode() != ScanLibResult.Result.SUCCESS) {
      return;
    }

    ScanLibResult scannerCapResult = ScanLib.getInstance().getScannerCapability();
    int scannerCap = scannerCapResult.getValue();

    if (scanlibResult.getResultCode() != ScanLibResult.Result.SUCCESS) {
      // just stay with the last selected source
      if ((scannerCap & ScanLib.CAP_IS_SCANNER) != 0) {
        return;
      }
      setEnableAllWidgets(false);
      BgcPlugin.openError(i18n.tr("Scanning Source Error"), scanlibResult.getMessage());
      return;
    }

    IPreferenceStore prefs = ScannerConfigPlugin.getDefault().getPreferenceStore();

    String drvSetting = null;
    boolean[] drvRadioSettings = new boolean[] {false, false};

    if ((scannerCap & ScanLib.CAP_IS_WIA) != 0) {
      drvSetting = PreferenceConstants.SCANNER_DRV_TYPE_WIA;
      drvRadioSettings[1] = true;
    } else {
      drvSetting = PreferenceConstants.SCANNER_DRV_TYPE_TWAIN;
      drvRadioSettings[0] = true;
    }

    prefs.setValue(PreferenceConstants.SCANNER_DRV_TYPE, drvSetting);
    driverTypeRadio.setSelectionArray(drvRadioSettings);
    driverTypeRadio.doLoad();
    setEnableAllWidgets(true);
  }
Exemplo n.º 2
0
 private void setEnableAllWidgets(boolean enableSettings) {
   selectScannerBtn.setEnabled(true);
   driverTypeRadio.setEnabled(enableSettings, getFieldEditorParent());
   brightnessInputField.setEnabled(enableSettings, getFieldEditorParent());
   contrastInputField.setEnabled(enableSettings, getFieldEditorParent());
 }