示例#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;
 }
示例#2
0
  private void setControlsEnabled(ButtonModel selection) {
    boolean newModuleEnabled = selection == myRbCreateNewModule.getModel();
    myTypesList.setEnabled(newModuleEnabled);
    myModuleDescriptionPane.setEnabled(newModuleEnabled);

    boolean importModuleEnabled = selection == myRbImportModule.getModel();
    myModulePathFieldPanel.setEnabled(importModuleEnabled);
  }
  @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;
  }
示例#4
0
  public ModuleTypeStep(boolean createNewProject) {
    myPanel = new JPanel(new GridBagLayout());
    myPanel.setBorder(BorderFactory.createEtchedBorder());

    myModuleDescriptionPane = new JEditorPane();
    myModuleDescriptionPane.setContentType(UIUtil.HTML_MIME);
    myModuleDescriptionPane.addHyperlinkListener(
        new HyperlinkListener() {
          public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
              try {
                BrowserUtil.launchBrowser(e.getURL().toString());
              } catch (IllegalThreadStateException ex) {
                // it's nnot a problem
              }
            }
          }
        });
    myModuleDescriptionPane.setEditable(false);

    final ModuleType[] allModuleTypes = ModuleTypeManager.getInstance().getRegisteredTypes();

    myTypesList = new JList(allModuleTypes);
    myTypesList.setSelectionModel(new PermanentSingleSelectionModel());
    myTypesList.setCellRenderer(new ModuleTypesListCellRenderer());
    myTypesList.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
              return;
            }
            final ModuleType typeSelected = (ModuleType) myTypesList.getSelectedValue();
            myModuleType = typeSelected;
            //noinspection HardCodedStringLiteral
            myModuleDescriptionPane.setText(
                "<html><body><font face=\"verdana\" size=\"-1\">"
                    + typeSelected.getDescription()
                    + "</font></body></html>");
            myEventDispatcher.getMulticaster().moduleTypeSelected(typeSelected);
          }
        });
    myTypesList.setSelectedIndex(0);
    myTypesList.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
              if (myDoubleClickAction != null) {
                if (myTypesList.getSelectedValue() != null) {
                  myDoubleClickAction.run();
                }
              }
            }
          }
        });

    myRbCreateNewModule = new JRadioButton(IdeBundle.message("radio.create.new.module"), true);
    myRbImportModule = new JRadioButton(IdeBundle.message("radio.import.existing.module"));
    myButtonGroup = new ButtonGroup();
    myButtonGroup.add(myRbCreateNewModule);
    myButtonGroup.add(myRbImportModule);
    ModulesRbListener listener = new ModulesRbListener();
    myRbCreateNewModule.addItemListener(listener);
    myRbImportModule.addItemListener(listener);

    JTextField tfModuleFilePath = new JTextField();
    final String productName = ApplicationNamesInfo.getInstance().getProductName();
    myModulePathFieldPanel =
        createFieldPanel(
            tfModuleFilePath,
            IdeBundle.message("label.path.to.module.file", productName),
            new BrowseFilesListener(
                tfModuleFilePath,
                IdeBundle.message("prompt.select.module.file.to.import", productName),
                null,
                new ModuleFileChooserDescriptor()));
    myModulePathFieldPanel.setEnabled(false);

    if (createNewProject) {
      final JLabel moduleTypeLabel = new JLabel(IdeBundle.message("label.select.module.type"));
      moduleTypeLabel.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD));
      myPanel.add(moduleTypeLabel, LABEL_CONSTRAINT);
    } else {
      myPanel.add(
          myRbCreateNewModule,
          new GridBagConstraints(
              0,
              GridBagConstraints.RELATIVE,
              1,
              1,
              0.0,
              0.0,
              GridBagConstraints.NORTHWEST,
              GridBagConstraints.NONE,
              new Insets(8, 10, 8, 10),
              0,
              0));
    }
    final JLabel descriptionLabel = new JLabel(IdeBundle.message("label.description"));
    descriptionLabel.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD));
    myPanel.add(
        descriptionLabel,
        new GridBagConstraints(
            1,
            GridBagConstraints.RELATIVE,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.SOUTHWEST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));

    final JScrollPane typesListScrollPane = ScrollPaneFactory.createScrollPane(myTypesList);
    final Dimension preferredSize = calcTypeListPreferredSize(allModuleTypes);
    typesListScrollPane.setPreferredSize(preferredSize);
    typesListScrollPane.setMinimumSize(preferredSize);
    myPanel.add(
        typesListScrollPane,
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            0.2,
            (createNewProject ? 1.0 : 0.0),
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(0, createNewProject ? 10 : 30, 0, 10),
            0,
            0));

    final JScrollPane descriptionScrollPane =
        ScrollPaneFactory.createScrollPane(myModuleDescriptionPane);
    descriptionScrollPane.setPreferredSize(
        new Dimension(preferredSize.width * 3, preferredSize.height));
    myPanel.add(
        descriptionScrollPane,
        new GridBagConstraints(
            1,
            GridBagConstraints.RELATIVE,
            1,
            1,
            0.8,
            (createNewProject ? 1.0 : 0.0),
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 10),
            0,
            0));

    if (!createNewProject) {
      myPanel.add(
          myRbImportModule,
          new GridBagConstraints(
              0,
              GridBagConstraints.RELATIVE,
              2,
              1,
              1.0,
              0.0,
              GridBagConstraints.NORTHWEST,
              GridBagConstraints.NONE,
              new Insets(16, 10, 0, 10),
              0,
              0));
      myPanel.add(
          myModulePathFieldPanel,
          new GridBagConstraints(
              0,
              GridBagConstraints.RELATIVE,
              2,
              1,
              1.0,
              1.0,
              GridBagConstraints.NORTHWEST,
              GridBagConstraints.HORIZONTAL,
              new Insets(8, 30, 0, 10),
              0,
              0));
    }
  }
示例#5
0
 public String getModuleFilePath() {
   return myModulePathFieldPanel.getText().trim().replace(File.separatorChar, '/');
 }
示例#6
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();
  }