コード例 #1
0
  public void init(
      final Project project,
      final boolean suggestSearchInLibs,
      final boolean prevSearchWholeFiles,
      final String preselect) {
    mySuggestSearchInLibs = suggestSearchInLibs;
    myPrevSearchFiles = prevSearchWholeFiles;
    myProject = project;
    myScopeListener =
        new NamedScopesHolder.ScopeListener() {
          @Override
          public void scopesChanged() {
            final SearchScope selectedScope = getSelectedScope();
            rebuildModel();
            if (selectedScope != null) {
              selectScope(selectedScope.getDisplayName());
            }
          }
        };
    myNamedScopeManager = NamedScopeManager.getInstance(project);
    myNamedScopeManager.addScopeListener(myScopeListener);
    myValidationManager = DependencyValidationManager.getInstance(project);
    myValidationManager.addScopeListener(myScopeListener);
    addActionListener(createScopeChooserListener());

    final JComboBox combo = getComboBox();
    combo.setRenderer(new ScopeDescriptionWithDelimiterRenderer(combo.getRenderer()));

    rebuildModel();

    selectScope(preselect);
  }
  @Override
  public JComponent createOptionsPanel() {
    final JFormattedTextField valueField = prepareNumberEditor("m_limit");
    final JComboBox comboBox =
        new ComboBox(
            new Object[] {Scope.NONE, Scope.PRIVATE, Scope.PACKAGE_LOCAL, Scope.PROTECTED});
    comboBox.setRenderer(
        new ListCellRendererWrapper() {
          @Override
          public void customize(
              JList list, Object value, int index, boolean selected, boolean hasFocus) {
            if (value instanceof Scope) setText(((Scope) value).getText());
          }
        });
    comboBox.setSelectedItem(ignoreScope);
    comboBox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            ignoreScope = (Scope) comboBox.getSelectedItem();
          }
        });
    comboBox.setPrototypeDisplayValue(Scope.PROTECTED);

    final FormBuilder formBuilder = FormBuilder.createFormBuilder();
    formBuilder.addLabeledComponent(getConfigurationLabel(), valueField);
    formBuilder.addLabeledComponent(
        InspectionGadgetsBundle.message("constructor.visibility.option"), comboBox);
    final JPanel panel = new JPanel(new BorderLayout());
    panel.add(formBuilder.getPanel(), BorderLayout.NORTH);
    return panel;
  }
コード例 #3
0
  public EditorOptionsPanel() {
    if (SystemInfo.isMac) {
      myCbEnableWheelFontChange.setText(
          ApplicationBundle.message("checkbox.enable.ctrl.mousewheel.changes.font.size.macos"));
    }

    myStripTrailingSpacesCombo.addItem(STRIP_CHANGED);
    myStripTrailingSpacesCombo.addItem(STRIP_ALL);
    myStripTrailingSpacesCombo.addItem(STRIP_NONE);

    myHighlightSettingsPanel.setLayout(new BorderLayout());
    myHighlightSettingsPanel.add(myErrorHighlightingPanel.getPanel(), BorderLayout.CENTER);

    myRichCopyColorSchemeComboBox.setRenderer(
        new ListCellRendererWrapper<String>() {
          @Override
          public void customize(
              JList list, String value, int index, boolean selected, boolean hasFocus) {
            final String textToUse;
            if (RichCopySettings.ACTIVE_GLOBAL_SCHEME_MARKER.equals(value)) {
              textToUse = ACTIVE_COLOR_SCHEME;
            } else {
              textToUse = value;
            }
            setText(textToUse);
          }
        });

    myConfigurable = new MyConfigurable();
    initQuickDocProcessing();
    initSoftWrapsSettingsProcessing();
  }
コード例 #4
0
ファイル: FramesPanel.java プロジェクト: jexp/idea2
  public FramesPanel(Project project, DebuggerStateManager stateManager) {
    super(project, stateManager);
    myStateManager = stateManager;

    setLayout(new BorderLayout());

    myThreadsCombo = new ComboBoxWithWidePopup();
    myThreadsCombo.setRenderer(new DebuggerComboBoxRenderer());
    myThreadsListener = new ThreadsListener();
    myThreadsCombo.addItemListener(myThreadsListener);

    myFramesList = new FramesList();
    myFramesListener = new FramesListener();
    myFramesList.addListSelectionListener(myFramesListener);

    myFramesList.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(final MouseEvent e) {
            int index = myFramesList.locationToIndex(e.getPoint());
            if (index >= 0 && myFramesList.isSelectedIndex(index)) {
              processListValue(myFramesList.getModel().getElementAt(index));
            }
          }
        });

    registerThreadsPopupMenu(myFramesList);

    setBorder(null);
    add(myThreadsCombo, BorderLayout.NORTH);
    add(new JScrollPane(myFramesList), BorderLayout.CENTER);
  }
  @Override
  protected JComponent createNorthPanel() {
    JBLabel descriptionLabel = new JBLabel("<html>" + makeDescription() + "</html>");

    final JComboBox repositorySelector =
        new JComboBox(ArrayUtil.toObjectArray(myRepositories, GitRepository.class));
    repositorySelector.setRenderer(new GitRepositoryComboboxListCellRenderer(repositorySelector));
    repositorySelector.setSelectedItem(myInitialRepository);
    repositorySelector.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            List<GitCommit> commits =
                myCommits.get((GitRepository) repositorySelector.getSelectedItem());
            myCommitListWithDiffPanel.setCommits(new ArrayList<GitCommit>(commits));
          }
        });

    JPanel repoSelectorPanel = new JPanel(new BorderLayout());
    JBLabel label = new JBLabel("Repository: ");
    label.setLabelFor(repoSelectorPanel);
    repoSelectorPanel.add(label, BorderLayout.WEST);
    repoSelectorPanel.add(repositorySelector);

    if (myRepositories.size() < 2) {
      repoSelectorPanel.setVisible(false);
    }

    JPanel northPanel = new JPanel(new BorderLayout());
    northPanel.add(descriptionLabel);
    northPanel.add(repoSelectorPanel, BorderLayout.SOUTH);
    return northPanel;
  }
コード例 #6
0
  @Override
  public JComponent createForm() {

    JComponent component = super.createForm();

    annotationComboBox.setRenderer(
        new DefaultListCellRenderer() {
          @Override
          public Component getListCellRendererComponent(
              JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if (value != null) {
              Annotation annotation = (Annotation) value;
              this.setText(annotation.getBrief());
            } else {
              this.setText("-- select annotation --");
            }
            return this;
          }
        });

    component.setLayout(new FormLayout("right:p, 4dlu, left:p", "p, 4dlu, p, 4dlu, p, 4dlu, p"));

    CellConstraints cc = new CellConstraints();

    component.add(getLabel("annotationLabel"), cc.xy(1, 1));
    component.add(annotationComboBox, cc.xy(3, 1));
    component.add(getLabel("patternLabel"), cc.xy(1, 3));
    component.add(patternField, cc.xy(3, 3));
    component.add(getLabel("ciLabel"), cc.xy(1, 5));
    component.add(caseInsensitive, cc.xy(3, 5));
    component.add(getLabel("remove"), cc.xy(1, 7));
    component.add(removeMatched, cc.xy(3, 7));

    patternField.setEnabled(false);
    caseInsensitive.setSelected(true);
    caseInsensitive.setEnabled(false);

    // action listener will fill out a suggested pattern for selected annotation types
    annotationComboBox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            Object obj = annotationComboBox.getSelectedItem();
            if (obj == null) {
              patternField.setEnabled(false);
              caseInsensitive.setEnabled(false);
              setEnabled(false);
            } else {
              patternField.setEnabled(true);
              caseInsensitive.setEnabled(true);
              patternField.setText(getDefault(obj.getClass()));
              patternField.setCaretPosition(0);
              setEnabled(true);
            }
          }
        });

    return component;
  }
コード例 #7
0
 private void setUpBrowserCombobox() {
   for (BrowsersConfiguration.BrowserFamily family :
       BrowsersConfiguration.getInstance().getActiveBrowsers()) {
     browserComboBox.addItem(family);
   }
   browserComboBox.setRenderer(
       new ListCellRendererWrapper<BrowsersConfiguration.BrowserFamily>(browserComboBox) {
         @Override
         public void customize(
             JList list,
             BrowsersConfiguration.BrowserFamily family,
             int index,
             boolean selected,
             boolean hasFocus) {
           if (family != null) {
             setText(family.getName());
             setIcon(family.getIcon());
           }
         }
       });
   if (browserComboBox.getItemCount() < 2) {
     browserComboBox.setVisible(false);
     browserComboBox.setVisible(false);
   } else {
     browserComboBox.setSelectedItem(0);
   }
 }
コード例 #8
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;
 }
コード例 #9
0
 private void initCompilerTypeCmb() {
   myIncrementalTypeCmb.setModel(new ListComboBoxModel<String>(mySettings.INCREMENTAL_TYPES));
   myIncrementalTypeCmb.setSelectedItem(mySettings.INCREMENTAL_TYPE);
   myIncrementalTypeCmb.setRenderer(
       new ListCellRendererWrapper<String>() {
         @Override
         public void customize(
             JList list, String value, int index, boolean selected, boolean hasFocus) {
           if (value.equals("SBT")) setText("SBT incremental compiler");
           if (value.equals("IDEA")) setText("IntelliJ IDEA");
         }
       });
   myIncrementalTypeCmb.setToolTipText("Rebuild is required after change");
 }
コード例 #10
0
  private JPanel createChartPanel() {
    final JPanel innerChartExpressionPanel = new JPanel(new BorderLayout());
    innerChartExpressionPanel.add(
        new SortHeaderPanel(chartPropertiesTableModel), BorderLayout.NORTH);
    final JComboBox comboBox = new SmartComboBox(editModel.getChartExpressionsModel());
    comboBox.setRenderer(new ExpressionListCellRenderer());
    innerChartExpressionPanel.add(comboBox, BorderLayout.CENTER);

    final JPanel chartExpressionPanel = new JPanel(new BorderLayout());
    chartExpressionPanel.add(innerChartExpressionPanel, BorderLayout.NORTH);
    chartExpressionPanel.add(
        configureExpressionTable(chartTable, chartPropertiesTableModel), BorderLayout.CENTER);
    return chartExpressionPanel;
  }
コード例 #11
0
 private void initCompileOrderCmb() {
   myCompileOrderCmb.setModel(new ListComboBoxModel<String>(mySettings.COMPILE_ORDERS));
   myCompileOrderCmb.setSelectedItem(mySettings.COMPILE_ORDER);
   myCompileOrderCmb.setRenderer(
       new ListCellRendererWrapper<String>() {
         @Override
         public void customize(
             JList list, String value, int index, boolean selected, boolean hasFocus) {
           if (value.equals("Mixed")) setText("Mixed");
           if (value.equals("JavaThenScala")) setText("Java then Scala");
           if (value.equals("ScalaThenJava")) setText("Scala then Java");
         }
       });
 }
コード例 #12
0
  private JPanel createPrimaryDataSourcePanel() {
    final JPanel innerPrimaryDataSourcePanel = new JPanel(new BorderLayout());
    innerPrimaryDataSourcePanel.add(
        new SortHeaderPanel(primaryDataSourcePropertiesTableModel), BorderLayout.NORTH);
    final JComboBox comboBox = new SmartComboBox(editModel.getPrimaryDataSourcesModel());
    comboBox.setRenderer(new ExpressionListCellRenderer());
    innerPrimaryDataSourcePanel.add(comboBox, BorderLayout.CENTER);

    final JPanel primaryDataSourcePanel = new JPanel(new BorderLayout());
    primaryDataSourcePanel.add(innerPrimaryDataSourcePanel, BorderLayout.NORTH);
    primaryDataSourcePanel.add(
        configureExpressionTable(primaryDataSourceTable, primaryDataSourcePropertiesTableModel),
        BorderLayout.CENTER);
    return primaryDataSourcePanel;
  }
コード例 #13
0
 @Override
 protected void initClassCombo(JComboBox classCombo) {
   classCombo.setRenderer(new ClassCellRenderer(classCombo.getRenderer()));
   classCombo.addItemListener(
       new ItemListener() {
         public void itemStateChanged(ItemEvent e) {
           if (e.getStateChange() == ItemEvent.SELECTED) {
             if (myMemberSelectionPanel != null) {
               ((MyMemberInfoModel) myMemberInfoModel).setSuperClass(getSuperClass());
               myMemberSelectionPanel.getTable().setMemberInfos(myMemberInfos);
               myMemberSelectionPanel.getTable().fireExternalDataChange();
             }
           }
         }
       });
 }
コード例 #14
0
ファイル: gui.java プロジェクト: kristofvanmoffaert/LightsOff
  /** Creates new form gui */
  public gui() {
    super(new BorderLayout());
    initComponents();

    // Load user list and images
    images = new ImageIcon[userStrings.length];
    Integer[] intArray = new Integer[userStrings.length];
    for (int i = 0; i < userStrings.length; i++) {
      intArray[i] = new Integer(i);
      images[i] = createImageIcon("images/" + userStrings[i] + ".png");
      if (images[i] != null) {
        images[i].setDescription(userStrings[i]);
      }
    }
    users = new JComboBox(intArray);
    Color bg = (Color) UIManager.get("ComboBox.background");
    Color fg = (Color) UIManager.get("ComboBox.foreground");
    UIManager.put("ComboBox.selectionBackground", bg);
    UIManager.put("ComboBox.selectionForeground", fg);
    users.setUI(new MetalComboBoxUI());
    // ComboBoxRenderer renderer = new ComboBoxRenderer();
    ComboBoxRenderer renderer = new ComboBoxRenderer(userStrings, images);
    renderer.setPreferredSize(new Dimension(650, 150));
    users.setRenderer(renderer);
    users.setSize(renderer.getPreferredSize());
    users.setMaximumRowCount(4);
    users.setBounds(150, 250, 650, 200);
    add(users);
    // setBorder(BorderFactory.createEmptyBorder(20,20,20,20));

    // Set the user satisfaction labels
    jSlider1.setPaintTicks(true);
    Hashtable labelTable = new Hashtable();
    for (int i = 0; i < labels.length; i++) {
      labelTable.put(new Integer(i), new JLabel(labels[i]));
    }

    jSlider1.setLabelTable(labelTable);

    jSlider1.setPaintLabels(true);

    socket = new generalSocket(machine, 1099);

    statusThread thread = new statusThread(socket, jLabel4);
    Thread theThread = new Thread(thread);
    theThread.start();
  }
コード例 #15
0
  /**
   * Creates an instance of <tt>SelectScreenDialog</tt> by specifying the list of possible desktop
   * devices to choose from.
   *
   * @param desktopDevices the list of possible desktop devices to choose from
   */
  public SelectScreenDialog(List<MediaDevice> desktopDevices) {
    setModal(true);

    setPreferredSize(new Dimension(400, 300));

    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    deviceComboBox = new JComboBox(desktopDevices.toArray());
    contentPane.add(deviceComboBox, BorderLayout.NORTH);

    deviceComboBox.setRenderer(new ComboRenderer());

    contentPane.add(createPreview(deviceComboBox));

    contentPane.add(createButtonsPanel(), BorderLayout.SOUTH);
  }
コード例 #16
0
  public void init() {
    myExistingListsCombo.setRenderer(
        new ColoredListCellRendererWrapper() {
          private final IssueLinkRenderer myLinkRenderer = new IssueLinkRenderer(myProject, this);

          @Override
          protected void doCustomize(
              JList list, Object value, int index, boolean selected, boolean hasFocus) {
            if (value instanceof LocalChangeList) {
              String name = ((LocalChangeList) value).getName();

              if (myExistingListsCombo.getWidth() == 0) {
                name = name.length() > 10 ? name.substring(0, 7) + " .." : name;
              } else {
                final FontMetrics fm = list.getFontMetrics(list.getFont());
                final int width = fm.stringWidth(name);
                final int listWidth = myExistingListsCombo.getWidth();
                if ((listWidth > 0) && (width > listWidth)) {
                  final String truncated =
                      CommittedChangeListRenderer.truncateDescription(
                          name, fm, listWidth - fm.stringWidth(" ..") - 7);
                  if (truncated.length() > 5) {
                    name = truncated + " ..";
                  }
                }
              }
              myLinkRenderer.appendTextWithLinks(
                  name,
                  ((LocalChangeList) value).isDefault()
                      ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES
                      : SimpleTextAttributes.REGULAR_ATTRIBUTES);
            }
          }
        });
    myNewListPanel.init(null);
    myRbNew.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusGained(FocusEvent e) {
            getPreferredFocusedComponent().requestFocusInWindow();
          }
        });
    final ComboboxSpeedSearch search = new ComboboxSpeedSearch(myExistingListsCombo);
    search.setComparator(new SpeedSearchComparator(true, false));
  }
コード例 #17
0
  public EditorOptionsPanel() {
    if (SystemInfo.isMac) {
      myCbEnableWheelFontChange.setText(
          ApplicationBundle.message("checkbox.enable.ctrl.mousewheel.changes.font.size.macos"));
    }

    myStripTrailingSpacesCombo.addItem(STRIP_CHANGED);
    myStripTrailingSpacesCombo.addItem(STRIP_ALL);
    myStripTrailingSpacesCombo.addItem(STRIP_NONE);
    ActionListener explainer =
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            explainTrailingSpaces(getStripTrailingSpacesValue());
          }
        };
    myStripTrailingSpacesCombo.addActionListener(explainer);
    myCbVirtualSpace.addActionListener(explainer);

    myHighlightSettingsPanel.setLayout(new BorderLayout());
    myHighlightSettingsPanel.add(myErrorHighlightingPanel.getPanel(), BorderLayout.CENTER);

    myCbRenameLocalVariablesInplace.setVisible(
        OptionsApplicabilityFilter.isApplicable(OptionId.RENAME_IN_PLACE));

    myRichCopyColorSchemeComboBox.setRenderer(
        new ListCellRendererWrapper<String>() {
          @Override
          public void customize(
              JList list, String value, int index, boolean selected, boolean hasFocus) {
            final String textToUse;
            if (RichCopySettings.ACTIVE_GLOBAL_SCHEME_MARKER.equals(value)) {
              textToUse = ACTIVE_COLOR_SCHEME;
            } else {
              textToUse = value;
            }
            setText(textToUse);
          }
        });

    myConfigurable = new MyConfigurable();
    initQuickDocProcessing();
    initSoftWrapsSettingsProcessing();
    initVcsSettingsProcessing();
  }
コード例 #18
0
    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);
    }
コード例 #19
0
  private JComboBox getMixerComboBox() {
    if (mixerComboBox == null) {
      Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();

      Line.Info clipLineInfo = new Line.Info(Clip.class);

      Vector<Mixer.Info> mixers = new Vector<Mixer.Info>();

      for (Mixer.Info mi : mixerInfo) {
        if (AudioSystem.getMixer(mi).getSourceLineInfo(clipLineInfo).length > 0) {
          mixers.add(mi);
        }
      }

      mixerComboBox = new JComboBox(mixers);
      mixerComboBox.setRenderer(new MixerInfoCellRenderer());
      mixerComboBox.addActionListener(eventHandler);
    }
    return mixerComboBox;
  }
 @NotNull
 private JComboBox createTestTypeComboBox(TestTypeListItem[] testTypeListItems) {
   JComboBox comboBox = new JComboBox(testTypeListItems);
   comboBox.setRenderer(
       new ListCellRendererWrapper<TestTypeListItem>(comboBox.getRenderer()) {
         @Override
         public void customize(
             JList list, TestTypeListItem value, int index, boolean selected, boolean hasFocus) {
           setText(value.getDisplayName());
         }
       });
   comboBox.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           selectTestType(getSelectedTestType());
         }
       });
   return comboBox;
 }
コード例 #21
0
 public JstdDebugSection() {
   BrowsersConfiguration.BrowserFamily[] supportedBrowsers =
       new BrowsersConfiguration.BrowserFamily[] {
         BrowsersConfiguration.BrowserFamily.CHROME, BrowsersConfiguration.BrowserFamily.FIREFOX
       };
   myPreferredDebugBrowserComboBox = new JComboBox(supportedBrowsers);
   myPreferredDebugBrowserComboBox.setRenderer(
       new ListCellRendererWrapper<BrowsersConfiguration.BrowserFamily>() {
         @Override
         public void customize(
             JList list,
             BrowsersConfiguration.BrowserFamily value,
             int index,
             boolean selected,
             boolean hasFocus) {
           setIcon(value.getIcon());
           setText(value.getName());
         }
       });
 }
コード例 #22
0
ファイル: JavaCompilersTab.java プロジェクト: jexp/idea2
  public JavaCompilersTab(
      final Project project,
      Collection<BackendCompiler> compilers,
      BackendCompiler defaultCompiler) {
    myDefaultCompiler = defaultCompiler;
    myCompilerConfiguration =
        (CompilerConfigurationImpl) CompilerConfiguration.getInstance(project);
    myConfigurables = new ArrayList<Configurable>(compilers.size());

    myCardLayout = new CardLayout();
    myContentPanel.setLayout(myCardLayout);

    for (BackendCompiler compiler : compilers) {
      Configurable configurable = compiler.createConfigurable();
      myConfigurables.add(configurable);

      myContentPanel.add(configurable.createComponent(), compiler.getId());
    }
    myCompiler.setModel(new DefaultComboBoxModel(new Vector(compilers)));
    myCompiler.setRenderer(
        new DefaultListCellRenderer() {
          public Component getListCellRendererComponent(
              JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            JLabel component =
                (JLabel)
                    super.getListCellRendererComponent(
                        list, value, index, isSelected, cellHasFocus);
            component.setText(((BackendCompiler) value).getPresentableName());
            return component;
          }
        });
    myCompiler.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            BackendCompiler compiler = (BackendCompiler) myCompiler.getSelectedItem();
            if (compiler == null) return;
            selectCompiler(compiler);
          }
        });
  }
コード例 #23
0
  public void setValue(T value, ObjectMeta target) {
    init(m_widgetContext);
    m_parentObject = target;

    valueMap = m_parentObject.getAll(getClassModel().getContainedClass());
    byName = new HashMap<String, ObjectMeta<T>>();
    for (ObjectMeta<T> objectMeta : valueMap.values()) {
      byName.put(objectMeta.getKey(), objectMeta);
    }
    setComboValues(new ArrayList(valueMap.keySet()));
    m_comboBox.setRenderer(
        new DefaultListCellRenderer() {
          public Component getListCellRendererComponent(
              JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            if (value instanceof String) {
              T obj = getObj((String) value);
              setToolTipText(getTooltip(obj));
              String t = getLabelText(obj);
              value = t != null ? t : value;
            }
            return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
          }
        });

    /*if (getClassModel().isTreeType()) {
        m_root = new Tree();
        Tree root = getClassModel().getTreeRoot();
        m_root.setPathSeparator(root.pathSeparator());
        m_root.getChildren().add(root);
        m_comboBox.setEditable(true);
    }
    else {
        m_comboBox.setEditable(false);
    }*/

    m_comboBox.setSelectedItem(getKeyByValue(value));
  }
コード例 #24
0
  public FriendsListView() {
    super();
    this.setTitle(friendsListViewMessages.getString("friends"));
    this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    this.setSize(400, 800);
    this.setLayout(new BorderLayout());
    JSplitPane splitter = new JSplitPane();
    splitter.setResizeWeight(0.5);

    JPanel topPanel = new JPanel(new BorderLayout());
    topPanel.add(new LocalizedJLabel(friendsListViewMessages, "online"), BorderLayout.NORTH);
    this.onlineList = new JList<RosterEntry>();
    this.onlineList.setCellRenderer(new FriendListItemRenderer());
    topPanel.add(new JScrollPane(this.onlineList), BorderLayout.CENTER);

    JPanel bottomPanel = new JPanel(new BorderLayout());
    bottomPanel.add(new LocalizedJLabel(friendsListViewMessages, "offline"), BorderLayout.NORTH);
    this.offlineList = new JList<RosterEntry>();
    this.offlineList.setCellRenderer(new FriendListItemRenderer());
    bottomPanel.add(new JScrollPane(this.offlineList), BorderLayout.CENTER);

    splitter.setTopComponent(topPanel);
    splitter.setBottomComponent(bottomPanel);
    this.add(splitter, BorderLayout.CENTER);

    JPanel presencePanel = new JPanel(new GridLayout(2, 1));
    presenceComboBox = new JComboBox<Status>();
    presenceComboBox.setModel(new StatusComboBoxModel());
    presenceComboBox.setRenderer(new StatusComboBoxRenderer());
    presencePanel.add(presenceComboBox);
    presenceStatusField = new JTextField();
    presencePanel.add(presenceStatusField);
    this.add(presencePanel, BorderLayout.SOUTH);

    this.setVisible(true);
  }
コード例 #25
0
 /** The constructor */
 private ReferenceEditor() {
   myComboBox.setEditable(true);
   myComboBox.setRenderer(new BasicComboBoxRenderer());
   myComboBox.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           stopCellEditing();
         }
       });
   myPanel.add(
       myComboBox,
       new GridBagConstraints(
           0,
           0,
           1,
           1,
           1.0,
           1.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.BOTH,
           new Insets(0, 0, 0, 0),
           0,
           0));
 }
コード例 #26
0
ファイル: FoodEditor.java プロジェクト: kba/neon
  public FoodEditor(JFrame parent, RItem data) {
    super(parent, "Scroll Editor: " + data.id);
    this.data = data;

    JPanel itemProps = new JPanel();
    GroupLayout layout = new GroupLayout(itemProps);
    itemProps.setLayout(layout);
    layout.setAutoCreateGaps(true);

    JLabel nameLabel = new JLabel("Name: ");
    JLabel costLabel = new JLabel("Cost: ");
    JLabel colorLabel = new JLabel("Color: ");
    JLabel charLabel = new JLabel("Character: ");
    JLabel weightLabel = new JLabel("Weight: ");
    JLabel spellLabel = new JLabel("Spell: ");
    nameField = new JTextField(15);
    costField = new JFormattedTextField(NeonFormat.getIntegerInstance());
    colorBox = new JComboBox<String>(ColorFactory.getColorNames());
    colorBox.setBackground(Color.black);
    colorBox.setRenderer(new ColorCellRenderer());
    colorBox.addActionListener(new ColorListener(colorBox));
    charField = new JFormattedTextField(getMaskFormatter("*", 'X'));
    weightField = new JFormattedTextField(NeonFormat.getFloatInstance());
    spellBox = new JComboBox<String>(loadSpells());
    JLabel nameHelpLabel = HelpLabels.getNameHelpLabel();
    JLabel costHelpLabel = HelpLabels.getCostHelpLabel();
    JLabel colorHelpLabel = HelpLabels.getColorHelpLabel();
    JLabel charHelpLabel = HelpLabels.getCharHelpLabel();
    JLabel weightHelpLabel = HelpLabels.getWeightHelpLabel();
    JLabel foodHelpLabel = HelpLabels.getFoodEffectHelpLabel();
    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(nameLabel)
                    .addComponent(nameField)
                    .addComponent(nameHelpLabel))
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(costLabel)
                    .addComponent(costField)
                    .addComponent(costHelpLabel))
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(colorLabel)
                    .addComponent(colorBox)
                    .addComponent(colorHelpLabel))
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(charLabel)
                    .addComponent(charField)
                    .addComponent(charHelpLabel))
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(weightLabel)
                    .addComponent(weightField)
                    .addComponent(weightHelpLabel))
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(spellLabel)
                    .addComponent(spellBox)
                    .addComponent(foodHelpLabel)));
    layout.setHorizontalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(nameLabel)
                    .addComponent(costLabel)
                    .addComponent(colorLabel)
                    .addComponent(charLabel)
                    .addComponent(weightLabel)
                    .addComponent(spellLabel))
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING, false)
                    .addComponent(
                        nameField,
                        GroupLayout.PREFERRED_SIZE,
                        GroupLayout.DEFAULT_SIZE,
                        GroupLayout.PREFERRED_SIZE)
                    .addComponent(costField)
                    .addComponent(colorBox)
                    .addComponent(charField)
                    .addComponent(weightField)
                    .addComponent(spellBox))
            .addGap(10)
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING, false)
                    .addComponent(nameHelpLabel)
                    .addComponent(costHelpLabel)
                    .addComponent(colorHelpLabel)
                    .addComponent(charHelpLabel)
                    .addComponent(weightHelpLabel)
                    .addComponent(foodHelpLabel)));

    JScrollPane propScroller = new JScrollPane(itemProps);
    propScroller.setBorder(new TitledBorder("Properties"));
    frame.add(propScroller, BorderLayout.CENTER);
  }
コード例 #27
0
  /**
   * Create a choicebox for link line style options and return the panel it is in.
   *
   * @return JPanel the panel holding the new choicebox for the link style options.
   */
  private JPanel createLinkDashedChoiceBox() {

    JPanel drawPanel = new JPanel(new BorderLayout());
    CSH.setHelpIDString(drawPanel, "toolbars.formatlink"); // $NON-NLS-1$

    cbLinkDashed = new JComboBox();
    cbLinkDashed.setToolTipText(
        LanguageProperties.getString(
            LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.selectDashed")); // $NON-NLS-1$
    cbLinkDashed.setOpaque(true);
    cbLinkDashed.setEditable(false);
    cbLinkDashed.setEnabled(false);
    cbLinkDashed.setMaximumRowCount(10);
    cbLinkDashed.setFont(new Font("Dialog", Font.PLAIN, 10)); // $NON-NLS-1$

    cbLinkDashed.addItem(
        new String(
            LanguageProperties.getString(
                LanguageProperties.TOOLBARS_BUNDLE,
                "UIToolBarFormatLink.plainLine"))); //$NON-NLS-1$
    cbLinkDashed.addItem(
        new String(
            LanguageProperties.getString(
                LanguageProperties.TOOLBARS_BUNDLE,
                "UIToolBarFormatLink.largeDashes"))); //$NON-NLS-1$
    cbLinkDashed.addItem(
        new String(
            LanguageProperties.getString(
                LanguageProperties.TOOLBARS_BUNDLE,
                "UIToolBarFormatLink.smallDashes"))); //$NON-NLS-1$

    cbLinkDashed.validate();

    cbLinkDashed.setSelectedIndex(0);

    DefaultListCellRenderer drawRenderer =
        new DefaultListCellRenderer() {
          public Component getListCellRendererComponent(
              JList list, Object value, int modelIndex, boolean isSelected, boolean cellHasFocus) {
            if (list != null) {
              if (isSelected) {
                setBackground(list.getSelectionBackground());
                setForeground(list.getSelectionForeground());
              } else {
                setBackground(list.getBackground());
                setForeground(list.getForeground());
              }
            }

            setText((String) value);
            return this;
          }
        };

    cbLinkDashed.setRenderer(drawRenderer);

    ActionListener drawActionListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onUpdateLinkDashed(cbLinkDashed.getSelectedIndex());
          }
        };
    cbLinkDashed.addActionListener(drawActionListener);

    drawPanel.add(new JLabel(" "), BorderLayout.WEST); // $NON-NLS-1$
    drawPanel.add(cbLinkDashed, BorderLayout.CENTER);
    return drawPanel;
  }
コード例 #28
0
  /**
   * Create a choicbox for link line thickness options and return the panel it is in.
   *
   * @return JPanel the panel holding the new choicebox for the line thickness options.
   */
  private JPanel createWeightChoiceBox() {

    JPanel drawPanel = new JPanel(new BorderLayout());
    CSH.setHelpIDString(drawPanel, "toolbars.formatlink"); // $NON-NLS-1$

    cbLineWeight = new JComboBox();
    cbLineWeight.setToolTipText(
        LanguageProperties.getString(
            LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.selectWeight")); // $NON-NLS-1$
    cbLineWeight.setOpaque(true);
    cbLineWeight.setEditable(false);
    cbLineWeight.setEnabled(false);
    cbLineWeight.setMaximumRowCount(10);
    cbLineWeight.setFont(new Font("Dialog", Font.PLAIN, 10)); // $NON-NLS-1$

    cbLineWeight.addItem(new String("1 px")); // $NON-NLS-1$
    cbLineWeight.addItem(new String("2 px")); // $NON-NLS-1$
    cbLineWeight.addItem(new String("3 px")); // $NON-NLS-1$
    cbLineWeight.addItem(new String("4 px")); // $NON-NLS-1$
    cbLineWeight.addItem(new String("5 px")); // $NON-NLS-1$
    cbLineWeight.addItem(new String("6 px")); // $NON-NLS-1$
    cbLineWeight.addItem(new String("7 px")); // $NON-NLS-1$
    cbLineWeight.addItem(new String("8 px")); // $NON-NLS-1$
    cbLineWeight.addItem(new String("9 px")); // $NON-NLS-1$
    cbLineWeight.addItem(new String("10 px")); // $NON-NLS-1$

    cbLineWeight.validate();

    cbLineWeight.setSelectedIndex(0);

    DefaultListCellRenderer drawRenderer =
        new DefaultListCellRenderer() {
          public Component getListCellRendererComponent(
              JList list, Object value, int modelIndex, boolean isSelected, boolean cellHasFocus) {
            if (list != null) {
              if (isSelected) {
                setBackground(list.getSelectionBackground());
                setForeground(list.getSelectionForeground());
              } else {
                setBackground(list.getBackground());
                setForeground(list.getForeground());
              }
            }

            setText((String) value);
            return this;
          }
        };

    cbLineWeight.setRenderer(drawRenderer);

    ActionListener drawActionListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            int ind = cbLineWeight.getSelectedIndex();

            if (ind == 0) onUpdateLinkWeight(1);
            else if (ind == 1) onUpdateLinkWeight(2);
            else if (ind == 2) onUpdateLinkWeight(3);
            else if (ind == 3) onUpdateLinkWeight(4);
            else if (ind == 4) onUpdateLinkWeight(5);
            else if (ind == 5) onUpdateLinkWeight(6);
            else if (ind == 6) onUpdateLinkWeight(7);
            else if (ind == 7) onUpdateLinkWeight(8);
            else if (ind == 8) onUpdateLinkWeight(9);
            else if (ind == 9) onUpdateLinkWeight(10);
          }
        };
    cbLineWeight.addActionListener(drawActionListener);

    drawPanel.add(new JLabel(" "), BorderLayout.WEST); // $NON-NLS-1$
    drawPanel.add(cbLineWeight, BorderLayout.CENTER);
    return drawPanel;
  }
コード例 #29
0
  /** Create the arrow head choicebox. */
  private JPanel createArrowChoiceBox() {

    JPanel drawPanel = new JPanel(new BorderLayout());
    CSH.setHelpIDString(drawPanel, "toolbars.formatlink"); // $NON-NLS-1$

    cbArrows = new JComboBox();
    cbArrows.setToolTipText(
        LanguageProperties.getString(
            LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.selectArrow")); // $NON-NLS-1$
    cbArrows.setOpaque(true);
    cbArrows.setEditable(false);
    cbArrows.setEnabled(false);
    cbArrows.setMaximumRowCount(4);
    cbArrows.setFont(new Font("Dialog", Font.PLAIN, 10)); // $NON-NLS-1$

    Vector arrows = new Vector(5);
    arrows.insertElementAt(
        LanguageProperties.getString(
            LanguageProperties.DIALOGS_BUNDLE, "UILinkEditDialog.noArrows"),
        0); //$NON-NLS-1$
    arrows.insertElementAt(
        LanguageProperties.getString(LanguageProperties.DIALOGS_BUNDLE, "UILinkEditDialog.fromTo"),
        1); //$NON-NLS-1$
    arrows.insertElementAt(
        LanguageProperties.getString(LanguageProperties.DIALOGS_BUNDLE, "UILinkEditDialog.toFfrom"),
        2); //$NON-NLS-1$
    arrows.insertElementAt(
        LanguageProperties.getString(
            LanguageProperties.DIALOGS_BUNDLE, "UILinkEditDialog.bothWays"),
        3); //$NON-NLS-1$
    DefaultComboBoxModel comboModel = new DefaultComboBoxModel(arrows);
    cbArrows.setModel(comboModel);
    cbArrows.setSelectedIndex(0);

    DefaultListCellRenderer comboRenderer =
        new DefaultListCellRenderer() {
          public Component getListCellRendererComponent(
              JList list, Object value, int modelIndex, boolean isSelected, boolean cellHasFocus) {
            if (isSelected) {
              setBackground(list.getSelectionBackground());
              setForeground(list.getSelectionForeground());
            } else {
              setBackground(list.getBackground());
              setForeground(list.getForeground());
            }

            setText((String) value);

            return this;
          }
        };
    cbArrows.setRenderer(comboRenderer);

    cbArrows.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onUpdateArrowType(cbArrows.getSelectedIndex());
          }
        });

    drawPanel.add(new JLabel(" "), BorderLayout.WEST); // $NON-NLS-1$
    drawPanel.add(cbArrows, BorderLayout.CENTER);
    return drawPanel;
  }
コード例 #30
0
 public void setRenderer(ListCellRenderer<? super Locale> newValue) {
   renderer = null;
   super.setRenderer(newValue);
 }