public static void importConfigsTo(@NotNull String newConfigPath) {
    ConfigImportSettings settings = getConfigImportSettings();

    File newConfigDir = new File(newConfigPath);
    File oldConfigDir = findOldConfigDir(newConfigDir, settings.getCustomPathsSelector());
    do {
      ImportOldConfigsPanel dialog = new ImportOldConfigsPanel(oldConfigDir, settings);
      dialog.setModalityType(Dialog.ModalityType.TOOLKIT_MODAL);
      AppUIUtil.updateWindowIcon(dialog);
      dialog.setVisible(true);
      if (dialog.isImportEnabled()) {
        File installationHome = dialog.getSelectedFile();
        oldConfigDir = getOldConfigDir(installationHome, settings);
        if (!validateOldConfigDir(installationHome, oldConfigDir, settings)) {
          continue;
        }

        assert oldConfigDir != null;
        doImport(newConfigDir, oldConfigDir, settings, installationHome);
        settings.importFinished(newConfigPath);
        System.setProperty(CONFIG_IMPORTED_IN_CURRENT_SESSION_KEY, Boolean.TRUE.toString());
      }

      break;
    } while (true);
  }
Exemplo n.º 2
0
 public boolean loadInitialCheckBoxState() {
   PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(myProject);
   return Boolean.TRUE
           .toString()
           .equals(propertiesComponent.getValue("GoToAction.toSaveAllIncluded"))
       && propertiesComponent.isTrueValue("GoToAction.allIncluded");
 }
Exemplo n.º 3
0
 public void saveInitialCheckBoxState(boolean state) {
   PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(myProject);
   if (Boolean.TRUE
       .toString()
       .equals(propertiesComponent.getValue("GoToAction.toSaveAllIncluded"))) {
     propertiesComponent.setValue("GoToAction.allIncluded", Boolean.toString(state));
   }
 }
Exemplo n.º 4
0
 public void writeExternal(final Element element) {
   element.setAttribute(ID_ATTR, myId);
   element.setAttribute(
       ACTIVE_ATTR, myActive ? Boolean.TRUE.toString() : Boolean.FALSE.toString());
   element.setAttribute(ANCHOR_ATTR, myAnchor.toString());
   element.setAttribute(
       AUTOHIDE_ATTR, myAutoHide ? Boolean.TRUE.toString() : Boolean.FALSE.toString());
   element.setAttribute(INTERNAL_TYPE_ATTR, myInternalType.toString());
   element.setAttribute(TYPE_ATTR, myType.toString());
   element.setAttribute(
       VISIBLE_ATTR, myVisible ? Boolean.TRUE.toString() : Boolean.FALSE.toString());
   element.setAttribute(WEIGHT_ATTR, Float.toString(myWeight));
   element.setAttribute(SIDE_WEIGHT_ATTR, Float.toString(mySideWeight));
   element.setAttribute(ORDER_ATTR, Integer.toString(myOrder));
   element.setAttribute(SIDE_TOOL_ATTR, Boolean.toString(mySplitMode));
   element.setAttribute(CONTENT_UI_ATTR, myContentUiType.getName());
   if (myFloatingBounds != null) {
     element.setAttribute(X_ATTR, Integer.toString(myFloatingBounds.x));
     element.setAttribute(Y_ATTR, Integer.toString(myFloatingBounds.y));
     element.setAttribute(WIDTH_ATTR, Integer.toString(myFloatingBounds.width));
     element.setAttribute(HEIGHT_ATTR, Integer.toString(myFloatingBounds.height));
   }
 }
  public void readDirectoryMappings(final Element element) {
    myMappings.clear();

    final List<VcsDirectoryMapping> mappingsList = new ArrayList<VcsDirectoryMapping>();
    boolean haveNonEmptyMappings = false;
    for (Element child : element.getChildren(ELEMENT_MAPPING)) {
      final String vcs = child.getAttributeValue(ATTRIBUTE_VCS);
      if (vcs != null && !vcs.isEmpty()) {
        haveNonEmptyMappings = true;
      }
      VcsDirectoryMapping mapping =
          new VcsDirectoryMapping(child.getAttributeValue(ATTRIBUTE_DIRECTORY), vcs);
      mappingsList.add(mapping);

      Element rootSettingsElement = child.getChild(ELEMENT_ROOT_SETTINGS);
      if (rootSettingsElement != null) {
        String className = rootSettingsElement.getAttributeValue(ATTRIBUTE_CLASS);
        AbstractVcs vcsInstance = findVcsByName(mapping.getVcs());
        if (vcsInstance != null && className != null) {
          final VcsRootSettings rootSettings = vcsInstance.createEmptyVcsRootSettings();
          if (rootSettings != null) {
            try {
              rootSettings.readExternal(rootSettingsElement);
              mapping.setRootSettings(rootSettings);
            } catch (InvalidDataException e) {
              LOG.error(
                  "Failed to load VCS root settings class "
                      + className
                      + " for VCS "
                      + vcsInstance.getClass().getName(),
                  e);
            }
          }
        }
      }
    }
    boolean defaultProject =
        Boolean.TRUE.toString().equals(element.getAttributeValue(ATTRIBUTE_DEFAULT_PROJECT));
    // run autodetection if there's no VCS in default project and
    if (haveNonEmptyMappings || !defaultProject) {
      myMappingsLoaded = true;
    }
    myMappings.setDirectoryMappings(mappingsList);
  }
 public void writeDirectoryMappings(final Element element) {
   if (myProject.isDefault()) {
     element.setAttribute(ATTRIBUTE_DEFAULT_PROJECT, Boolean.TRUE.toString());
   }
   for (VcsDirectoryMapping mapping : getDirectoryMappings()) {
     Element child = new Element(ELEMENT_MAPPING);
     child.setAttribute(ATTRIBUTE_DIRECTORY, mapping.getDirectory());
     child.setAttribute(ATTRIBUTE_VCS, mapping.getVcs());
     final VcsRootSettings rootSettings = mapping.getRootSettings();
     if (rootSettings != null) {
       Element rootSettingsElement = new Element(ELEMENT_ROOT_SETTINGS);
       rootSettingsElement.setAttribute(ATTRIBUTE_CLASS, rootSettings.getClass().getName());
       try {
         rootSettings.writeExternal(rootSettingsElement);
         child.addContent(rootSettingsElement);
       } catch (WriteExternalException e) {
         // don't add element
       }
     }
     element.addContent(child);
   }
 }
Exemplo n.º 7
0
  @Override
  public void displayView(DisplayHint displayHint) {
    super.displayView(displayHint);

    if (DisplayHint.WALLET_TRANSACTIONS_HAVE_CHANGED == displayHint) {
      return;
    }

    JTextField aTextField = new JTextField();

    labelTextArea.setBorder(aTextField.getBorder());

    String bringToFront = controller.getModel().getUserPreference(BitcoinModel.BRING_TO_FRONT);
    if (Boolean.TRUE.toString().equals(bringToFront)) {
      controller.getModel().setUserPreference(BitcoinModel.BRING_TO_FRONT, "false");
      mainFrame.bringToFront();
    }

    // disable any new changes if another process has changed the wallet
    if (this.bitcoinController.getModel().getActivePerWalletModelData() != null
        && this.bitcoinController
            .getModel()
            .getActivePerWalletModelData()
            .isFilesHaveBeenChangedByAnotherProcess()) {
      // files have been changed by another process - disallow edits
      mainFrame.setUpdatesStoppedTooltip(addressTextField);
      addressTextField.setEditable(false);
      addressTextField.setEnabled(false);

      if (sendButton != null) {
        sendButton.setEnabled(false);
        mainFrame.setUpdatesStoppedTooltip(sendButton);
      }
      if (pasteAddressButton != null) {
        pasteAddressButton.setEnabled(false);
        mainFrame.setUpdatesStoppedTooltip(pasteAddressButton);
      }
      titleLabel.setText(
          controller
              .getLocaliser()
              .getString("sendBitcoinPanel.sendingAddressesTitle.mayBeOutOfDate"));
      mainFrame.setUpdatesStoppedTooltip(titleLabel);
    } else {
      addressTextField.setToolTipText(null);
      addressTextField.setEditable(true);
      addressTextField.setEnabled(true);

      if (sendButton != null) {
        if (SendBitcoinPanel.enableSendButton) {
          sendButton.setEnabled(true);
          sendButton.setToolTipText(
              HelpContentsPanel.createTooltipText(
                  controller.getLocaliser().getString("sendBitcoinAction.tooltip")));
        } else {
          sendButton.setEnabled(false);
          sendButton.setToolTipText(
              HelpContentsPanel.createTooltipText(
                  controller.getLocaliser().getString("sendBitcoinAction.pleaseWait.tooltip")));
        }
      }
      if (pasteAddressButton != null) {
        pasteAddressButton.setEnabled(true);
        pasteAddressButton.setToolTipText(
            HelpContentsPanel.createTooltipText(
                controller.getLocaliser().getString("pasteAddressAction.tooltip")));
      }
      titleLabel.setText(
          controller.getLocaliser().getString("sendBitcoinPanel.sendingAddressesTitle"));
      titleLabel.setToolTipText(null);
    }
    checkDeleteSendingEnabled();
    updateAmountPanel();
  }
Exemplo n.º 8
0
  @Override
  public void loadForm() {
    // get the current address, label and amount from the model
    String address =
        this.bitcoinController.getModel().getActiveWalletPreference(BitcoinModel.SEND_ADDRESS);
    String label =
        this.bitcoinController.getModel().getActiveWalletPreference(BitcoinModel.SEND_LABEL);
    String amountNotLocalised =
        this.bitcoinController.getModel().getActiveWalletPreference(BitcoinModel.SEND_AMOUNT);

    if (amountBTCTextField != null) {
      CurrencyConverterResult converterResult =
          CurrencyConverter.INSTANCE.parseToBTCNotLocalised(amountNotLocalised);

      if (converterResult.isBtcMoneyValid()) {
        parsedAmountBTC = converterResult.getBtcMoney();
        String amountLocalised =
            CurrencyConverter.INSTANCE.getBTCAsLocalisedString(converterResult.getBtcMoney());
        amountBTCTextField.setText(amountLocalised);
        if (notificationLabel != null) {
          notificationLabel.setText("");
        }
      } else {
        parsedAmountBTC = null;
        amountBTCTextField.setText("");
        if (notificationLabel != null) {
          notificationLabel.setText(converterResult.getBtcMessage());
        }
      }
    }

    if (address != null) {
      addressTextField.setText(address);
    } else {
      addressTextField.setText("");
    }
    if (label != null) {
      labelTextArea.setText(label);
    } else {
      labelTextArea.setText("");
    }

    // if there is a pending 'handleopenURI' that needs pasting into the
    // send form, do it
    String performPasteNow =
        this.bitcoinController
            .getModel()
            .getActiveWalletPreference(BitcoinModel.SEND_PERFORM_PASTE_NOW);
    if (Boolean.TRUE.toString().equalsIgnoreCase(performPasteNow)) {
      try {
        Address decodeAddress =
            new Address(this.bitcoinController.getModel().getNetworkParameters(), address);
        processDecodedString(
            com.google.bitcoin.uri.BitcoinURI.convertToBitcoinURI(
                decodeAddress, Utils.toNanoCoins(amountNotLocalised), label, null),
            null);
        this.bitcoinController
            .getModel()
            .setActiveWalletPreference(BitcoinModel.SEND_PERFORM_PASTE_NOW, "false");
        sendButton.requestFocusInWindow();

        mainFrame.bringToFront();
      } catch (AddressFormatException e) {
        throw new RuntimeException(e);
      }
    }
  }