예제 #1
0
 /** Constructor */
 public VHDLCompletionProvider() {
   DefaultCompletionProvider cp = new DefaultCompletionProvider();
   try {
     cp.loadFromXML(getClass().getResourceAsStream("/res/autocomplete/vhdl.xml"));
   } catch (IOException e) {
     Logger.logError(this, e);
   }
   setDefaultCompletionProvider(cp);
 }
예제 #2
0
  /** Create the dialog. */
  public NewFileDialog() {
    // Common settings
    setModalityType(ModalityType.APPLICATION_MODAL);
    setTitle("Add new file");
    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    setBounds(0, 0, 500, 150);
    setMinimumSize(new Dimension(500, 0));
    setLocationRelativeTo(Application.mainFrame);

    // components
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new MigLayout("", "[][grow,fill]", "[][][]"));

    // Name of the file
    {
      JLabel lblFileName = new JLabel("File Name:");
      contentPanel.add(lblFileName, "cell 0 0,alignx trailing");
    }
    {
      tbxFileName = new JTextField();
      contentPanel.add(tbxFileName, "cell 1 0,growx,aligny center");
      tbxFileName.setColumns(10);
    }

    // File location
    {
      JLabel lblFileLocation = new JLabel("Location:");
      contentPanel.add(lblFileLocation, "cell 0 1,alignx trailing");
    }
    {
      tbxFileLocation = new JTextField();
      contentPanel.add(tbxFileLocation, "flowx,cell 1 1,growx,aligny center");
      tbxFileLocation.setColumns(10);
    }
    {
      SelectFileAction action =
          new SelectFileAction(
              this,
              "Select a folder",
              JFileChooser.DIRECTORIES_ONLY,
              null,
              Application.projectManager.getCurrentProject().getProjectLocation());
      Method setMethod;
      try {
        setMethod = this.getClass().getMethod("setFileLocation", String.class);
        action.setSetPathMethod(this, setMethod);
      } catch (Exception e) {
        Logger.logError(this, e);
      }
      JButton btnShowOpenFolderDialog = new JButton(action);
      contentPanel.add(btnShowOpenFolderDialog, "cell 1 1,alignx center,aligny center");
    }

    // Type of the file
    {
      JLabel lblType = new JLabel("Type:");
      contentPanel.add(lblType, "cell 0 2,alignx trailing");
    }
    {
      String[] fileTypes =
          (String[]) Application.projectManager.getSupportedFiles().toArray(new String[] {});
      Arrays.sort(fileTypes);
      DefaultComboBoxModel model = new DefaultComboBoxModel(fileTypes);
      cmbxFileType = new JComboBox(model);
      contentPanel.add(cmbxFileType, "cell 1 2,growx,aligny center");
    }

    // Ok Cancel buttons
    {
      JPanel buttonPane = new JPanel();
      buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
      getContentPane().add(buttonPane, BorderLayout.SOUTH);
      {
        JButton okButton = new JButton("OK");
        okButton.setActionCommand("OK");
        buttonPane.add(okButton);
        getRootPane().setDefaultButton(okButton);
        okButton.addActionListener(
            new ActionListener() {

              @Override
              public void actionPerformed(ActionEvent e) {
                if (checkInput()) {
                  result = DialogResult.OK;
                  dispose();
                }
              }
            });
      }
      {
        JButton cancelButton = new JButton("Cancel");
        cancelButton.setActionCommand("Cancel");
        buttonPane.add(cancelButton);
        cancelButton.addActionListener(
            new ActionListener() {

              @Override
              public void actionPerformed(ActionEvent e) {
                result = DialogResult.CANCEL;
                dispose();
              }
            });
      }
    }
    pack();
    setResizable(false);
  }