コード例 #1
0
 /** Update state dialog depending on the current state of the fields */
 private void updateDialogState() {
   String branch = myBranchTextField.getText();
   if (branch.length() != 0) {
     setOKButtonText(GitBundle.getString("unstash.button.branch"));
     myPopStashCheckBox.setEnabled(false);
     myPopStashCheckBox.setSelected(true);
     myReinstateIndexCheckBox.setEnabled(false);
     myReinstateIndexCheckBox.setSelected(true);
     if (!GitBranchNameValidator.INSTANCE.checkInput(branch)) {
       setErrorText(GitBundle.getString("unstash.error.invalid.branch.name"));
       setOKActionEnabled(false);
       return;
     }
     if (myBranches.contains(branch)) {
       setErrorText(GitBundle.getString("unstash.error.branch.exists"));
       setOKActionEnabled(false);
       return;
     }
   } else {
     if (!myPopStashCheckBox.isEnabled()) {
       myPopStashCheckBox.setSelected(false);
     }
     myPopStashCheckBox.setEnabled(true);
     setOKButtonText(
         myPopStashCheckBox.isSelected()
             ? GitBundle.getString("unstash.button.pop")
             : GitBundle.getString("unstash.button.apply"));
     if (!myReinstateIndexCheckBox.isEnabled()) {
       myReinstateIndexCheckBox.setSelected(false);
     }
     myReinstateIndexCheckBox.setEnabled(true);
   }
   if (myStashList.getModel().getSize() == 0) {
     myViewButton.setEnabled(false);
     myDropButton.setEnabled(false);
     myClearButton.setEnabled(false);
     setErrorText(null);
     setOKActionEnabled(false);
     return;
   } else {
     myClearButton.setEnabled(true);
   }
   if (myStashList.getSelectedIndex() == -1) {
     myViewButton.setEnabled(false);
     myDropButton.setEnabled(false);
     setErrorText(null);
     setOKActionEnabled(false);
     return;
   } else {
     myViewButton.setEnabled(true);
     myDropButton.setEnabled(true);
   }
   setErrorText(null);
   setOKActionEnabled(true);
 }
コード例 #2
0
 void checkAllProductNodes(boolean checked) {
   for (JCheckBox checker : checkers) {
     if (checker.isEnabled()) {
       checker.setSelected(checked);
     }
   }
 }
コード例 #3
0
 public boolean isDoNotAskMe() {
   if (myDoNotAskMeCheckBox.isEnabled()) {
     return myDoNotAskMeCheckBox.isSelected();
   } else {
     return !EditorSettingsExternalizable.getInstance().getOptions().SHOW_REFORMAT_DIALOG;
   }
 }
コード例 #4
0
 /**
  * Returns the files that failed to import.
  *
  * @return See above.
  */
 public List<FileImportComponent> getImportErrors() {
   List<FileImportComponent> l = null;
   if (file.isFile()) {
     if (errorBox != null && errorBox.isVisible()) {
       if (errorBox.isSelected() && errorBox.isEnabled() && image instanceof Exception) {
         l = new ArrayList<FileImportComponent>();
         l.add(this);
         return l;
       }
     }
   } else {
     if (components != null) {
       Entry entry;
       Iterator<FileImportComponent> i = components.values().iterator();
       FileImportComponent fc;
       l = new ArrayList<FileImportComponent>();
       List<FileImportComponent> list;
       while (i.hasNext()) {
         fc = i.next();
         list = fc.getImportErrors();
         if (list != null && list.size() > 0) l.addAll(list);
       }
     }
   }
   return l;
 }
コード例 #5
0
 private void updateSoftWrapSettingsRepresentation() {
   boolean softWrapsEnabled = myCbUseSoftWrapsAtEditor.isSelected();
   myCbUseCustomSoftWrapIndent.setEnabled(softWrapsEnabled);
   myCustomSoftWrapIndent.setEnabled(
       myCbUseCustomSoftWrapIndent.isEnabled() && myCbUseCustomSoftWrapIndent.isSelected());
   myCustomSoftWrapIndentLabel.setEnabled(myCustomSoftWrapIndent.isEnabled());
   myCbShowSoftWrapsOnlyOnCaretLine.setEnabled(softWrapsEnabled);
 }
コード例 #6
0
 /**
  * Returns the import error object.
  *
  * @return See above.
  */
 public ImportErrorObject getImportErrorObject() {
   if (errorBox == null || !errorBox.isVisible()) return null;
   if (!errorBox.isEnabled()) return null;
   ImportErrorObject object = new ImportErrorObject(file, (ImportException) image);
   object.setReaderType(statusLabel.getReaderType());
   object.setUsedFiles(statusLabel.getUsedFiles());
   return object;
 }
コード例 #7
0
 protected void doOKAction() {
   if (!myValidator.isOK(this)) return;
   myNameSuggestionsManager.nameSelected();
   myTypeSelectorManager.typeSelected(getSelectedType());
   if (myCbFinal.isEnabled()) {
     JavaRefactoringSettings.getInstance().INTRODUCE_LOCAL_CREATE_FINALS = myCbFinal.isSelected();
   }
   super.doOKAction();
 }
 private void saveSettings() {
   final JavaRefactoringSettings settings = JavaRefactoringSettings.getInstance();
   settings.INTRODUCE_PARAMETER_CREATE_FINALS = myDeclareFinalCheckBox.isSelected();
   if (myGetterPanel.isVisible()) {
     settings.INTRODUCE_PARAMETER_REPLACE_FIELDS_WITH_GETTERS = getReplaceFieldsWithGetter();
   }
   if (myForceReturnCheckBox.isEnabled() && mySignaturePanel.isVisible()) {
     GroovyApplicationSettings.getInstance().FORCE_RETURN = myForceReturnCheckBox.isSelected();
   }
 }
コード例 #9
0
 private void updateCheckboxes(List<SearchEngine> engines) {
   for (SearchEngine se : engines) {
     JCheckBox cBox = engineCheckboxes.get(se);
     if (cBox != null) {
       if (cBox.isEnabled() && !cBox.isSelected() && se.isEnabled()) {
         continue;
       }
       cBox.setSelected(se.isEnabled());
       cBox.setEnabled(se.isEnabled());
     }
   }
 }
コード例 #10
0
 private String applyExchangeRate(String amount) {
   String convertedAmount = "";
   // apply the exchange rate
   if (foreignExchangeCheckBox.isEnabled()
       && foreignExchangeTextField.getText().length() > 0
       && amount.length() > 0) {
     double exchangeRate = Double.parseDouble(foreignExchangeTextField.getText());
     convertedAmount = "" + Double.parseDouble(amount) * exchangeRate;
   } else {
     convertedAmount = amount;
   }
   return convertedAmount;
 }
コード例 #11
0
 /**
  * Returns <code>true</code> if some files were imported, <code>false</code> otherwise.
  *
  * @return See above.
  */
 public boolean toRefresh() {
   if (file.isFile()) {
     if (deleteButton.isVisible()) return false;
     else if (errorBox.isVisible()) return !(errorBox.isEnabled() && errorBox.isSelected());
     return true;
   }
   if (components == null) return false;
   Iterator<FileImportComponent> i = components.values().iterator();
   int count = 0;
   while (i.hasNext()) {
     if (i.next().hasFailuresToSend()) count++;
   }
   return components.size() != count;
 }
コード例 #12
0
 /**
  * Returns <code>true</code> if errors to send, <code>false</code> otherwise.
  *
  * @return See above.
  */
 public boolean hasFailuresToSend() {
   if (file.isFile()) {
     if (errorBox.isVisible()) return errorBox.isEnabled() && errorBox.isSelected();
     return false;
   }
   if (components == null) {
     return false;
   }
   Iterator<FileImportComponent> i = components.values().iterator();
   while (i.hasNext()) {
     if (i.next().hasFailuresToSend()) return true;
   }
   return false;
 }
コード例 #13
0
 private StockpileItem getStockpileItem() {
   Item item = (Item) jItems.getSelectedItem();
   double countMinimum;
   try {
     countMinimum = Double.valueOf(jCountMinimum.getText());
   } catch (NumberFormatException ex) {
     countMinimum = 0;
   }
   boolean copy = jCopy.isSelected() && jCopy.isEnabled();
   int typeID;
   if (copy) {
     typeID = -item.getTypeID();
   } else {
     typeID = item.getTypeID();
   }
   return new StockpileItem(getStockpile(), item, typeID, countMinimum);
 }
コード例 #14
0
  protected void updateComponents(boolean b) {
    if (b) {
      if (!isPopAccount()) {
        trashButton.setText(getPath(item.get(SpecialFoldersItem.TRASH)));
      }

      draftsButton.setText(getPath(item.get(SpecialFoldersItem.DRAFTS)));
      templatesButton.setText(getPath(item.get(SpecialFoldersItem.TEMPLATES)));
      sentButton.setText(getPath(item.get(SpecialFoldersItem.SENT)));

      if (isPopAccount()) {
        inboxButton.setText(getPath(item.get(SpecialFoldersItem.INBOX)));
      }

      defaultAccountCheckBox.setSelected(item.getBoolean(SpecialFoldersItem.USE_DEFAULT_ACCOUNT));

      defaultAccountCheckBox.setEnabled(
          MailConfig.getInstance().getAccountList().getDefaultAccountUid()
              == accountItem.getInteger(SpecialFoldersItem.UID));

      if (defaultAccountCheckBox.isEnabled() && defaultAccountCheckBox.isSelected()) {
        showDefaultAccountWarning();
      } else {
        layoutComponents();
      }
    } else {
      if (!isPopAccount()) {
        item.setString(SpecialFoldersItem.TRASH, getUid(trashButton.getText()));
      }

      item.setString(SpecialFoldersItem.DRAFTS, getUid(draftsButton.getText()));
      item.setString(SpecialFoldersItem.TEMPLATES, getUid(templatesButton.getText()));
      item.setString(SpecialFoldersItem.SENT, getUid(sentButton.getText()));

      if (isPopAccount()) {
        item.setString(SpecialFoldersItem.INBOX, getUid(inboxButton.getText()));
      }

      item.setBoolean(SpecialFoldersItem.USE_DEFAULT_ACCOUNT, defaultAccountCheckBox.isSelected());
    }
  }
コード例 #15
0
  protected void doAction() {
    final JavaRefactoringSettings settings = JavaRefactoringSettings.getInstance();
    settings.INTRODUCE_PARAMETER_REPLACE_FIELDS_WITH_GETTERS =
        myPanel.getReplaceFieldsWithGetters();
    if (myCbDeclareFinal != null && myCbDeclareFinal.isEnabled()) {
      settings.INTRODUCE_PARAMETER_CREATE_FINALS = Boolean.valueOf(myCbDeclareFinal.isSelected());
    }

    myPanel.saveSettings(settings);

    myNameSuggestionsManager.nameSelected();

    boolean isDeleteLocalVariable = false;

    PsiExpression parameterInitializer = myExpression;
    if (myLocalVar != null) {
      if (myPanel.isUseInitializer()) {
        parameterInitializer = myLocalVar.getInitializer();
      }
      isDeleteLocalVariable = myPanel.isDeleteLocalVariable();
    }

    final IntroduceParameterProcessor processor =
        new IntroduceParameterProcessor(
            myProject,
            myMethodToReplaceIn,
            myMethodToSearchFor,
            parameterInitializer,
            myExpression,
            myLocalVar,
            isDeleteLocalVariable,
            getParameterName(),
            myPanel.isReplaceAllOccurences(),
            myPanel.getReplaceFieldsWithGetters(),
            isDeclareFinal(),
            myPanel.isGenerateDelegate(),
            getSelectedType(),
            myPanel.getParametersToRemove());
    invokeRefactoring(processor);
    myParameterNameField.requestFocusInWindow();
  }
コード例 #16
0
  private void setupCheckboxes(List<SearchEngine> searchEngines, JPanel parent) {

    final Map<JCheckBox, BooleanSetting> cBoxes = new HashMap<JCheckBox, BooleanSetting>();

    ItemListener listener =
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (areAll(false)) {
              ((JCheckBox) e.getItemSelectable()).setSelected(true);
            }

            if (resultPanel != null) {
              resultPanel.filterChanged(new SearchEngineFilter(engineCheckboxes), 0);
            }
          }
        };

    for (SearchEngine se : searchEngines) {
      JCheckBox cBox = new JCheckBox(se.getName());
      cBox.setSelected(se.isEnabled());
      cBox.setEnabled(se.isEnabled());

      if (!cBox.isEnabled()) {
        cBox.setToolTipText(
            se.getName()
                + " "
                + I18n.tr(
                    "has been disabled on your FrostWire Search Options. (Go to Tools > Options > Search to enable)"));
      }

      parent.add(cBox);

      cBoxes.put(cBox, se.getEnabledSetting());
      cBox.addItemListener(listener);

      engineCheckboxes.put(se, cBox);
    }
  }
コード例 #17
0
  public synchronized void notifyVersion(SprogVersion v) {
    sv = v;
    if (log.isDebugEnabled()) {
      log.debug("Found: " + sv.toString());
    }
    if (sv.sprogType.isSprog() == false) {
      // Didn't recognize a SPROG so check if it is in boot mode already
      JOptionPane.showMessageDialog(
          null, "SPROG prompt not found", "SPROG Console", JOptionPane.ERROR_MESSAGE);
    } else {
      if (sv.sprogType.sprogType > SprogType.SPROGIIv3) {
        currentTextField.setToolTipText("Enter new current limit in milliAmps (less than 2500)");
      }
      // We know what we're connected to
      setTitle(title() + " - Connected to " + sv.toString());

      // Enable blueline & firmware unlock check boxes
      if (isBlueLineSupportPossible()) {
        if (log.isDebugEnabled()) {
          log.debug("Enable blueline check box");
        }
        blueCheckBox.setEnabled(true);
        if (log.isDebugEnabled()) {
          log.debug(Boolean.toString(blueCheckBox.isEnabled()));
        }
      }
      if (isFirmwareUnlockPossible()) {
        if (log.isDebugEnabled()) {
          log.debug("Enable firmware check box");
        }
        unlockCheckBox.setEnabled(true);
        if (log.isDebugEnabled()) {
          log.debug(Boolean.toString(unlockCheckBox.isEnabled()));
        }
      }

      ztcCheckBox.setEnabled(isZTCModePossible());

      // Get Current Limit if available
      if (isCurrentLimitPossible() && sm.getInUseCount() == 0) {
        state = State.CURRENTQUERYSENT;
        msg = new SprogMessage(1);
        msg.setOpCode('I');
        nextLine("cmd: \"" + msg + "\"\n", "");
        tc.sendSprogMessage(msg, this);
      } else {
        // Set default and get the mode word
        currentLimit = (SprogConstants.DEFAULT_I * 4880) / 470;
        currentTextField.setText(String.valueOf(SprogConstants.DEFAULT_I));

        // Only send this if we have zero active slots in slot manager
        // in command mode
        if (sm.getInUseCount() == 0) {
          state = State.MODEQUERYSENT;
          msg = new SprogMessage(1);
          msg.setOpCode('M');
          nextLine("cmd: \"" + msg + "\"\n", "");
          tc.sendSprogMessage(msg, this);
        } else {
          state = State.IDLE;
        }
      }
    }
  }
コード例 #18
0
 private void updateSoftWrapSettingsRepresentation() {
   myCbUseCustomSoftWrapIndent.setEnabled(
       myCbUseSoftWrapsAtEditor.isSelected() || myCbUseSoftWrapsAtConsole.isSelected());
   myCustomSoftWrapIndent.setEnabled(
       myCbUseCustomSoftWrapIndent.isEnabled() && myCbUseCustomSoftWrapIndent.isSelected());
 }
コード例 #19
0
 public boolean isProcessOnlyChangedText() {
   return myCbOnlyVcsChangedRegions.isEnabled() && myCbOnlyVcsChangedRegions.isSelected();
 }
コード例 #20
0
  @Override
  public void actionPerformed(ActionEvent arg0) {
    // Construct the list of loaded GPX tracks
    Collection<Layer> layerLst = Main.map.mapView.getAllLayers();
    GpxDataWrapper defaultItem = null;
    for (Layer cur : layerLst) {
      if (cur instanceof GpxLayer) {
        GpxLayer curGpx = (GpxLayer) cur;
        GpxDataWrapper gdw =
            new GpxDataWrapper(curGpx.getName(), curGpx.data, curGpx.data.storageFile);
        gpxLst.add(gdw);
        if (cur == yLayer.gpxLayer) {
          defaultItem = gdw;
        }
      }
    }
    for (GpxData data : loadedGpxData) {
      gpxLst.add(new GpxDataWrapper(data.storageFile.getName(), data, data.storageFile));
    }

    if (gpxLst.isEmpty()) {
      gpxLst.add(new GpxDataWrapper(tr("<No GPX track loaded yet>"), null, null));
    }

    JPanel panelCb = new JPanel();

    panelCb.add(new JLabel(tr("GPX track: ")));

    cbGpx = new JosmComboBox<>(gpxLst.toArray(new GpxDataWrapper[0]));
    if (defaultItem != null) {
      cbGpx.setSelectedItem(defaultItem);
    }
    cbGpx.addActionListener(statusBarUpdaterWithRepaint);
    panelCb.add(cbGpx);

    JButton buttonOpen = new JButton(tr("Open another GPX trace"));
    buttonOpen.addActionListener(new LoadGpxDataActionListener());
    panelCb.add(buttonOpen);

    JPanel panelTf = new JPanel(new GridBagLayout());

    String prefTimezone = Main.pref.get("geoimage.timezone", "0:00");
    if (prefTimezone == null) {
      prefTimezone = "0:00";
    }
    try {
      timezone = parseTimezone(prefTimezone);
    } catch (ParseException e) {
      timezone = 0;
    }

    tfTimezone = new JosmTextField(10);
    tfTimezone.setText(formatTimezone(timezone));

    try {
      delta = parseOffset(Main.pref.get("geoimage.delta", "0"));
    } catch (ParseException e) {
      delta = 0;
    }
    delta = delta / 1000; // milliseconds -> seconds

    tfOffset = new JosmTextField(10);
    tfOffset.setText(Long.toString(delta));

    JButton buttonViewGpsPhoto =
        new JButton(
            tr("<html>Use photo of an accurate clock,<br>" + "e.g. GPS receiver display</html>"));
    buttonViewGpsPhoto.setIcon(ImageProvider.get("clock"));
    buttonViewGpsPhoto.addActionListener(new SetOffsetActionListener());

    JButton buttonAutoGuess = new JButton(tr("Auto-Guess"));
    buttonAutoGuess.setToolTipText(tr("Matches first photo with first gpx point"));
    buttonAutoGuess.addActionListener(new AutoGuessActionListener());

    JButton buttonAdjust = new JButton(tr("Manual adjust"));
    buttonAdjust.addActionListener(new AdjustActionListener());

    JLabel labelPosition = new JLabel(tr("Override position for: "));

    int numAll = getSortedImgList(true, true).size();
    int numExif = numAll - getSortedImgList(false, true).size();
    int numTagged = numAll - getSortedImgList(true, false).size();

    cbExifImg =
        new JCheckBox(tr("Images with geo location in exif data ({0}/{1})", numExif, numAll));
    cbExifImg.setEnabled(numExif != 0);

    cbTaggedImg =
        new JCheckBox(tr("Images that are already tagged ({0}/{1})", numTagged, numAll), true);
    cbTaggedImg.setEnabled(numTagged != 0);

    labelPosition.setEnabled(cbExifImg.isEnabled() || cbTaggedImg.isEnabled());

    boolean ticked = yLayer.thumbsLoaded || Main.pref.getBoolean("geoimage.showThumbs", false);
    cbShowThumbs = new JCheckBox(tr("Show Thumbnail images on the map"), ticked);
    cbShowThumbs.setEnabled(!yLayer.thumbsLoaded);

    int y = 0;
    GBC gbc = GBC.eol();
    gbc.gridx = 0;
    gbc.gridy = y++;
    panelTf.add(panelCb, gbc);

    gbc = GBC.eol().fill(GBC.HORIZONTAL).insets(0, 0, 0, 12);
    gbc.gridx = 0;
    gbc.gridy = y++;
    panelTf.add(new JSeparator(SwingConstants.HORIZONTAL), gbc);

    gbc = GBC.std();
    gbc.gridx = 0;
    gbc.gridy = y;
    panelTf.add(new JLabel(tr("Timezone: ")), gbc);

    gbc = GBC.std().fill(GBC.HORIZONTAL);
    gbc.gridx = 1;
    gbc.gridy = y++;
    gbc.weightx = 1.;
    panelTf.add(tfTimezone, gbc);

    gbc = GBC.std();
    gbc.gridx = 0;
    gbc.gridy = y;
    panelTf.add(new JLabel(tr("Offset:")), gbc);

    gbc = GBC.std().fill(GBC.HORIZONTAL);
    gbc.gridx = 1;
    gbc.gridy = y++;
    gbc.weightx = 1.;
    panelTf.add(tfOffset, gbc);

    gbc = GBC.std().insets(5, 5, 5, 5);
    gbc.gridx = 2;
    gbc.gridy = y - 2;
    gbc.gridheight = 2;
    gbc.gridwidth = 2;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 0.5;
    panelTf.add(buttonViewGpsPhoto, gbc);

    gbc = GBC.std().fill(GBC.BOTH).insets(5, 5, 5, 5);
    gbc.gridx = 2;
    gbc.gridy = y++;
    gbc.weightx = 0.5;
    panelTf.add(buttonAutoGuess, gbc);

    gbc.gridx = 3;
    panelTf.add(buttonAdjust, gbc);

    gbc = GBC.eol().fill(GBC.HORIZONTAL).insets(0, 12, 0, 0);
    gbc.gridx = 0;
    gbc.gridy = y++;
    panelTf.add(new JSeparator(SwingConstants.HORIZONTAL), gbc);

    gbc = GBC.eol();
    gbc.gridx = 0;
    gbc.gridy = y++;
    panelTf.add(labelPosition, gbc);

    gbc = GBC.eol();
    gbc.gridx = 1;
    gbc.gridy = y++;
    panelTf.add(cbExifImg, gbc);

    gbc = GBC.eol();
    gbc.gridx = 1;
    gbc.gridy = y++;
    panelTf.add(cbTaggedImg, gbc);

    gbc = GBC.eol();
    gbc.gridx = 0;
    gbc.gridy = y++;
    panelTf.add(cbShowThumbs, gbc);

    final JPanel statusBar = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    statusBar.setBorder(BorderFactory.createLoweredBevelBorder());
    statusBarText = new JLabel(" ");
    statusBarText.setFont(statusBarText.getFont().deriveFont(8));
    statusBar.add(statusBarText);

    tfTimezone.addFocusListener(repaintTheMap);
    tfOffset.addFocusListener(repaintTheMap);

    tfTimezone.getDocument().addDocumentListener(statusBarUpdater);
    tfOffset.getDocument().addDocumentListener(statusBarUpdater);
    cbExifImg.addItemListener(statusBarUpdaterWithRepaint);
    cbTaggedImg.addItemListener(statusBarUpdaterWithRepaint);

    statusBarUpdater.updateStatusBar();

    outerPanel = new JPanel(new BorderLayout());
    outerPanel.add(statusBar, BorderLayout.PAGE_END);

    if (!GraphicsEnvironment.isHeadless()) {
      syncDialog =
          new ExtendedDialog(
              Main.parent,
              tr("Correlate images with GPX track"),
              new String[] {tr("Correlate"), tr("Cancel")},
              false);
      syncDialog.setContent(panelTf, false);
      syncDialog.setButtonIcons(new String[] {"ok", "cancel"});
      syncDialog.setupDialog();
      outerPanel.add(syncDialog.getContentPane(), BorderLayout.PAGE_START);
      syncDialog.setContentPane(outerPanel);
      syncDialog.pack();
      syncDialog.addWindowListener(new SyncDialogWindowListener());
      syncDialog.showDialog();
    }
  }
コード例 #21
0
  public boolean validateInput() {

    String left = textField.getText();
    if (StringUtils.isBlank(left)) {
      MessageDialogs.alert("WSCA0006");
      return false;
    }
    int leftColumnNumber = Integer.parseInt(left);

    if (leftColumnNumber <= 0) {
      MessageDialogs.alert("WSCA0007", SCBundle.get("key.columnNumber"));
      return false;
    }

    CellValue l = new CellValue(leftColumnNumber);

    String[] right = getRight();

    boolean columnVal =
        lowerPanel.isVisible() && colValCheckBox.isEnabled() && colValCheckBox.isSelected();
    boolean caseSensitive =
        lowerPanel.isVisible() && casecheckBox.isEnabled() && casecheckBox.isSelected();

    Criteria criteria = (Criteria) criteriaCombo.getSelectedItem();

    FilterConditionItem filterConditionItem;
    switch (criteria) {
      case IS_EMPTY:
      case IS_NOT_EMPTY:
      case IS_A_NUMERIC:
      case IS_NOT_A_NUMERIC:
      case EXISTS:
      case DOES_NOT_EXISTS:
        filterConditionItem = new FilterConditionItem(l, criteria);
        break;
      case MATCHES_THE_REGEX_OF:
        Regex regex = new Regex(right[0], caseSensitive);
        if (!regex.isValid()) {
          MessageDialogs.alert("WSCA0009", regex.getError());
          return false;
        }
        filterConditionItem =
            new FilterConditionItem(l, criteria, new FixedValue(right[0]), caseSensitive);
        break;
      default:
        IValue[] r = new IValue[right.length];
        for (int i = 0; i < r.length; i++) {
          if (columnVal) {
            if (!com.smoothcsv.commons.utils.StringUtils.isNumber(right[i])) {
              MessageDialogs.alert("WSCA0008", SCBundle.get("key.columnNumber"));
              return false;
            }
            int ri = Integer.parseInt(right[i]);
            if (ri <= 0) {
              MessageDialogs.alert("WSCA0007", SCBundle.get("key.columnNumber"));
              return false;
            }
            r[i] = new CellValue(ri);
          } else {
            switch (criteria) {
              case IS_A_NUMBER_GREATER_THAN:
              case IS_A_NUMBER_LESS_THAN:
              case IS_A_NUMBER_EQUAL_TO_OR_GREATER_THAN:
              case IS_A_NUMBER_EQUAL_TO_OR_LESS_THAN:
                if (!StringUtils.isNumeric(right[i])) {
                  MessageDialogs.alert("WSCA0010");
                  return false;
                }
                break;
              default:
                break;
            }
            r[i] = new FixedValue(right[i]);
          }
        }
        filterConditionItem = new FilterConditionItem(l, criteria, r, caseSensitive);
        break;
    }

    this.filterConditionItem = filterConditionItem;

    return true;
  }
コード例 #22
0
 @Override
 public TextRangeType getTextRangeType() {
   return myCbOnlyVcsChangedRegions.isEnabled() && myCbOnlyVcsChangedRegions.isSelected()
       ? TextRangeType.VCS_CHANGED_TEXT
       : TextRangeType.WHOLE_FILE;
 }
コード例 #23
0
  private void initComponents() {
    final TitledBorder border = BorderFactory.createTitledBorder(label);
    final Font titleFont = border.getTitleFont();
    if (titleFont != null) {
      border.setTitleFont(titleFont.deriveFont(Font.BOLD));
    }
    setBorder(border);

    jtext = new JTextField();
    // jtext.setText(defalt.getFile().getPath());
    jRelativneKProgramu = new JCheckBox("Relativně k umístění programu");
    jRelativneKProgramu.setEnabled(FConst.JAR_DIR_EXISTUJE);
    jActive = new JCheckBox("Aktivní");
    jActive.setEnabled(lzeDeaktivovat);
    jCurrVal = new JTextField();
    jCurrVal.setForeground(Color.BLUE);
    jCurrVal.setEditable(false);
    jCurrVal.setBorder(null);
    final JButton jbut = new JButton("...");
    // jtext.setText(defalt.getFile().getPath());
    jtext.setColumns(50);
    if (editovatelne) {
      final Box box2 = Box.createHorizontalBox();
      box2.setAlignmentX(LEFT_ALIGNMENT);
      box2.add(jtext);
      box2.add(jbut);
      final Box panel3 = Box.createHorizontalBox();
      if (FConst.JAR_DIR_EXISTUJE) {
        panel3.add(jRelativneKProgramu);
      }
      if (jActive.isEnabled()) {
        panel3.add(jActive);
      }
      if (panel3.getComponentCount() > 0) {
        add(panel3);
      }
      panel3.setAlignmentX(LEFT_ALIGNMENT);
      add(box2);
    }
    // panel.add(Box.createVerticalStrut(20));
    jCurrVal.setAlignmentX(LEFT_ALIGNMENT);
    add(jCurrVal);
    // add(panel);
    // add(Box.createVerticalStrut(20));
    jbut.addActionListener(
        new ActionListener() {
          private JFileChooser fc;

          @Override
          public void actionPerformed(final ActionEvent ae) {
            if (fc == null) { // dlouho to trvá, tak vytvoříme vždy nový
              fc = new JFileChooser();
            }
            fc.setCurrentDirectory(new File(jtext.getText()));
            if (jenAdresare) {
              fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            }
            final int result = fc.showDialog(JJedenSouborPanel.this, "Vybrat");
            if (result == JFileChooser.APPROVE_OPTION) {
              jtext.setText(fc.getSelectedFile().getPath());
            }
          }
        });

    prepocitej();
    jtext.getDocument().addDocumentListener(this);

    jRelativneKProgramu.addActionListener(e -> prepocitej());
    jActive.addActionListener(e -> prepocitej());
  }
コード例 #24
0
  public Component getListCellRendererComponent(
      JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {

    if (theList == null || theList != list) {
      theList = list;

      if (useLinkState) {
        attachLinkSimulationListener();
      }
    }

    setOpaque(true);
    setText(value == null ? "" : value.toString());

    if (useIndexSensitiveIcons) {
      icon = getIcon(index);
    }

    if (useIconBackground) setIcon(icon);

    setFont(list.getFont());
    // setToolTipText(value.toString() );

    if (list.isEnabled()) setEnabled(isEnabled(index));
    else setEnabled(list.isEnabled());

    if (isSelected && isEnabled(index)) {
      setForeground(Color.black);
      setBackground(new Color(250, 214, 138));

      if (useIndexSensitiveIcons) {
        selIcon = getIcon(index);
      }

      if (useIconBackground) setIcon(selIcon);
    } else {
      setForeground(Color.black);
      setBackground(Color.white);
      setBorder(null);
    }

    if (cellHasFocus) {
      setBorder(
          new CompoundBorder(
              new LineBorder(new Color(150, 150, 220)), new EmptyBorder(2, 2, 2, 2)));
    }

    if (useLinkState) {
      if (currentLinkRow == index) {
        setText("<html><u>" + value.toString() + "</u></html>");
        setForeground(getHoverLinkColor());
      } else {
        setForeground(getLinkColor());
      }

      if (isSelected) {
        setForeground(getSelectedLinkColor());
      }

      setBackground(Color.white);
      setBorder(new EmptyBorder(1, 1, 1, 1));
    }

    if (shdPaintDivider()) {
      Border border = null;
      if (index == 1) {
        if (dividerImage != null) {
          border = new MatteBorder(1, 0, 0, 0, dividerImage);
        } else {
          border = new MatteBorder(1, 0, 0, 0, getLinkColor());
        }

        if (index < theList.getModel().getSize() - 1) {
          setBorder(new CompoundBorder(getBorder(), border));
        } else {
          setBorder(new EmptyBorder(1, 1, 1, 1));
        }
      }
    }

    if (useIconBackground == false) {
      if (isSelected) iconLabel.setIcon(selIcon);
      else iconLabel.setIcon(icon);

      if (useCheckBoxAsIcon()) {
        if (selState == null) {
          updateSelectionStateTrackers(list);
        }

        if (selStateHandler == null) {
          list.addMouseListener(selStateHandler = new SelectionStateHandler(list));
        }
        // if selStateHandler is not null
        try {
          if (box.isEnabled()) {
            box.setSelected(selState[index]);
          }
          setSelStateList(selState);
        } catch (Exception e) {
        }
      }

      if (shdPaintDivider()) {

        // if(index < theList.getModel().getSize() - 1 ) {
        noback.setBorder(getBorder());
        setBorder(new EmptyBorder(1, 1, 1, 1));
        // } else {
        //  noback.get
        // }
      }

      // this should cause a JComboBox to paint the Label instead of the
      // check box + label combination
      if (index == -1) {
        JLabel label = new JLabel(this.getText());
        if (iconLabel.getIcon() != null) {
          label.setIcon(iconLabel.getIcon());
        }

        return label;
      }

      return noback;
    }

    return this;
  }
コード例 #25
0
ファイル: ReportPanel.java プロジェクト: KenC57/JMRI
  @SuppressWarnings("unchecked")
  public void sendButtonActionPerformed(java.awt.event.ActionEvent e) {
    try {
      sendButton.setEnabled(false);
      log.debug("initial checks");
      InternetAddress email = new InternetAddress(emailField.getText());
      email.validate();

      log.debug("start send");
      String charSet = "UTF-8"; // NO18N
      String requestURL = "http://jmri.org/problem-report.php"; // NOI18N

      MultipartMessage msg = new MultipartMessage(requestURL, charSet);

      // add reporter email address
      log.debug("start creating message");
      msg.addFormField("reporter", emailField.getText());

      // add if to Cc sender
      msg.addFormField("sendcopy", checkCopy.isSelected() ? "yes" : "no");

      // add problem summary
      msg.addFormField("summary", summaryField.getText());

      // build detailed error report (include context if selected)
      String report = descField.getText() + "\r\n";
      if (checkContext.isSelected()) {
        report += "=========================================================\r\n"; // NOI18N
        report +=
            (new ReportContext()).getReport(checkNetwork.isSelected() && checkNetwork.isEnabled());
      }
      msg.addFormField("problem", report);

      log.debug("start adding attachments");
      // add panel file if OK
      if (checkPanel.isSelected()) {
        log.debug("prepare panel attachment");
        // Check that some startup panel files have been loaded
        for (PerformFileModel m :
            InstanceManager.getDefault(StartupActionsManager.class)
                .getActions(PerformFileModel.class)) {
          String fn = m.getFileName();
          File f = new File(fn);
          log.debug("add startup panel file: {}", f);
          msg.addFilePart("logfileupload[]", f);
        }
        // Check that a manual panel file has been loaded
        File file = jmri.configurexml.LoadXmlUserAction.getCurrentFile();
        if (file != null) {
          log.debug("add manual panel file: {}", file.getPath());
          msg.addFilePart("logfileupload[]", jmri.configurexml.LoadXmlUserAction.getCurrentFile());
        } else {
          // No panel file loaded
          log.warn("No manual panel file loaded - not sending");
        }
      }

      // add profile files if OK
      if (checkProfile.isSelected()) {
        log.debug("prepare profile attachment");
        // Check that a profile has been loaded
        Profile profile = ProfileManager.getDefault().getActiveProfile();
        File file = profile.getPath();
        if (file != null) {
          log.debug("add profile: {}", file.getPath());
          // Now zip-up contents of profile
          // Create temp file that will be deleted when Java quits
          File temp = File.createTempFile("profile", ".zip");
          temp.deleteOnExit();

          FileOutputStream out = new FileOutputStream(temp);
          ZipOutputStream zip = new ZipOutputStream(out);

          addDirectory(zip, file);

          zip.close();
          out.close();

          msg.addFilePart("logfileupload[]", temp);
        } else {
          // No profile loaded
          log.warn("No profile loaded - not sending");
        }
      }

      // add the log if OK
      if (checkLog.isSelected()) {
        log.debug("prepare log attachments");
        // search for an appender that stores a file
        for (java.util.Enumeration<org.apache.log4j.Appender> en =
                org.apache.log4j.Logger.getRootLogger().getAllAppenders();
            en.hasMoreElements(); ) {
          // does this have a file?
          org.apache.log4j.Appender a = en.nextElement();
          // see if it's one of the ones we know
          if (log.isDebugEnabled()) {
            log.debug("check appender {}", a);
          }
          try {
            org.apache.log4j.FileAppender f = (org.apache.log4j.FileAppender) a;
            log.debug("find file: {}", f.getFile());
            msg.addFilePart("logfileupload[]", new File(f.getFile()), "application/octet-stream");
          } catch (ClassCastException ex) {
          }
        }
      }
      log.debug("done adding attachments");

      // finalise and get server response (if any)
      log.debug("posting report...");
      List<String> response = msg.finish();
      log.debug("send complete");
      log.debug("server response:");
      boolean checkResponse = false;
      for (String line : response) {
        log.debug("               :{}", line);
        if (line.contains("<p>Message successfully sent!</p>")) {
          checkResponse = true;
        }
      }

      if (checkResponse) {
        JOptionPane.showMessageDialog(
            null,
            rb.getString("InfoMessage"),
            rb.getString("InfoTitle"),
            JOptionPane.INFORMATION_MESSAGE);
        // close containing Frame
        getTopLevelAncestor().setVisible(false);
      } else {
        JOptionPane.showMessageDialog(
            null, rb.getString("ErrMessage"), rb.getString("ErrTitle"), JOptionPane.ERROR_MESSAGE);
        sendButton.setEnabled(true);
      }

    } catch (IOException ex) {
      log.error("Error when attempting to send report: " + ex);
      sendButton.setEnabled(true);
    } catch (AddressException ex) {
      log.error("Invalid email address: " + ex);
      JOptionPane.showMessageDialog(
          null, rb.getString("ErrAddress"), rb.getString("ErrTitle"), JOptionPane.ERROR_MESSAGE);
      sendButton.setEnabled(true);
    }
  }