Esempio n. 1
0
 public boolean validate() {
   if (myRbImportModule.isSelected()) {
     final String path = myModulePathFieldPanel.getText().trim();
     if (path.length() == 0) {
       Messages.showErrorDialog(
           IdeBundle.message(
               "error.please.specify.path.to.module.file",
               ApplicationNamesInfo.getInstance().getProductName()),
           IdeBundle.message("title.module.file.path.not.specified"));
       myModulePathFieldPanel.getTextField().requestFocus();
       return false;
     }
     final File file = new File(path);
     if (!file.exists()) {
       Messages.showErrorDialog(
           IdeBundle.message("error.module.file.does.not.exist"),
           IdeBundle.message("title.module.file.does.not.exist"));
       myModulePathFieldPanel.getTextField().requestFocus();
       return false;
     }
     if (!StdFileTypes.IDEA_MODULE.equals(
         FileTypeManager.getInstance().getFileTypeByFileName(file.getName()))) {
       Messages.showErrorDialog(
           IdeBundle.message(
               "error.module.not.iml", path, ApplicationNamesInfo.getInstance().getProductName()),
           IdeBundle.message("title.incorrect.file.type"));
       myModulePathFieldPanel.getTextField().requestFocus();
       return false;
     }
   }
   return true;
 }
  @Override
  @Nullable
  public JComponent createOptionsPanel() {
    final JPanel result = new JPanel(new BorderLayout());

    final JPanel internalPanel = new JPanel(new BorderLayout());
    result.add(internalPanel, BorderLayout.NORTH);

    final FieldPanel additionalAttributesPanel = new FieldPanel(null, getPanelTitle(), null, null);
    additionalAttributesPanel
        .getTextField()
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              @Override
              protected void textChanged(DocumentEvent e) {
                final Document document = e.getDocument();
                try {
                  final String text = document.getText(0, document.getLength());
                  if (text != null) {
                    myValues = reparseProperties(text.trim());
                  }
                } catch (BadLocationException e1) {
                  getLogger().error(e1);
                }
              }
            });

    final JCheckBox checkBox = new JCheckBox(getCheckboxTitle());
    checkBox.setSelected(myCustomValuesEnabled);
    checkBox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            final boolean b = checkBox.isSelected();
            if (b != myCustomValuesEnabled) {
              myCustomValuesEnabled = b;
              additionalAttributesPanel.setEnabled(myCustomValuesEnabled);
            }
          }
        });

    internalPanel.add(checkBox, BorderLayout.NORTH);
    internalPanel.add(additionalAttributesPanel, BorderLayout.CENTER);

    additionalAttributesPanel.setPreferredSize(
        new Dimension(150, additionalAttributesPanel.getPreferredSize().height));
    additionalAttributesPanel.setEnabled(myCustomValuesEnabled);
    additionalAttributesPanel.setText(createPropertiesString());

    return result;
  }
Esempio n. 3
0
  public NewLanguageSettings(String projectPath) {
    super(new GridLayoutManager(5, 1, new Insets(0, 5, 5, 5), -1, -1));
    myProjectPath = projectPath;

    this.add(new JLabel("Language name:"), Util.getGridConstraints(0));
    myLanguageName = new JTextField();
    myLanguageName.setName("Name");
    myLanguageName
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              protected void textChanged(DocumentEvent p0) {
                if ((myProjectPath == null || myProjectPath.length() == 0)) {
                  return;
                }
                String path = myProjectPath + File.separator + "languages" + File.separator;
                final String langName = getLanguageName();
                if (!(langName.equals(getLanguageLocation()))) {
                  path += langName;
                }
                if (!(myLangLocationChangedByUser)) {
                  setLanguageLocation(path);
                }
                fireChanged();
              }
            });
    this.add(myLanguageName, Util.getGridConstraints(1));

    myLanguageLocation = new JTextField();
    myLanguageLocation.setName("Path");
    myLanguageLocation
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              protected void textChanged(DocumentEvent p0) {
                if (myLangLocationDocListenerEnabled) {
                  myLangLocationChangedByUser = true;
                }
              }
            });
    final FileChooserDescriptor descriptor =
        FileChooserDescriptorFactory.createSingleFolderDescriptor();
    InsertPathAction.addTo(myLanguageLocation, descriptor);
    BrowseFilesListener listener =
        new BrowseFilesListener(
            myLanguageLocation, "Choose Language Location Folder", "", descriptor);
    FieldPanel fieldPanel =
        new FieldPanel(
            myLanguageLocation, "Language location:", null, listener, EmptyRunnable.getInstance());
    FileChooserFactory.getInstance()
        .installFileCompletion(fieldPanel.getTextField(), descriptor, false, null);
    this.add(fieldPanel, Util.getGridConstraints(2));

    myRuntimeSolution = new JCheckBox("Create Runtime Solution");
    this.add(myRuntimeSolution, Util.getGridConstraints(3));

    mySandboxSolution = new JCheckBox("Create Sandbox Solution");
    this.add(mySandboxSolution, Util.getGridConstraints(4));

    this.setPreferredSize(new Dimension(400, 100));

    reset();
  }