示例#1
0
  @Override
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == btnQAuswahl) {
      addQListBoxEintrag(dateiAuswählen());
    }
    if (e.getSource() == btnQEntfernen) {
      subQListBoxEintrag();
    }
    if (e.getSource() == btnZAuswahl) {
      addZListBoxEintrag(dateiAuswählen());
    }
    if (e.getSource() == btnZEntfernen) {
      subZListBoxEintrag();
    }
    if (e.getSource() == btnSync) {

      startCopy(
          (Path) quellJList.getSelectedValue().getValueMember(),
          (Path) zielJList.getSelectedValue().getValueMember());
    }
    if (e.getSource() == btnAbbruch) {
      setAbbruch();
    }
    if (e.getSource() == btnBackup) {
      MainNtray.bwvisible();
      this.invisible();
    }
  }
示例#2
0
文件: MoveATub.java 项目: wwake/dpij
  public void valueChanged(ListSelectionEvent e) {
    @SuppressWarnings("unchecked")
    JList<String> sender = (JList<String>) e.getSource();

    if (!sender.isSelectionEmpty()) {
      if (sender.equals(boxList())) updateTubList(sender.getSelectedValue());

      if (sender.equals(machineList())) selectedMachine = sender.getSelectedValue();

      if (sender.equals(tubList())) selectedTub = sender.getSelectedValue();
    }

    assignButton().setEnabled(!tubList().isSelectionEmpty() && !machineList().isSelectionEmpty());
  }
示例#3
0
 protected void addUndirectedArc() {
   Node firstNode = (Node) fromList.getSelectedValue();
   Node secNode = (Node) toList.getSelectedValue();
   if (!firstNode.isConnected(secNode)) {
     UndirectedArc udArc = new UndirectedArc(firstNode, secNode);
     arcListModel.addElement(udArc);
     layouter.arcAdded(udArc);
   } else {
     JOptionPane.showMessageDialog(
         null,
         "Arc from " + firstNode + " to " + secNode + " already exists!",
         "Warning",
         JOptionPane.WARNING_MESSAGE);
   }
 }
示例#4
0
 protected void addDirectedArc() {
   Node fromNode = (Node) fromList.getSelectedValue();
   Node toNode = (Node) toList.getSelectedValue();
   if (!fromNode.isChild(toNode)) {
     DirectedArc dArc = new DirectedArc(fromNode, toNode);
     arcListModel.addElement(dArc);
     layouter.arcAdded(dArc);
   } else {
     JOptionPane.showMessageDialog(
         null,
         "Arc from " + fromNode + " to " + toNode + " already exists!",
         "Warning",
         JOptionPane.WARNING_MESSAGE);
   }
 }
 @Override
 protected void doOKAction() {
   apply((SeverityBasedTextAttributes) myOptionsList.getSelectedValue());
   final Collection<SeverityBasedTextAttributes> infoTypes =
       new HashSet<SeverityBasedTextAttributes>(
           SeverityUtil.getRegisteredHighlightingInfoTypes(mySeverityRegistrar));
   final ListModel listModel = myOptionsList.getModel();
   final List<HighlightSeverity> order = new ArrayList<HighlightSeverity>();
   for (int i = listModel.getSize() - 1; i >= 0; i--) {
     final SeverityBasedTextAttributes info =
         (SeverityBasedTextAttributes) listModel.getElementAt(i);
     order.add(info.getSeverity());
     if (!mySeverityRegistrar.isDefaultSeverity(info.getSeverity())) {
       infoTypes.remove(info);
       final Color stripeColor = info.getAttributes().getErrorStripeColor();
       mySeverityRegistrar.registerSeverity(
           info, stripeColor != null ? stripeColor : LightColors.YELLOW);
     }
   }
   for (SeverityBasedTextAttributes info : infoTypes) {
     mySeverityRegistrar.unregisterSeverity(info.getSeverity());
   }
   mySeverityRegistrar.setOrder(order);
   super.doOKAction();
 }
示例#6
0
  // ボタンが押されたときのイベント処理
  public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();

    if (cmd.equals("submit")) { // 送信
      sendMessage("msg " + msgTextField.getText());
      msgTextField.setText("");
    } else if (cmd.equals("rename")) { // 名前の変更
      sendMessage("setName " + nameTextField.getText());
    } else if (cmd.equals("addRoom")) { // 部屋を作成
      String roomName = nameTextField.getText();
      sendMessage("addRoom " + roomName);
      enteredRoom(roomName);
      sendMessage("getUsers " + roomName);
    } else if (cmd.equals("enterRoom")) { // 入室
      Object room = roomList.getSelectedValue();
      if (room != null) {
        String roomName = room.toString();
        sendMessage("enterRoom " + roomName);
        enteredRoom(roomName);
      }
    } else if (cmd.equals("exitRoom")) { // 退室
      sendMessage("exitRoom " + roomName);
      exitedRoom();
    }
  }
 @Override
 public void ok() {
   DataFlavor flavor = (DataFlavor) flavorList.getSelectedValue();
   if (flavor == null) {
     flavor = DataFlavor.stringFlavor;
   }
   Registers.paste(textArea, '$', flavor);
   dispose();
 }
  private void mRemoveNode() {
    String old_node = (String) lstNodes.getSelectedValue();

    java.util.List remove_list =
        ConfigUtilities.getElementsWithDefinition(mBroker.getElements(mContext), old_node);
    for (int i = 0; i < remove_list.size(); i++) {
      mBroker.remove(mContext, (ConfigElement) remove_list.get(i));
    }
  }
    public void valueChanged(ListSelectionEvent evt) {
      if (!evt.getValueIsAdjusting()) {
        JFileChooser chooser = getFileChooser();
        FileSystemView fsv = chooser.getFileSystemView();
        JList list = (JList) evt.getSource();

        int fsm = chooser.getFileSelectionMode();
        boolean useSetDirectory = usesSingleFilePane && (fsm == JFileChooser.FILES_ONLY);

        if (chooser.isMultiSelectionEnabled()) {
          File[] files = null;
          Object[] objects = list.getSelectedValues();
          if (objects != null) {
            if (objects.length == 1
                && ((File) objects[0]).isDirectory()
                && chooser.isTraversable(((File) objects[0]))
                && (useSetDirectory || !fsv.isFileSystem(((File) objects[0])))) {
              setDirectorySelected(true);
              setDirectory(((File) objects[0]));
            } else {
              ArrayList<File> fList = new ArrayList<File>(objects.length);
              for (Object object : objects) {
                File f = (File) object;
                boolean isDir = f.isDirectory();
                if ((chooser.isFileSelectionEnabled() && !isDir)
                    || (chooser.isDirectorySelectionEnabled() && fsv.isFileSystem(f) && isDir)) {
                  fList.add(f);
                }
              }
              if (fList.size() > 0) {
                files = fList.toArray(new File[fList.size()]);
              }
              setDirectorySelected(false);
            }
          }
          chooser.setSelectedFiles(files);
        } else {
          File file = (File) list.getSelectedValue();
          if (file != null
              && file.isDirectory()
              && chooser.isTraversable(file)
              && (useSetDirectory || !fsv.isFileSystem(file))) {

            setDirectorySelected(true);
            setDirectory(file);
            if (usesSingleFilePane) {
              chooser.setSelectedFile(null);
            }
          } else {
            setDirectorySelected(false);
            if (file != null) {
              chooser.setSelectedFile(file);
            }
          }
        }
      }
    }
示例#10
0
  void doubleClicked(JComponent src) {
    if (src == lstEntities) {
      DustEntity sel = ((LabEntity) lstEntities.getSelectedValue()).entity;

      if (!mapEntityFrames.containsKey(sel)) {
        selectEntityFrame(sel, true);
      }
    }
  }
  private void suggestCompletion(final boolean selectReplacedText, final boolean isExplicitCall) {
    if (isExplicitCall) {
      myAutopopup = true;
    }

    if (!getField().isFocusOwner()) return;

    final CompletionResult result = new CompletionResult();
    if (myList != null && myCurrentCompletion != null) {
      int index = myList.getSelectedIndex();
      if (index >= 0 && index < myList.getModel().getSize()) {
        result.myPreselected = (LookupFile) myList.getSelectedValue();
      }
    }

    myUiUpdater.queue(
        new Update("textField.suggestCompletion") {
          public void run() {
            final String completionBase = getCompletionBase();
            if (completionBase != null) {
              final LookupFile file = myFinder.find(completionBase);
              if (file != null && !file.isDirectory()) {
                // we've entered a complete path already, no need to autopopup completion again
                // (IDEA-78996)
                return;
              }
            }
            result.myCompletionBase = completionBase;
            if (result.myCompletionBase == null) return;
            result.myFieldText = myPathTextField.getText();
            ApplicationManager.getApplication()
                .executeOnPooledThread(
                    new Runnable() {
                      public void run() {
                        processCompletion(result);
                        SwingUtilities.invokeLater(
                            new Runnable() {
                              public void run() {
                                if (!result.myCompletionBase.equals(getCompletionBase())) return;

                                int pos = selectCompletionRemoveText(result, selectReplacedText);

                                showCompletionPopup(result, pos, isExplicitCall);
                              }
                            });
                      }
                    });
          }
        });
  }
  public EtatPanelDist(
      Hashtable uneHashtable, BoiteChangementEtatSommetDist parent, String defaultValue) {
    ardoise = new EtatArdoiseDist(uneHashtable, parent);
    Vector listeItems = new Vector();
    JList liste = new JList();
    JScrollPane listeAvecAscenseur;
    listeItems.addElement("A");
    listeItems.addElement("B");
    listeItems.addElement("C");
    listeItems.addElement("D");
    listeItems.addElement("E");
    listeItems.addElement("F");
    listeItems.addElement("G");
    listeItems.addElement("H");
    listeItems.addElement("I");
    listeItems.addElement("J");
    listeItems.addElement("K");
    listeItems.addElement("L");
    listeItems.addElement("M");
    listeItems.addElement("N");
    listeItems.addElement("O");
    listeItems.addElement("P");
    listeItems.addElement("Q");
    listeItems.addElement("R");
    listeItems.addElement("S");
    listeItems.addElement("T");
    listeItems.addElement("U");
    listeItems.addElement("V");
    listeItems.addElement("W");
    listeItems.addElement("X");
    listeItems.addElement("Y");
    listeItems.addElement("Z");

    liste = new JList(listeItems);
    liste.setSelectedValue(defaultValue, true);
    ardoise.changerEtat((String) liste.getSelectedValue());
    liste.addListSelectionListener(this);
    setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5));
    add(ardoise);
    listeAvecAscenseur = new JScrollPane(liste);
    listeAvecAscenseur.setPreferredSize(new Dimension(200, 80));
    add(listeAvecAscenseur);
    setVisible(true);
  }
示例#13
0
 public void actionPerformed(ActionEvent arg0) {
   if (arg0.getActionCommand().equals("Enter Hallway")) {
     if (hallList.getSelectedValue() != null) {
       outputText(model.movePlayer(hallList.getSelectedValue().toString()));
       update();
     }
   }
   if (arg0.getActionCommand().equals("Drop Item")) {
     if (playerItemsList.getSelectedValue() != null)
       model.dropItem(playerItemsList.getSelectedValue().toString());
     update();
   }
   if (arg0.getActionCommand().equals("Pick Up")) {
     if (roomItemsList.getSelectedValue() != null)
       if (model.pickItem(roomItemsList.getSelectedValue().toString())) endGame("You Win!");
     update();
   }
 }
 /**
  * @return selected stash
  * @throws NullPointerException if no stash is selected
  */
 private StashInfo getSelectedStash() {
   return (StashInfo) myStashList.getSelectedValue();
 }
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == jbSaveLayer) {
      try {
        FileOutputStream fout = new FileOutputStream(jtfCengMing.getText() + ".wyf");
        ObjectOutputStream oout = new ObjectOutputStream(fout);
        oout.writeObject(itemArray);
        oout.close();
        fout.close();
      } catch (Exception ea) {
        ea.printStackTrace();
      }
    } else if (e.getSource() == jbLoadLayer) {
      try {
        FileInputStream fin = new FileInputStream(jtfCengMing.getText() + ".wyf");
        ObjectInputStream oin = new ObjectInputStream(fin);
        itemArray = (Item[][]) oin.readObject();

        oin.close();
        fin.close();
        this.flush();
      } catch (Exception ea) {
        ea.printStackTrace();
      }
      lvp.repaint();
    } else if (e.getSource() == jbLoadAll) { // 全部铺上当前选中

      for (int row = 0; row < 40; row++) {
        for (int col = 0; col < 60; col++) {
          Item item = ((Item) (jl.getSelectedValue())).clone();
          itemArray[row][col] = item;
          if (item != null) {
            item.setPosition(col, row);
          }
        }
      }

      lvp.repaint();
    } else if (e.getSource() == jbCreate) { // 生成源代码

      try {
        FileOutputStream fout = null;
        DataOutputStream dout = null;
        fout = new FileOutputStream("maps.so");
        dout = new DataOutputStream(fout);
        int totalBlocks = 0;

        for (int i = 0; i < 40; i++) {
          for (int j = 0; j < 60; j++) {
            Item item = itemArray[i][j];
            if (item != null) {
              totalBlocks++;
            }
          }
        }
        System.out.println("totalBlocks=" + totalBlocks);

        // 写入不空块的数量
        dout.writeInt(totalBlocks);

        for (int i = 0; i < 40; i++) {
          for (int j = 0; j < 60; j++) {
            Item item = itemArray[i][j];
            if (item != null) {
              int w = item.w; // 元素的图片宽度
              int h = item.h; // 元素的图片高度
              int col = item.col; // 元素的地图列
              int row = item.row; // 元素的地图行
              int pCol = item.pCol; // 元素的占位列
              int pRow = item.pRow; // 元素的占位行
              String leiMing = item.leiMing; // 类名

              int[][] notIn = item.notIn; // 不可通过
              int[][] keYu = item.keYu; // 可遇矩阵

              // 计算图片下标
              int outBitmapInxex = 0;
              if (leiMing.equals("Grass")) {
                outBitmapInxex = 0;
              } else if (leiMing.equals("XiaoHua1")) {
                outBitmapInxex = 1;
              } else if (leiMing.equals("MuZhuang")) {
                outBitmapInxex = 2;
              } else if (leiMing.equals("XiaoHua2")) {
                outBitmapInxex = 3;
              } else if (leiMing.equals("Road")) {
                outBitmapInxex = 4;
              } else if (leiMing.equals("Jing")) {
                outBitmapInxex = 5;
              }

              dout.writeByte(outBitmapInxex); // 记录图片下标
              dout.writeByte(0); // 记录可遇标志 0-不可遇 底层都不可遇
              dout.writeByte(w); // 图片宽度
              dout.writeByte(h); // 图片高度
              dout.writeByte(col); // 总列数
              dout.writeByte(row); // 总行数
              dout.writeByte(pCol); // 占位列
              dout.writeByte(pRow); // 占位行

              int bktgCount = notIn.length; // 不可通过点的数量
              dout.writeByte(bktgCount); // 写入不可通过点的数量

              for (int k = 0; k < bktgCount; k++) {
                dout.writeByte(notIn[k][0]);
                dout.writeByte(notIn[k][1]);
              }
            }
          }
        }

        dout.close();
        fout.close();

      } catch (Exception ea) {
        ea.printStackTrace();
      }
    }
  }
示例#16
0
 protected void deleteNode() {
   Node node = (Node) fromList.getSelectedValue();
   graph.deleteNode(node);
 }
 private @Nullable LookupFile getSelectedFileFromCompletionPopup() {
   if (myList == null) return null;
   return (LookupFile) myList.getSelectedValue();
 }
 @Nullable
 public Sdk getSelectedSdk() {
   return (Sdk) mySdkList.getSelectedValue();
 }
示例#19
0
  public SeverityEditorDialog(
      final JComponent parent,
      final HighlightSeverity severity,
      final SeverityRegistrar severityRegistrar) {
    super(parent, true);
    mySeverityRegistrar = severityRegistrar;
    myOptionsList.setCellRenderer(
        new DefaultListCellRenderer() {
          @Override
          public Component getListCellRendererComponent(
              JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            final Component rendererComponent =
                super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if (value instanceof SeverityBasedTextAttributes) {
              setText(((SeverityBasedTextAttributes) value).getSeverity().toString());
            }
            return rendererComponent;
          }
        });
    myOptionsList.addListSelectionListener(
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent e) {
            if (myCurrentSelection != null) {
              apply(myCurrentSelection);
            }
            myCurrentSelection = (SeverityBasedTextAttributes) myOptionsList.getSelectedValue();
            if (myCurrentSelection != null) {
              reset(myCurrentSelection);
              myCard.show(
                  myRightPanel,
                  mySeverityRegistrar.isDefaultSeverity(myCurrentSelection.getSeverity())
                      ? DEFAULT
                      : EDITABLE);
            }
          }
        });
    myOptionsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    JPanel leftPanel =
        ToolbarDecorator.createDecorator(myOptionsList)
            .setAddAction(
                new AnActionButtonRunnable() {
                  @Override
                  public void run(AnActionButton button) {
                    final String name =
                        Messages.showInputDialog(
                            myPanel,
                            InspectionsBundle.message(
                                "highlight.severity.create.dialog.name.label"),
                            InspectionsBundle.message("highlight.severity.create.dialog.title"),
                            Messages.getQuestionIcon(),
                            "",
                            new InputValidator() {
                              @Override
                              public boolean checkInput(final String inputString) {
                                final ListModel listModel = myOptionsList.getModel();
                                for (int i = 0; i < listModel.getSize(); i++) {
                                  final String severityName =
                                      ((SeverityBasedTextAttributes) listModel.getElementAt(i))
                                          .getSeverity()
                                          .myName;
                                  if (Comparing.strEqual(severityName, inputString)) return false;
                                }
                                return true;
                              }

                              @Override
                              public boolean canClose(final String inputString) {
                                return checkInput(inputString);
                              }
                            });
                    if (name == null) return;
                    final TextAttributes textAttributes =
                        CodeInsightColors.WARNINGS_ATTRIBUTES.getDefaultAttributes();
                    HighlightInfoType.HighlightInfoTypeImpl info =
                        new HighlightInfoType.HighlightInfoTypeImpl(
                            new HighlightSeverity(name, 50),
                            TextAttributesKey.createTextAttributesKey(name));

                    SeverityBasedTextAttributes newSeverityBasedTextAttributes =
                        new SeverityBasedTextAttributes(textAttributes.clone(), info);
                    ((DefaultListModel) myOptionsList.getModel())
                        .addElement(newSeverityBasedTextAttributes);

                    myOptionsList.clearSelection();
                    ListScrollingUtil.selectItem(myOptionsList, newSeverityBasedTextAttributes);
                  }
                })
            .setMoveUpAction(
                new AnActionButtonRunnable() {
                  @Override
                  public void run(AnActionButton button) {
                    apply(myCurrentSelection);
                    ListUtil.moveSelectedItemsUp(myOptionsList);
                  }
                })
            .setMoveDownAction(
                new AnActionButtonRunnable() {
                  @Override
                  public void run(AnActionButton button) {
                    apply(myCurrentSelection);
                    ListUtil.moveSelectedItemsDown(myOptionsList);
                  }
                })
            .createPanel();
    ToolbarDecorator.findRemoveButton(leftPanel)
        .addCustomUpdater(
            new AnActionButtonUpdater() {
              @Override
              public boolean isEnabled(AnActionEvent e) {
                return !mySeverityRegistrar.isDefaultSeverity(
                    ((SeverityBasedTextAttributes) myOptionsList.getSelectedValue()).getSeverity());
              }
            });
    ToolbarDecorator.findUpButton(leftPanel)
        .addCustomUpdater(
            new AnActionButtonUpdater() {
              @Override
              public boolean isEnabled(AnActionEvent e) {
                boolean canMove = ListUtil.canMoveSelectedItemsUp(myOptionsList);
                if (canMove) {
                  SeverityBasedTextAttributes pair =
                      (SeverityBasedTextAttributes) myOptionsList.getSelectedValue();
                  if (pair != null && mySeverityRegistrar.isDefaultSeverity(pair.getSeverity())) {
                    final int newPosition = myOptionsList.getSelectedIndex() - 1;
                    pair =
                        (SeverityBasedTextAttributes)
                            myOptionsList.getModel().getElementAt(newPosition);
                    if (mySeverityRegistrar.isDefaultSeverity(pair.getSeverity())) {
                      canMove = false;
                    }
                  }
                }

                return canMove;
              }
            });
    ToolbarDecorator.findDownButton(leftPanel)
        .addCustomUpdater(
            new AnActionButtonUpdater() {
              @Override
              public boolean isEnabled(AnActionEvent e) {
                boolean canMove = ListUtil.canMoveSelectedItemsDown(myOptionsList);
                if (canMove) {
                  SeverityBasedTextAttributes pair =
                      (SeverityBasedTextAttributes) myOptionsList.getSelectedValue();
                  if (pair != null && mySeverityRegistrar.isDefaultSeverity(pair.getSeverity())) {
                    final int newPosition = myOptionsList.getSelectedIndex() + 1;
                    pair =
                        (SeverityBasedTextAttributes)
                            myOptionsList.getModel().getElementAt(newPosition);
                    if (mySeverityRegistrar.isDefaultSeverity(pair.getSeverity())) {
                      canMove = false;
                    }
                  }
                }

                return canMove;
              }
            });

    myPanel = new JPanel(new BorderLayout());
    myPanel.add(leftPanel, BorderLayout.CENTER);
    myCard = new CardLayout();
    myRightPanel = new JPanel(myCard);
    final JPanel disabled = new JPanel(new GridBagLayout());
    final JButton button =
        new JButton(InspectionsBundle.message("severities.default.settings.message"));
    button.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            editColorsAndFonts();
          }
        });
    disabled.add(
        button,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));
    myRightPanel.add(DEFAULT, disabled);
    myRightPanel.add(EDITABLE, myOptionsPanel);
    myCard.show(myRightPanel, EDITABLE);
    myPanel.add(myRightPanel, BorderLayout.EAST);
    fillList(severity);
    init();
    setTitle(InspectionsBundle.message("severities.editor.dialog.title"));
    reset((SeverityBasedTextAttributes) myOptionsList.getSelectedValue());
  }
示例#20
0
 @Nullable
 public HighlightInfoType getSelectedType() {
   final SeverityBasedTextAttributes selection =
       (SeverityBasedTextAttributes) myOptionsList.getSelectedValue();
   return selection != null ? selection.getType() : null;
 }