public void selectRemote(@NotNull String remoteName) {
   for (GitRemote remote : myRemotes) {
     if (remote.getName().equals(remoteName)) {
       myRemoteCombobox.setSelectedItem(remote);
       return;
     }
   }
   myRemoteCombobox.setSelectedIndex(0);
 }
 @NotNull
 JComponent createComponent() {
   myRemoteCombobox = new JComboBox();
   myRemoteCombobox.setRenderer(new RemoteCellRenderer(myRemoteCombobox.getRenderer()));
   for (GitRemote remote : myRemotes) {
     myRemoteCombobox.addItem(remote);
   }
   myRemoteCombobox.setToolTipText("Select remote");
   if (myRemotes.size() == 1) {
     myRemoteCombobox.setEnabled(false);
   }
   return myRemoteCombobox;
 }
Esempio n. 3
0
 private static void setupSelectionOnPreferredComponent(final JComponent component) {
   if (component instanceof JTextField) {
     JTextField field = (JTextField) component;
     String text = field.getText();
     if (text != null && field.getClientProperty(HAVE_INITIAL_SELECTION) == null) {
       field.setSelectionStart(0);
       field.setSelectionEnd(text.length());
     }
   } else if (component instanceof JComboBox) {
     JComboBox combobox = (JComboBox) component;
     combobox.getEditor().selectAll();
   }
 }
Esempio n. 4
0
    protected CompileCppDialog(
        Project _project, CompileHandler compilerHandler, CompileCppOptions options) {
      super(_project, false);

      project = _project;
      setModal(true);

      doRun.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
              final boolean b = doRun.isSelected();
              executableFileName.setEnabled(b);
              executableFileName.setEditable(b);
            }
          });

      executableFileName.getEditor().setItem(options != null ? options.getOutputFileName() : "");
      doRun.setSelected(lastRunStatus);

      final CppSupportLoader loader = CppSupportLoader.getInstance(project);
      final String compileParameters = loader.getAdditionalCompileParameters();

      compileProperties.setText(
          (compileParameters != null && compileParameters.length() > 0
                  ? compileParameters + " "
                  : "")
              + CompileHandler.MARKER);

      setTitle(CppBundle.message("compile.cpp.file.dialog.title"));

      compilerSelector.setModel(
          new DefaultComboBoxModel(CppSupportSettings.CompilerSelectOptions.values()));
      compilerSelector.setSelectedItem(getCurrentCompilerOption(project));

      setSelectedProjectCompile();

      includeProjectCompileParametersCheckBox.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
              setSelectedProjectCompile();
            }
          });

      includeProjectCompileParametersCheckBox.setSelected(loader.isIncludeProjectSettings());
      final String compileParametersText = compilerHandler.buildProjectCompileOptions(project);
      projectCompileParameters.setText(compileParametersText != null ? compileParametersText : "");

      init();
    }
    public ChangeListChooser(List<? extends ChangeList> lists) {
      super(new BorderLayout(4, 2));
      myChooser = new JComboBox();
      //noinspection unchecked
      myChooser.setRenderer(
          new ColoredListCellRendererWrapper<LocalChangeList>() {
            @Override
            protected void doCustomize(
                JList list, LocalChangeList value, int index, boolean selected, boolean hasFocus) {
              if (value != null) {
                String name = value.getName().trim();
                if (name.length() > MAX_LEN) {
                  name = name.substring(0, MAX_LEN - 3) + "...";
                }
                append(
                    name,
                    value.isDefault()
                        ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES
                        : SimpleTextAttributes.REGULAR_ATTRIBUTES);
              }
            }
          });

      myChooser.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
              if (e.getStateChange() == ItemEvent.SELECTED) {
                final LocalChangeList changeList = (LocalChangeList) myChooser.getSelectedItem();
                setSelectedList(changeList);
                myChooser.setToolTipText(changeList == null ? "" : (changeList.getName()));
              }
            }
          });

      updateLists(lists);
      myChooser.setEditable(false);
      add(myChooser, BorderLayout.CENTER);

      JLabel label = new JLabel(VcsBundle.message("commit.dialog.changelist.label"));
      label.setLabelFor(myChooser);
      add(label, BorderLayout.WEST);
    }
 public void updateLists(List<? extends ChangeList> lists) {
   //noinspection unchecked
   myChooser.setModel(new DefaultComboBoxModel(lists.toArray()));
   myChooser.setEnabled(lists.size() > 1);
   if (lists.contains(mySelectedChangeList)) {
     myChooser.setSelectedItem(mySelectedChangeList);
   } else {
     if (myChooser.getItemCount() > 0) {
       myChooser.setSelectedIndex(0);
     }
   }
   mySelectedChangeList = (ChangeList) myChooser.getSelectedItem();
 }
Esempio n. 7
0
 public String getOutputFileName() {
   return (String) executableFileName.getEditor().getItem();
 }
Esempio n. 8
0
 CppSupportSettings.CompilerSelectOptions getCompiler() {
   return (CppSupportSettings.CompilerSelectOptions) compilerSelector.getSelectedItem();
 }
 void setEnabled(boolean selected) {
   if (myRemotes.size() > 1) {
     myRemoteCombobox.setEnabled(selected);
   }
 }
 @NotNull
 GitRemote getSelectedValue() {
   return (GitRemote) myRemoteCombobox.getSelectedItem();
 }