예제 #1
3
  /**
   * Constructor del panel
   *
   * @param ventanaPrincipal La ventana principal de la aplicación
   */
  public PanelListaRecetas(InterfazRecetario ventanaPrincipal) {
    interfaz = ventanaPrincipal;

    setLayout(new BorderLayout());
    setBorder(new CompoundBorder(new EmptyBorder(0, 5, 0, 5), new TitledBorder(" Recetas ")));
    setPreferredSize(new Dimension(250, 0));

    listaRecetas = new JList();
    listaRecetas.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    listaRecetas.addListSelectionListener(this);

    scroll = new JScrollPane(listaRecetas);

    scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scroll.setBorder(
        new CompoundBorder(new EmptyBorder(3, 3, 3, 3), new LineBorder(Color.BLACK, 1)));

    botonAgregar = new JButton(AGREGAR);
    botonAgregar.setActionCommand(AGREGAR);
    botonAgregar.addActionListener(this);

    add(scroll, BorderLayout.CENTER);
    add(botonAgregar, BorderLayout.SOUTH);
  }
예제 #2
2
  public void actionPerformed(ActionEvent ae) {
    if (ae.getActionCommand().equals(PUT)) {
      while (availableExpressions.getSelectedIndex() != -1) {
        String exp = (String) availableExpressions.getSelectedValue();
        setAsSelected(exp, true);
      }
    } else if (ae.getActionCommand().equals(PUSH)) {
      while (selectedExpressions.getSelectedRow() != -1) {
        String exp =
            (String) selectedExpressions.getValueAt(selectedExpressions.getSelectedRow(), 1);
        ((DefaultTableModel) selectedExpressions.getModel())
            .removeRow(selectedExpressions.getSelectedRow());
        ((DefaultListModel) availableExpressions.getModel()).addElement(exp);
      }
    } else if (ae.getActionCommand().equals(UP)) {
      int row = selectedExpressions.getSelectedRow();
      if (row < 1) return;
      ((DefaultTableModel) selectedExpressions.getModel()).moveRow(row, row, --row);
      selectedExpressions.setRowSelectionInterval(row, row);
      scrollToRow(row);
    } else if (ae.getActionCommand().equals(DOWN)) {
      int row = selectedExpressions.getSelectedRow();
      if (row == selectedExpressions.getRowCount() - 1) return;
      ((DefaultTableModel) selectedExpressions.getModel()).moveRow(row, row, ++row);
      selectedExpressions.setRowSelectionInterval(row, row);
      scrollToRow(row);
    }

    clauses.builder.syntax.refresh();
  }
예제 #3
1
 @Override
 public void profileSelectionChanged(final Optional<MutableProfile> profile) {
   okButton.setEnabled(model.isSaveAllowed());
   deleteProfile.setEnabled(model.getSelectedProfile().isPresent());
   if (profile.isPresent()) {
     final int index = profilesModel.indexOf(profile.get());
     selectionModel.setLeadSelectionIndex(index);
   } else {
     selectionModel.setLeadSelectionIndex(-1);
   }
   addNickname.setEnabled(model.getSelectedProfile().isPresent());
   editNickname.setEnabled(model.getSelectedProfile().isPresent());
   addHighlight.setEnabled(model.getSelectedProfile().isPresent());
   editHighlight.setEnabled(model.getSelectedProfile().isPresent());
   name.setEnabled(model.getSelectedProfile().isPresent());
   name.setText(model.getSelectedProfileName().orElse(""));
   nicknames.setEnabled(model.getSelectedProfile().isPresent());
   nicknamesModel.clear();
   nicknamesModel.addAll(model.getSelectedProfileNicknames().orElse(Lists.newArrayList()));
   highlights.setEnabled(model.getSelectedProfile().isPresent());
   highlightsModel.clear();
   highlightsModel.addAll(model.getSelectedProfileHighlights().orElse(Lists.newArrayList()));
   realname.setEnabled(model.getSelectedProfile().isPresent());
   realname.setText(model.getSelectedProfileRealname().orElse(""));
   ident.setEnabled(model.getSelectedProfile().isPresent());
   ident.setText(model.getSelectedProfileIdent().orElse(""));
 }
  /** Construct a new property panel for an ExtensionPoint. */
  public PropPanelExtensionPoint() {
    super("ExtensionPoint", ConfigLoader.getTabPropsOrientation());

    // First column

    // nameField, stereotypeBox and namespaceScroll are all set up by
    // PropPanelModelElement.

    addField(Translator.localize("label.name"), getNameTextField());

    // Our location (a String).  Allow the location label to
    // expand vertically so we all float to the top.

    JTextField locationField = new UMLTextField2(new UMLExtensionPointLocationDocument());
    addField(Translator.localize("label.location"), locationField);

    addSeparator();

    JList usecaseList = new UMLLinkedList(new UMLExtensionPointUseCaseListModel());
    usecaseList.setVisibleRowCount(1);
    addField(Translator.localize("label.usecase-base"), new JScrollPane(usecaseList));

    JList extendList = new UMLLinkedList(new UMLExtensionPointExtendListModel());
    addField(Translator.localize("label.extend"), new JScrollPane(extendList));

    addAction(new ActionNavigateContainerElement());
    addAction(new ActionNewExtensionPoint());
    addAction(new ActionNewStereotype());
    addAction(getDeleteAction());
  }
  /**
   * Attempts to search the mod website for the mod and pull the recent versions of the mod.
   *
   * @param mod The Mod to search for on the website.
   * @param modInfoList The JList to populate/alter.
   */
  public void getRecentVersionsOfModAsync(Profile.Mod mod, JList modInfoList) {
    // Here we set a thread task to get the version numbers for the mod. This will look at the site
    // and search for the mod, then pull all versions from it.
    Runnable task = () -> Crawler.readVersionInfoOfMod(mod.nameWithoutVersion);
    Thread thread = new Thread(task);
    thread.start();

    // Our timer that checks every 200ms if the thread has finished.
    Timer timer = new Timer(200, null);
    timer.addActionListener(
        ev -> {
          if (thread.getState() != Thread.State.TERMINATED) timer.restart();
          else {
            timer.stop();
            DefaultListModel listModel = (DefaultListModel) modInfoList.getModel();
            // Get the modVersionInfo from the crawler. If not null, add to the list.
            String[][] modVersionInfo = Crawler.getModVersionInfo();
            if (modVersionInfo != null) {
              listModel.addElement("Recent Versions:");
              for (String[] info : modVersionInfo) {
                listModel.addElement("    v" + info[0] + " for " + info[1]);
              }
            } else {
              listModel.addElement("Couldn't find the mod on the website.");
            }
            modInfoList.setModel(listModel);
          }
        });
    timer.start();
  }
 @Override
 public void valueChanged(ListSelectionEvent event) {
   System.out.println(event.toString());
   JList list = (JList) event.getSource();
   if (list.getSelectedValue() != null) {
     // check
     String buttonText = list.getSelectedValue().toString();
     item = model.getCatalog().getItem(buttonText);
     if (item instanceof PizzaSize) {
       setView(
           "Size",
           ((PizzaSize) item).getFullName(),
           ((PizzaSize) item).getShortName(),
           ((PizzaSize) item).getPrice());
     } else if (item instanceof Sauce) {
       setView("Sauce", ((Sauce) item).getFullName(), ((Sauce) item).getShortName(), -1.0);
     } else if (item instanceof Topping) {
       setView("Topping", ((Topping) item).getFullName(), ((Topping) item).getShortName(), -1.0);
     } else if (item instanceof Side) {
       setView("Side", ((SideItem) item).getName(), null, ((SideItem) item).getPrice());
     } else if (item instanceof Drink) {
       setView("Drink", ((SideItem) item).getName(), null, ((SideItem) item).getPrice());
     }
     components.get("typeComboBox").setEnabled(false);
   }
 }
    @Override
    public Component getListCellRendererComponent(
        JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
      if (value instanceof StoryComponentPanel) {
        final StoryComponentPanel valuePanel;
        final StoryComponent valueComponent;
        final Boolean isVisible;

        valuePanel = (StoryComponentPanel) value;

        valueComponent = valuePanel.getStoryComponent();
        isVisible = valueComponent.isVisible();

        valuePanel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.LIGHT_GRAY));

        if (isVisible
            && valueComponent.getLibrary().isReadOnly()
            && !isSelected
            && SEModelManager.getInstance().getActiveModel() instanceof LibraryModel
            && !ScriptEase.DEBUG_MODE) valuePanel.setBackground(ScriptEaseUI.TERTIARY_UI);
        else if (isSelected && isVisible) valuePanel.setBackground(list.getSelectionBackground());
        else if (isSelected && !isVisible) valuePanel.setBackground(ScriptEaseUI.SELECTED_COLOUR);
        else if (!isSelected && !isVisible) valuePanel.setBackground(Color.DARK_GRAY);
        else if (!isSelected && isVisible) valuePanel.setBackground(list.getBackground());

        if (valueComponent instanceof CauseIt || valueComponent instanceof ActivityIt) {
          valuePanel.setShowChildren(false);
          valuePanel.getExpansionButton().setCollapsed(true);
        }

        return valuePanel;
      } else if (value instanceof JPanel) {
        return (JPanel) value;
      } else return new JLabel("Error: Not a story component: " + value.toString());
    }
예제 #8
0
    public void navigate(final Project project) {
      DefaultPsiElementListCellRenderer renderer = new DefaultPsiElementListCellRenderer();

      final JList list = new JList(myPsiFiles);
      list.setCellRenderer(renderer);

      renderer.installSpeedSearch(list);

      final Runnable runnable =
          new Runnable() {
            public void run() {
              int[] ids = list.getSelectedIndices();
              if (ids == null || ids.length == 0) return;
              Object[] selectedElements = list.getSelectedValues();
              for (Object element : selectedElements) {
                Navigatable descriptor = EditSourceUtil.getDescriptor((PsiElement) element);
                if (descriptor != null && descriptor.canNavigate()) {
                  descriptor.navigate(true);
                }
              }
            }
          };

      final Editor editor =
          PlatformDataKeys.EDITOR.getData(DataManager.getInstance().getDataContext());

      new PopupChooserBuilder(list)
          .setTitle("Choose file")
          .setItemChoosenCallback(runnable)
          .createPopup()
          .showInBestPositionFor(editor);
    }
    private void postMessage(final String type) {
      final String id = (String) list.getSelectedValue();
      if (id == null) {
        return;
      }
      list.clearSelection();

      //			final Endpoint endpoint = context.getEndpoint("http4://localhost:8122/");
      //			final Exchange exchange = endpoint.createExchange();
      //			exchange.getIn().setHeader(Exchange.HTTP_METHOD, "POST");
      //			exchange.getIn().setHeader(Exchange.CONTENT_TYPE, "text/plain");
      //			exchange.getIn().setBody(id + ":" + type);
      //			producerTemplate.asyncSend(endpoint, exchange);

      // final String url = "jms:queue:itk-trunk/" + id + "/" + type.split("\\|")[0];

      final String url = "jms:topic:document-ebxml-acks";
      System.out.println("Sending message to: " + url);

      final Endpoint endpoint = context.getEndpoint(url);
      final Exchange exchange = endpoint.createExchange();
      exchange.getIn().setHeader("JMSCorrelationID", id);
      exchange.getIn().setBody(type.split("\\|")[1]);
      producerTemplate.send(endpoint, exchange);
    }
예제 #10
0
 private void updateWithFont(Font aFont) {
   fontNameList.setSelectedValue(aFont.getFamily(), true);
   fontStyleList.setSelectedValue(fontStyle(aFont), true);
   fontSizeList.setSelectedValue("" + aFont.getSize(), true);
   previewLabel.setFont(aFont);
   previewLabel.setText(fontDescription(aFont));
 }
예제 #11
0
  /** Initializes GUI components */
  public void init() {
    this.setLayout(new BorderLayout());

    nodeListModel = new DefaultListModel();

    nodeList = new JList(nodeListModel);
    nodeList.setLayoutOrientation(JList.HORIZONTAL_WRAP);
    nodeList.setCellRenderer(new NodeCellRenderer(main));
    nodeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    nodeList.addMouseListener(new PopupListener(new NodeOptions(main)));

    listPane = new JScrollPane(nodeList);

    // Build the clear button
    clearButton = new JButton("Clear");
    clearButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            clearButtonPressed();
          }
        });
    clearButton.setMnemonic(KeyEvent.VK_K);
    add(listPane, BorderLayout.CENTER);
    add(clearButton, BorderLayout.SOUTH);
  }
예제 #12
0
  /**
   * Shows a string message in the client's log with the specified priority
   *
   * @param message
   * @param priority
   */
  public void show(String message, Priority priority) {
    switch (priority) {
      case LOW:
        backGC.add(Color.white);
        break;
      case NORMAL:
        backGC.add(Color.LIGHT_GRAY);
        break;
      case HIGH:
        backGC.add(Color.red);
        break;
      case SEVERE:
        backGC.add(Color.red);
        break;
    }

    if (priority.equals(Priority.SEVERE)) {
      foreGC.add(Color.white);
    } else {
      foreGC.add(Color.black);
    }

    lastMessage = message;

    listModel.addElement(formatMsg(message));
    render.setElements(backGC, foreGC);
    counter++;

    logText.ensureIndexIsVisible(logText.getLastVisibleIndex() + 1);
  }
예제 #13
0
  public void makeInterface() {
    frame = new JFrame("俄罗斯方块多人对战");

    frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    frame.setResizable(false);

    listModel = new DefaultListModel();
    listModel.ensureCapacity(100);

    list = new JList(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    list.setSelectedIndex(0);

    JButton exitButton = new JButton("Disconnect/Exit");
    exitButton.setActionCommand("exit");
    exitButton.addActionListener(this);

    JScrollPane listScroller = new JScrollPane(list);
    listScroller.setPreferredSize(new Dimension(250, 125));

    frame.getContentPane().add(listScroller, BorderLayout.CENTER);
    frame.getContentPane().add(exitButton, BorderLayout.SOUTH);

    frame.pack();
    frame.setVisible(false);
  }
예제 #14
0
  /** update our data */
  void updateData() {

    // find out which one is selected
    final int curSel = _myList.getSelectedIndex();

    // create an object to put the data into
    final Vector<WorldLocationHolder> list = new Vector<WorldLocationHolder>(0, 1);

    if (getPath() != null) {
      final int len = getPath().size();
      for (int i = 0; i < len; i++) {
        final WorldLocation thisLoc = getPath().getLocationAt(i);
        final WorldLocationHolder holder = new WorldLocationHolder(thisLoc, i + 1);
        list.add(holder);
      }
    }

    // and put the data into the list
    _myList.setListData(list);

    // select the previous item
    if (curSel != -1 && curSel < _myPath.size()) _myList.setSelectedIndex(curSel);

    // update the list
    _myPlotter.update();
  }
예제 #15
0
 private void clearSourceSelected() {
   Object selected[] = sourceList.getSelectedValues();
   for (int i = selected.length - 1; i >= 0; --i) {
     sourceListModel.removeElement(selected[i]);
   }
   sourceList.getSelectionModel().clearSelection();
 }
예제 #16
0
 public final void setCode(String code) {
   int idx = filteredData.indexOf(code);
   if (idx != -1) {
     selectionList.setSelectedIndex(idx);
     selectionList.ensureIndexIsVisible(idx);
   }
 }
예제 #17
0
 private void clearDestinationSelected() {
   Object selected[] = destList.getSelectedValues();
   for (int i = selected.length - 1; i >= 0; --i) {
     destListModel.removeElement(selected[i]);
   }
   destList.getSelectionModel().clearSelection();
 }
예제 #18
0
  // Listener method for list selection changes.
  public void valueChanged(ListSelectionEvent e) {
    if (e.getValueIsAdjusting() == false) {

      if (list.getSelectedIndex() == -1) {
        // No selection: disable delete, up, and down buttons.
        deleteButton.setEnabled(false);
        upButton.setEnabled(false);
        downButton.setEnabled(false);
        nameField.setText("");

      } else if (list.getSelectedIndices().length > 1) {
        // Multiple selection: disable up and down buttons.
        deleteButton.setEnabled(true);
        upButton.setEnabled(false);
        downButton.setEnabled(false);

      } else {
        // Single selection: permit all operations.
        deleteButton.setEnabled(true);
        upButton.setEnabled(true);
        downButton.setEnabled(true);
        nameField.setText(list.getSelectedValue().toString());
      }
    }
  }
  // -------------------------------------------------------------------------------------- //
  // ---------------------------------- Constructor Helpers ------------------------------- //
  // -------------------------------------------------------------------------------------- //
  private void buildActiveKits(JPanel container) {
    // initialize variable
    final int WIDTH = 150;

    // set containment panel properties
    container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS));
    setComponentSize(container, 150, PAGE_HEIGHT);

    JLabel header = new JLabel("Active Kits");
    header.setHorizontalAlignment(header.CENTER);
    header.setFont(new Font("Serif", Font.BOLD, 18));
    setComponentSize(header, WIDTH, 25);

    // create list model and list
    listModel = new DefaultListModel();
    kitList = new JList(listModel);
    kitList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    kitList.addListSelectionListener(this);
    kitList.setFixedCellHeight(25);
    JScrollPane listScrollPane = new JScrollPane(kitList);

    // add elements to containment panel
    container.add(header);
    container.add(listScrollPane);
  }
 private void doAdd() {
   Designer designer = Designer.theDesigner();
   String headline = headLineTextField.getText();
   int priority = ToDoItem.HIGH_PRIORITY;
   switch (priorityComboBox.getSelectedIndex()) {
     case 0:
       priority = ToDoItem.HIGH_PRIORITY;
       break;
     case 1:
       priority = ToDoItem.MED_PRIORITY;
       break;
     case 2:
       priority = ToDoItem.LOW_PRIORITY;
       break;
   }
   String desc = descriptionTextArea.getText();
   String moreInfoURL = moreinfoTextField.getText();
   ListSet newOffenders = new ListSet();
   for (int i = 0; i < offenderList.getModel().getSize(); i++) {
     newOffenders.add(offenderList.getModel().getElementAt(i));
   }
   ToDoItem item = new UMLToDoItem(designer, headline, priority, desc, moreInfoURL, newOffenders);
   designer.getToDoList().addElement(item); // ? inform()
   Designer.firePropertyChange(Designer.MODEL_TODOITEM_ADDED, null, item);
 }
  private void initDialog(final DesignTimeContext designTimeContext) {
    if (designTimeContext == null) {
      throw new NullPointerException();
    }

    this.designTimeContext = designTimeContext;

    editParameterAction = new EditParameterAction();
    editParameterAction.setEnabled(false);

    queryListModel = new DefaultListModel();

    queryNameList = new JList(queryListModel);
    queryNameList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    queryNameList.setVisibleRowCount(5);
    queryNameList.addListSelectionListener(new QueryNameListSelectionListener());

    fileTextField = new JTextField(30);
    fileTextField.setEnabled(false);
    fileTextField.getDocument().addDocumentListener(new FileSyncHandler());

    stepsList = new JList();
    stepsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    stepsList.addListSelectionListener(new StepsListListener());

    nameTextField = new JTextField(30);
    nameTextField.setEnabled(false);
    nameTextField.getDocument().addDocumentListener(new NameSyncHandler());

    setTitle(Messages.getString("KettleDataSourceDialog.Title"));
    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    setModal(true);

    super.init();
  }
예제 #22
0
  /** Initializes the config list. */
  private void initList() {
    configList.setModel(new DefaultListModel());
    configList.setCellRenderer(new ConfigListCellRenderer());
    configList.addListSelectionListener(this);
    configList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    JScrollPane configScrollList = new JScrollPane();

    configScrollList.getVerticalScrollBar().setUnitIncrement(30);

    configScrollList.getViewport().add(configList);

    add(configScrollList, BorderLayout.WEST);

    String osgiFilter =
        "(" + ConfigurationForm.FORM_TYPE + "=" + ConfigurationForm.ADVANCED_TYPE + ")";
    ServiceReference[] confFormsRefs = null;
    try {
      confFormsRefs =
          AdvancedConfigActivator.bundleContext.getServiceReferences(
              ConfigurationForm.class.getName(), osgiFilter);
    } catch (InvalidSyntaxException ex) {
    }

    if (confFormsRefs != null) {
      for (int i = 0; i < confFormsRefs.length; i++) {
        ConfigurationForm form =
            (ConfigurationForm) AdvancedConfigActivator.bundleContext.getService(confFormsRefs[i]);

        if (form.isAdvanced()) this.addConfigForm(form);
      }
    }
  }
예제 #23
0
  /*
   *  Adjust the width of the scrollpane used by the popup
   */
  protected void popupWider(BasicComboPopup popup) {
    JList list = popup.getList();

    //  Determine the maximimum width to use:
    //  a) determine the popup preferred width
    //  b) limit width to the maximum if specified
    //  c) ensure width is not less than the scroll pane width

    int popupWidth =
        list.getPreferredSize().width
            + 5 // make sure horizontal scrollbar doesn't appear
            + getScrollBarWidth(popup, scrollPane);

    if (maximumWidth != -1) {
      popupWidth = Math.min(popupWidth, maximumWidth);
    }

    Dimension scrollPaneSize = scrollPane.getPreferredSize();
    popupWidth = Math.max(popupWidth, scrollPaneSize.width);

    //  Adjust the width

    scrollPaneSize.width = popupWidth;
    scrollPane.setPreferredSize(scrollPaneSize);
    scrollPane.setMaximumSize(scrollPaneSize);
  }
예제 #24
0
  private void doSave() {
    ContactProps contact = new ContactProps();
    for (AccessInterface infoField : infoFields)
      contact.setProperty(infoField.getContactKey(), infoField.getContent());
    String newname = contact.getProperty(ContactProps.NAME);
    if (newname == null || newname.trim().equals("")) {
      AddrBookProps.save(addrbook);
      return;
    }
    if (contactList.getSelectedIndex() != -1) {
      String oldname = (String) contactList.getSelectedValue();
      if (oldname.equals(newname)) { // 同名
        addrbook.put(contact.getProperty(ContactProps.NAME), contact);
      } else { // 改变名字
        if (addrbook.containsKey(newname)) { // 名字冲突
        } else { // 名字不冲突
          addrbook.remove(oldname);
          addrbook.put(newname, contact);
        }
      }
    } else {

      if (addrbook.containsKey(newname)) { // 名字冲突
      } else { // 名字不冲突
        addrbook.put(newname, contact);
      }
    }
    refreshContactList();
    contactList.setSelectedValue(newname, true);
    AddrBookProps.save(addrbook);
  }
예제 #25
0
  // Take the incoming string and wherever there is a
  // newline, break it into a separate item in the list.
  protected void importString(JComponent c, String str) {
    JList target = (JList) c;
    DefaultListModel listModel = (DefaultListModel) target.getModel();
    int index = target.getSelectedIndex();

    // Prevent the user from dropping data back on itself.
    // For example, if the user is moving items #4,#5,#6 and #7 and
    // attempts to insert the items after item #5, this would
    // be problematic when removing the original items.
    // So this is not allowed.
    if (indices != null && index >= indices[0] - 1 && index <= indices[indices.length - 1]) {
      indices = null;
      return;
    }

    int max = listModel.getSize();
    if (index < 0) {
      index = max;
    } else {
      index++;
      if (index > max) {
        index = max;
      }
    }
    String[] values = str.split("\n");
    for (int i = 0; i < values.length; i++) {
      listModel.add(index++, values[i]);
    }
  }
    @Override
    protected void customizeCellRenderer(
        JList list, Object value, int index, boolean selected, boolean hasFocus) {
      setIcon(myListEntryIcon);
      if (myUseIdeaEditor) {
        int max = list.getModel().getSize();
        String indexString = String.valueOf(index + 1);
        int count = String.valueOf(max).length() - indexString.length();
        char[] spaces = new char[count];
        Arrays.fill(spaces, ' ');
        String prefix = indexString + new String(spaces) + "  ";
        append(prefix, SimpleTextAttributes.GRAYED_ATTRIBUTES);
      } else if (UIUtil.isUnderGTKLookAndFeel()) {
        // Fix GTK background
        Color background =
            selected ? UIUtil.getListSelectionBackground() : UIUtil.getListBackground();
        UIUtil.changeBackGround(this, background);
      }
      String text = ((Item) value).shortText;

      FontMetrics metrics = list.getFontMetrics(list.getFont());
      int charWidth = metrics.charWidth('m');
      int maxLength = list.getParent().getParent().getWidth() * 3 / charWidth / 2;
      text = StringUtil.first(text, maxLength, true); // do not paint long strings
      append(text, SimpleTextAttributes.REGULAR_ATTRIBUTES);
    }
 private void jbInit() throws Exception {
   this.setSize(new Dimension(560, 293));
   setTitle("Please select a contact to send");
   _scrollPaneContactList.setBounds(15, 10, 530, 237);
   _listContactList.setOpaque(false);
   _listContactList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   _listContactList.setCellRenderer(new ContactListRenderer());
   _listContactList.addListSelectionListener(
       new ListSelectionListener() {
         public void valueChanged(ListSelectionEvent listSelectionEvent) {
           _listContactList_valueChanged(listSelectionEvent);
         }
       });
   _listContactList.setVisibleRowCount(JLIST_VISIBLE_ROW_COUNT);
   _scrollPaneContactList.addScrollUpButtonActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent actionEvent) {
           _scrollPaneContactList_scrollUp(actionEvent);
         }
       });
   _scrollPaneContactList.addScrollDownButtonActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent actionEvent) {
           _scrollPaneContactList_scrollDown(actionEvent);
         }
       });
   _scrollPaneContactList.addToViewport(_listContactList);
   _panelContent.add(_scrollPaneContactList, null);
 }
예제 #28
0
 public void valueChanged(ListSelectionEvent e) {
   if (!e.getValueIsAdjusting()) {
     if (userInputListener.isModified()) {
       // the user has modified the config, but not stored it
       int decision =
           JOptionPane.showConfirmDialog(
               this,
               "The configuration for project '"
                   + selectedProjectName
                   + "' has unsaved changes. Do you wish to save them?",
               "Save Changes?",
               JOptionPane.YES_NO_CANCEL_OPTION);
       if (decision == JOptionPane.YES_OPTION) { // store
         try {
           storeConfig(false);
         } catch (Exception ex) {
           Main.fatalError(ex);
         }
       }
       if (decision == JOptionPane.CANCEL_OPTION) {
         selection.removeListSelectionListener(this);
         selection.setSelectedValue(selectedProjectName, true);
         selection.addListSelectionListener(this);
         return;
       }
     }
     selectedProjectName = (String) selection.getSelectedValue();
     generateGUIGonfiguration(selectedProjectName);
     generateGUIDescription(selectedProjectName);
   }
 }
예제 #29
0
 @Override
 public void mousePressed(MouseEvent e) {
   rightClick = AppD.isRightClick(e);
   table.stopEditing();
   mousePressedRow = rowHeader.locationToIndex(e.getPoint());
   rowHeader.requestFocus();
 }
예제 #30
0
  private void addListeners() {
    myMacrosList
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent e) {
                Macro macro = getSelectedMacro();
                if (macro == null) {
                  myPreviewTextarea.setText("");
                  setOKActionEnabled(false);
                } else {
                  myPreviewTextarea.setText(macro.preview());
                  setOKActionEnabled(true);
                }
              }
            });

    // doubleclick support
    myMacrosList.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if ((e.getClickCount() == 2) && (getSelectedMacro() != null)) {
              close(OK_EXIT_CODE);
            }
          }
        });
  }