/** Listener to handle button actions */
 public void actionPerformed(ActionEvent e) {
   // Check if the user changed the service filter option
   if (e.getSource() == service_box) {
     service_list.setEnabled(service_box.isSelected());
     service_list.clearSelection();
     remove_service_button.setEnabled(false);
     add_service_field.setEnabled(service_box.isSelected());
     add_service_field.setText("");
     add_service_button.setEnabled(false);
   }
   // Check if the user pressed the add service button
   if ((e.getSource() == add_service_button) || (e.getSource() == add_service_field)) {
     String text = add_service_field.getText();
     if ((text != null) && (text.length() > 0)) {
       service_data.addElement(text);
       service_list.setListData(service_data);
     }
     add_service_field.setText("");
     add_service_field.requestFocus();
   }
   // Check if the user pressed the remove service button
   if (e.getSource() == remove_service_button) {
     Object[] sels = service_list.getSelectedValues();
     for (int i = 0; i < sels.length; i++) {
       service_data.removeElement(sels[i]);
     }
     service_list.setListData(service_data);
     service_list.clearSelection();
   }
 }
 private void showSubscriptionInfo(
     final ApplicationSubscriptionInfo.ApplicationSendingSubscription clientSendingSubscription) {
   _receiverList.clearSelection();
   _label.setText(
       "<html>"
           + "<b>Objekt: </b>"
           + clientSendingSubscription.getObject()
           + "<br>"
           + "<b>Attributgruppe: </b>"
           + clientSendingSubscription.getUsage().getAttributeGroup()
           + "<br>"
           + "<b>Aspekt: </b>"
           + clientSendingSubscription.getUsage().getAspect()
           + "<br>"
           + "<b>Simulationsvariante: </b>"
           + clientSendingSubscription.getSimVar()
           + "<br>"
           + "<b>Typ: </b>"
           + (clientSendingSubscription.isSource() ? "Quelle" : "Sender")
           + "<br>"
           + "<b>Unterstützt Sendesteuerung: </b>"
           + (clientSendingSubscription.isRequestSupported() ? "Ja" : "Nein")
           + "<br>"
           + "<b>Status: </b>"
           + stateToString(clientSendingSubscription.getState()));
 }
 private void showSubscriptionInfo(
     final ApplicationSubscriptionInfo.ApplicationReceivingSubscription
         clientReceivingSubscription) {
   _senderList.clearSelection();
   _label.setText(
       "<html>"
           + "<b>Objekt: </b>"
           + clientReceivingSubscription.getObject()
           + "<br>"
           + "<b>Attributgruppe: </b>"
           + clientReceivingSubscription.getUsage().getAttributeGroup()
           + "<br>"
           + "<b>Aspekt: </b>"
           + clientReceivingSubscription.getUsage().getAspect()
           + "<br>"
           + "<b>Simulationsvariante: </b>"
           + clientReceivingSubscription.getSimVar()
           + "<br>"
           + "<b>Typ: </b>"
           + (clientReceivingSubscription.isDrain() ? "Senke" : "Empfänger")
           + "<br>"
           + "<b>Nachgelieferte Daten: </b>"
           + (clientReceivingSubscription.isDelayed() ? "Ja" : "Nein")
           + "<br>"
           + "<b>Nur Änderungen: </b>"
           + (clientReceivingSubscription.isDelta() ? "Ja" : "Nein")
           + "<br>"
           + "<b>Status: </b>"
           + stateToString(clientReceivingSubscription.getState()));
 }
Exemplo n.º 4
0
  private void removeAllButtonActionPerformed() {
    JList selectedList = getSelectedRobotsList();
    SelectedRobotsModel selectedModel = (SelectedRobotsModel) selectedList.getModel();

    selectedRobots.clear();
    selectedList.clearSelection();
    selectedModel.changed();
    fireStateChanged();
    showInstructions();
  }
Exemplo n.º 5
0
  private void removeButtonActionPerformed() {
    JList selectedList = getSelectedRobotsList();
    SelectedRobotsModel selectedModel = (SelectedRobotsModel) selectedList.getModel();
    int sel[] = selectedList.getSelectedIndices();

    for (int i = 0; i < sel.length; i++) {
      selectedRobots.remove(sel[i] - i);
    }
    selectedList.clearSelection();
    selectedModel.changed();
    fireStateChanged();
    if (selectedModel.getSize() < minRobots || selectedModel.getSize() > maxRobots) {
      showWrongNumInstructions();
    } else {
      showInstructions();
    }
  }
  private void refreshSdkList() {
    final List<Sdk> pythonSdks = myInterpreterList.getAllPythonSdks(myProject);
    Sdk projectSdk = getSdk();
    if (!myShowOtherProjectVirtualenvs) {
      VirtualEnvProjectFilter.removeNotMatching(myProject, pythonSdks);
    }
    //noinspection unchecked
    mySdkList.setModel(new CollectionListModel<Sdk>(pythonSdks));

    mySdkListChanged = false;
    if (projectSdk != null) {
      projectSdk = myProjectSdksModel.findSdk(projectSdk.getName());
      mySdkList.clearSelection();
      mySdkList.setSelectedValue(projectSdk, true);
      mySdkList.updateUI();
    }
  }
Exemplo n.º 7
0
  private void addAllButtonActionPerformed() {
    JList selectedList = getSelectedRobotsList();
    SelectedRobotsModel selectedModel = (SelectedRobotsModel) selectedList.getModel();

    for (AvailableRobotsPanel.ItemWrapper selected : availableRobotsPanel.getAvailableRobots()) {
      selectedRobots.add(selected);
    }

    selectedList.clearSelection();
    selectedModel.changed();
    fireStateChanged();
    if (selectedModel.getSize() >= minRobots && selectedModel.getSize() <= maxRobots) {
      showInstructions();
    } else if (selectedModel.getSize() > maxRobots) {
      showWrongNumInstructions();
    }

    availableRobotsPanel.getAvailableRobotsList().requestFocus();
  }
Exemplo n.º 8
0
 private void editColorsAndFonts() {
   final String toConfigure = getSelectedType().getSeverity(null).myName;
   doOKAction();
   myOptionsList.clearSelection();
   final DataContext dataContext = DataManager.getInstance().getDataContext(myPanel);
   final OptionsEditor optionsEditor = OptionsEditor.KEY.getData(dataContext);
   if (optionsEditor != null) {
     final ColorAndFontOptions colorAndFontOptions =
         optionsEditor.findConfigurable(ColorAndFontOptions.class);
     assert colorAndFontOptions != null;
     final SearchableConfigurable javaPage =
         colorAndFontOptions.findSubConfigurable(InspectionColorSettingsPage.class);
     LOG.assertTrue(javaPage != null);
     optionsEditor
         .clearSearchAndSelect(javaPage)
         .doWhenDone(
             new Runnable() {
               @Override
               public void run() {
                 final Runnable runnable = javaPage.enableSearch(toConfigure);
                 if (runnable != null) {
                   SwingUtilities.invokeLater(runnable);
                 }
               }
             });
   } else {
     ColorAndFontOptions colorAndFontOptions = new ColorAndFontOptions();
     final Configurable[] configurables = colorAndFontOptions.buildConfigurables();
     try {
       final SearchableConfigurable javaPage =
           colorAndFontOptions.findSubConfigurable(InspectionColorSettingsPage.class);
       LOG.assertTrue(javaPage != null);
       ShowSettingsUtil.getInstance()
           .editConfigurable(CommonDataKeys.PROJECT.getData(dataContext), javaPage);
     } finally {
       for (Configurable configurable : configurables) {
         configurable.disposeUIResources();
       }
       colorAndFontOptions.disposeUIResources();
     }
   }
 }
Exemplo n.º 9
0
    public void mouseClicked(MouseEvent evt) {
      // Note: we can't depend on evt.getSource() because of backward
      // compatability
      if (list != null && SwingUtilities.isLeftMouseButton(evt) && (evt.getClickCount() % 2 == 0)) {

        int index = SwingUtilities2.loc2IndexFileList(list, evt.getPoint());
        if (index >= 0) {
          File f = (File) list.getModel().getElementAt(index);
          try {
            // Strip trailing ".."
            f = ShellFolder.getNormalizedFile(f);
          } catch (IOException ex) {
            // That's ok, we'll use f as is
          }
          if (getFileChooser().isTraversable(f)) {
            list.clearSelection();
            changeDirectory(f);
          } else {
            getFileChooser().approveSelection();
          }
        }
      }
    }
Exemplo n.º 10
0
  // FUNCTION TO SIMULATE A STEP IN THE SIMULATION ON THE FRAME
  public void step() {

    /**
     * EACH TIME THE NEXT BUTTON IS PRESSED, ALL THE STATES THAT OCURRED UPTO THE CURRENT STATE ARE
     * EVALUATED. THERE IS A while STATEMENT THAT PERFORMS THIS FUNCTION AND CONTAINS A switch
     * STATEMENT WITHIN IT TO EVALUATE EACH STEP AS IT OCCURS.
     */

    ////////////////////// INITIALIZATION ///////////////////////////////////////

    // UPDATE THE STATE OF THE CACHE AND MEMORY
    for (int i = 0; i < 16; i++) {
      cachePanel.stringBlocks[i] = "";
      cachePanel.boolBlocks[i] = false;
      cachePanel.tag[i] = "";
      cachePanel.boolTags[i] = false;

      statusCacheEmpty[i] = true;
      statusCacheLRU[i] = 0;
    }
    for (int i = 0; i < 8; i++) {
      cachePanel.boolWords[i] = false;
      memoryPanel.boolWords[i] = false;
    }
    for (int i = 0; i < 32; i++) memoryPanel.boolBlocks[i] = false;

    // UPDATE THE BITS IN MAIN MEMORY ADDRESS
    tTag.setText("");
    tWord.setText("");
    tTag.setBackground(new Color(205, 205, 205));
    tWord.setBackground(new Color(205, 205, 205));

    // UPDATE THE CACHE HITS AND MISSES FIELDS
    cacheHits = 0;
    cacheMisses = 0;
    tCacheHits.setText("  0");
    tCacheMisses.setText("  0");

    // UPDATE THE VALUES USED FOR BRINGING MEMORY BLOCKS IN CACHE
    statusLRU = 0;
    memInCache = -1;
    lruCacheBlock = -1;

    // RESET THE VALUE OF addSel
    evaluateIndex = 0;

    // DISABLE ADDRESS GENERATION BUTTONS
    autoGen.setEnabled(false);
    selfGen.setEnabled(false);

    ////////////////////// END INITIALIZATION /////////////////////////////////////

    // IF Next WAS CLICKED, INCREMENT moveStatus
    if (nextClicked) moveStatus++;
    else {
      // DECREMENT moveStatus AND ENABLE NEXT SINCE IT MIGHT BE DISABLED
      moveStatus--;
      next.setEnabled(true);
    }

    // IF NO MORE back MOVES CAN BE MADE, DISABLE back BUTTON
    if (moveStatus == 0) {
      back.setEnabled(false);
      tProgress.setText(
          "You cannot go back any further."
              + "\nPlease click on \"Next\" or \"Restart\" to continue.");
      tProgress.setCaretPosition(0);

      // CLEAR THE SELECTED ADDRESS REFERENCE STRING
      addRefStrList.clearSelection();
    } else
      // ENABLE back BUTTON ONCE THE FIRST MOVE IS MADE
      back.setEnabled(true);

    // INITIALIZE THE VARIABLE THAT KEEPS TRACK OF THE STATE WE ARE CURRENTLY EVALUATING.
    int tempState = 1;

    // CONTINUE TO EVALUATE EACH STATE TILL WE REACH THE CURRENT STATE
    while (tempState <= moveStatus) {

      switch (tempState % 6) {
        case 1: // IF A NEW CYCLE IS BEGINNING, OBTAIN NEXT ADDRESS REFERENCE

          // OBTAIN THE ADDRESS REFERENCE STRING
          addRefStrList.setSelectedIndex(evaluateIndex);

          // ENSURE THAT THE LIST SCROLLS AND SELECTED INDEX IS VISIBLE
          // DUE TO REPAINTING CONSTRAINTS, ONLY DO THIS IN THE CURRENT STATE
          if (tempState == moveStatus) addRefStrList.ensureIndexIsVisible(evaluateIndex);

          // EVALUATE THE TAG, BLOCK AND WORD
          hexAddress = (String) addRefStrList.getSelectedValue();
          int intAddress = Integer.parseInt(hexAddress, 16);
          binAddress = Integer.toBinaryString(intAddress);

          // USING CLASS INTEGER'S parseInt FUNCTION RETURNS A BINARY STRING WITHOUT LEADING 0'S
          // ENSURE THAT binAddress is 8 bits
          if (binAddress.length() < 8) {
            int zeroes = 8 - binAddress.length();
            for (int i = 0; i < zeroes; i++) binAddress = '0' + binAddress;
          }

          tag = binAddress.substring(0, 5);
          word = binAddress.substring(5);

          // CALCULATE THE ACTUAL CACHE AND MEMORY BLOCKS AND WORDS IN QUESTION
          intWordDec = Integer.parseInt(word, 2);
          intBlockDecMem = Integer.parseInt(tag, 2);

          // IF THIS IS THE CURRENT STATE, UPDATE THE PROGRESS FIELD
          if (tempState == moveStatus) {
            tProgress.setText(
                "The memory address we want is obtained from the Address Reference String."
                    + "\nIt is (in hexadecimal): "
                    + hexAddress
                    + ".");
            tProgress.setCaretPosition(0);
          }

          break;

        case 2: // EVALUATE THE BITS IN MAIN MEMORY ADDRESS AND HIGHLIGHT THEM

          // IF THIS IS THE CURRENT STATE, UPDATE THE PROGRESS FIELD
          if (tempState == moveStatus) {
            tProgress.setText(
                "The hexadecimal address "
                    + hexAddress
                    + " evaluates to its binary equivalent "
                    + binAddress
                    + "."
                    + "\nHence the bits in the Main Memory Address are divided into the following fields\n"
                    + tag
                    + " --> Tag,  "
                    + word
                    + " --> Word."
                    + "\nThe tag bits identify the memory block, "
                    + "and the word bits identify the word within the block.");
            tProgress.setCaretPosition(0);

            // HIGHLIGHT THE BITS IN MAIN MEMORY ADDRESS IN GREEN
            tTag.setBackground(Color.green);
            tWord.setBackground(Color.green);
          }

          tTag.setText("      " + tag);
          tWord.setText("  " + word);

          break;

        case 3: // FIND THE CACHE BLOCK IN QUESTION AND HIGHLIGHT IT

          // UNDO HIGHLIGHTS OF PREVIOUS STEP
          tTag.setBackground(new Color(205, 205, 205));
          tWord.setBackground(new Color(205, 205, 205));

          // IF THIS IS THE CURRENT STATE, UPDATE THE PROGRESS FIELD
          if (tempState == moveStatus) {
            tProgress.setText(
                "Every time a memory block is placed in cache, its tag field is stored with it as well."
                    + "\nSo, to find the required memory block in cache, its tag, "
                    + tag
                    + " is compared to all the valid tag fields in cache.");
            tProgress.setCaretPosition(0);
          }

          // GET THE BLOCK IN CACHE WHERE MEMORY BLOCK EXISTS, IF AT ALL
          memInCache = getCacheBlock(tag);

          // IF MEMORY BLOCK IS NOT IN CACHE...
          if (memInCache == -1) {
            if (tempState == moveStatus) {
              tProgress.append(
                  "\n\nSince the memory block is not in cache, there is a cache miss."
                      + "\nSo the block needs to be brought in from memory.");
              tProgress.setCaretPosition(0);
            }

            // GET FIRST EMPTY CACHE BLOCK, IF AVAILABLE
            emptyCacheBlock = getFirstEmptyCacheBlock();

            // IF EMPTY CACHE BLOCK IS AVAILABLE, THIS IS WHERE THE MEMORY WILL BE BROUGHT SO
            // DISPLAY IT
            if (!(emptyCacheBlock == -1)) {

              // IF THIS IS THE CURRENT STATE, UPDATE THE PROGRESS FIELD
              if (tempState == moveStatus) {
                tProgress.append(
                    "\nSince the cache has empty space, the first available block will be filled."
                        + "\nSee the highlighted cache block.");
                tProgress.setCaretPosition(0);
              }

              // HIGHLIGHT THE CACHE BLOCK IN YELLOW
              cachePanel.boolBlocks[emptyCacheBlock] = true;
              cachePanel.boolTags[emptyCacheBlock] = true;

              // STORE THE CHANGED CACHE BLOCK INDEX IN COMMON VARIABLE
              intBlockDec = emptyCacheBlock;
            }

            // ELSE DISPLAY THE LRU CACHE BLOCK WHICH WILL BE REPLACED
            else {

              // IF THIS IS THE CURRENT STATE, UPDATE THE PROGRESS FIELD
              if (tempState == moveStatus) {
                tProgress.append(
                    "\nSince the cache is full, the least recently used cache block will be replaced."
                        + "\nSee the highlighted cache block.");
                tProgress.setCaretPosition(0);
              }

              lruCacheBlock = getLRUCacheBlock();

              // HIGHLIGHT THE CACHE BLOCK IN YELLOW
              cachePanel.boolBlocks[lruCacheBlock] = true;
              cachePanel.boolTags[lruCacheBlock] = true;

              // STORE THE CHANGED CACHE BLOCK INDEX IN COMMON VARIABLE
              intBlockDec = lruCacheBlock;
            }

            // UPDATE COUNT OF CACHE MISSES
            cacheMisses++;
            tCacheMisses.setText("  " + cacheMisses);
          } else {

            if (tempState == moveStatus) {
              tProgress.append(
                  "\n\nSince the required memory block is in cache block "
                      + memInCache
                      + " there is a cache hit.");
              tProgress.setCaretPosition(0);
            }

            // HIGHLIGHT THE CACHE BLOCK IN YELLOW
            // TO CAUSE HIGHLIGHTING ON THE CACHE, WE NEED TO MODIFY IT'S STATE, i.e. IT'S DATA
            // MEMBERS
            cachePanel.boolBlocks[memInCache] = true;
            cachePanel.boolWords[intWordDec] = true;
            cachePanel.boolTags[memInCache] = true;

            // STORE THE CHANGED CACHE BLOCK INDEX IN COMMON VARIABLE
            intBlockDec = memInCache;

            // UPDATE COUNT OF CACHE HITS
            cacheHits++;
            tCacheHits.setText("  " + cacheHits);
          }

          break;

        case 4: // EVALUATE THE MEMORY BLOCK IN QUESTION AND HIGHLIGHT IT

          // UNDO THE HIGHLIGHTS OF THE PREVIOUS STEP
          cachePanel.boolBlocks[intBlockDec] = false;
          cachePanel.boolWords[intWordDec] = false;
          cachePanel.boolTags[intBlockDec] = false;

          // IF THIS IS THE CURRENT STATE, UPDATE THE PROGRESS FIELD
          if (tempState == moveStatus) {
            tProgress.setText(
                "Highlighted is the memory block in question. Since the tag bits are "
                    + tag
                    + ", the memory block, in decimal, is "
                    + intBlockDecMem
                    + ".");
            tProgress.setCaretPosition(0);
          }

          // SET THE MEMORY STATE SO AS TO HIGHLIGHT THE REQUIRED MEMORY BLOCK
          memoryPanel.boolBlocks[intBlockDecMem] = true;

          // SET THE MEMORY STATE SO AS TO HIGHLIGHT THE REQUIRED WORD
          memoryPanel.boolWords[intWordDec] = true;

          break;

        case 5: // HIGHLIGHT THE CACHE BLOCK WITH THE MEMORY BLOCK NOW IN IT

          // UNDO HIGHLIGHTS OF PREVIOUS STEP
          memoryPanel.boolBlocks[intBlockDecMem] = false;
          memoryPanel.boolWords[intWordDec] = false;

          /*
           * NOW, THERE ARE 3 WAYS TO GO FROM HERE
           * 1. IF THERE IS AN EMPTY CACHE BLOCK, SIMPLY BRING THE MEMORY BLOCK INTO CACHE
           * 2. IF THE REQUIRED MEMORY BLOCK IS ALREADY IN CACHE, DO NOTHING
           * 3. IF THE CACHE IS FULL, FIND THE LRU BLOCK AND REPLACE IT WITH THE REQUIRED MEMORY BLOCK
           */

          // IF THE MEMORY BLOCK WAS NOT IN CACHE AND AN EMPTY CACHE BLOCK IS AVAILABLE
          // BRING THE MEMORY BLOCK AND TAG INTO CACHE AND HIGHLIGHT CACHE BLOCK
          if ((memInCache == -1) && !(emptyCacheBlock == -1)) {

            // IF THIS IS THE CURRENT STATE, UPDATE THE PROGRESS FIELD
            if (tempState == moveStatus) {
              tProgress.setText(
                  "As we saw earlier, the required memory block was not in cache."
                      + "\nSince there was empty space in cache, we brought the memory block into it."
                      + "\nWe also stored the tag, "
                      + tag
                      + ", of the memory block with the cache block."
                      + "\n\nRemember that the memory block could be brought into any empty cache block."
                      + "\nIn our example, we are using the first available empty block.");
              tProgress.setCaretPosition(0);
            }

            // UPDATE THE COUNTER FOR THE LRU CACHE BLOCK
            statusLRU++;
            statusCacheLRU[emptyCacheBlock] = statusLRU;
            statusCacheEmpty[emptyCacheBlock] = false;

            // UPDATE THE CACHE ARRAYS KEEPING TRACK OF MEMORY BLOCKS AND TAGS
            cachePanel.stringBlocks[emptyCacheBlock] = "" + intBlockDecMem;
            cachePanel.tag[emptyCacheBlock] = tag;

            // HIGHLIGHT THE CACHE BLOCK IN YELLOW
            cachePanel.boolBlocks[emptyCacheBlock] = true;
            cachePanel.boolWords[intWordDec] = true;
            cachePanel.boolTags[emptyCacheBlock] = true;

            // STORE THE CHANGED CACHE BLOCK INDEX IN COMMON VARIABLE
            intBlockDec = emptyCacheBlock;

          } // END IF

          // IF MEMORY BLOCK IS ALREADY IN CACHE THEN JUST HIGHLIGHT THE CACHE BLOCK
          else if ((memInCache >= 0) && (memInCache < 16)) {

            // IF THIS IS THE CURRENT STATE, UPDATE THE PROGRESS FIELD
            if (tempState == moveStatus) {
              tProgress.setText(
                  "As we saw earlier, the required memory block is already in cache.");
              tProgress.setCaretPosition(0);
            }

            // UPDATE THE COUNTER FOR THE LRU CACHE BLOCK
            statusLRU++;
            statusCacheLRU[memInCache] = statusLRU;

            // HIGHLIGHT THE CACHE BLOCK IN YELLOW
            cachePanel.boolBlocks[memInCache] = true;
            cachePanel.boolWords[intWordDec] = true;
            cachePanel.boolTags[memInCache] = true;

            // STORE THE CHANGED CACHE BLOCK INDEX IN COMMON VARIABLE
            intBlockDec = memInCache;

          } // END ELSE IF

          // IF THE MEMORY BLOCK IS NOT IN CACHE AND THE CACHE IS FULL
          // FIND THE LRU CACHE BLOCK AND REPLACE IT WITH THE MEMORY BLOCK, THEN HIGHLIGHT THE CACHE
          // BLOCK
          else {

            // FIND THE LRU CACHE BLOCK
            lruCacheBlock = getLRUCacheBlock();

            // IF THIS IS THE CURRENT STATE, UPDATE THE PROGRESS FIELD
            if (tempState == moveStatus) {
              tProgress.setText(
                  "As we saw earlier, the cache is full."
                      + "\nSo we picked the least recently used cache block, "
                      + lruCacheBlock
                      + ", and replaced it with the required memory block.");
              tProgress.setCaretPosition(0);
            }

            // UPDATE THE COUNTER FOR THE LRU CACHE BLOCK
            statusLRU++;
            statusCacheLRU[lruCacheBlock] = statusLRU;
            statusCacheEmpty[lruCacheBlock] = false; // redundant stmt

            // UPDATE THE CACHE ARRAYS KEEPING TRACK OF MEMORY BLOCKS AND TAGS
            cachePanel.stringBlocks[lruCacheBlock] = "" + intBlockDecMem;
            cachePanel.tag[lruCacheBlock] = tag;

            // HIGHLIGHT THE CACHE BLOCK IN YELLOW
            cachePanel.boolBlocks[lruCacheBlock] = true;
            cachePanel.boolWords[intWordDec] = true;
            cachePanel.boolTags[lruCacheBlock] = true;

            // STORE THE CHANGED CACHE BLOCK INDEX IN COMMON VARIABLE
            intBlockDec = lruCacheBlock;
          } // END ELSE

          break;

        case 0: // LAST STEP IN CYCLE - CLEANUP STEP!

          // UNDO HIGHLIGHTS OF PREVIOUS STEP
          cachePanel.boolBlocks[intBlockDec] = false;
          cachePanel.boolWords[intWordDec] = false;
          cachePanel.boolTags[intBlockDec] = false;

          tTag.setText("");
          tWord.setText("");

          tTag.setBackground(new Color(205, 205, 205));
          tWord.setBackground(new Color(205, 205, 205));

          // CLEAR THE SELECTED ADDRESS REFERENCE STRING
          addRefStrList.clearSelection();

          // INCREMENT THE INDEX SO AS TO POINT TO THE NEXT ADDRESS REFERENCE STRING
          evaluateIndex++;

          // IF THE LAST ADDRESS REFERENCE STRING HAS BEEN REACHED, DO THE APPROPRIATE
          if (evaluateIndex == listData.size()) {

            if (tempState == moveStatus) {
              tProgress.setText(
                  "This completes the runthrough."
                      + "\nPlease click on \"Restart\", generate the Address Reference String "
                      + "OR click \"Quit\" to finish.");
              tProgress.setCaretPosition(0);
            }
            next.setEnabled(false);

            // ENABLE ADDRESS GENERATION BUTTONS
            autoGen.setEnabled(true);
            selfGen.setEnabled(true);

            reStarted = false;
          }

          // ELSE AN ACCESS CYCLE HAS BEEN COMPLETED SO SHOW THE APPROPRIATE MESSAGE IN THE PROGRESS
          // FIELD
          else {
            if (tempState == moveStatus) {
              tProgress.setText("This completes an access cycle.");
              tProgress.setCaretPosition(0);
            }

            // CLEAR THE SELECTION IN THE ADDRESS REFERENCE STRING
            addRefStrList.clearSelection();
          }

          break;

        default:
          JOptionPane.showMessageDialog(null, "Uh Oh, there's a problem in switch-case!");
      } // END switch

      tempState++;
    } // END while

    // CALL THE REPAINT METHOD
    repaint();
  } // END FUNCTION step
Exemplo n.º 11
0
 public void setSelected(boolean isSelected) {
   _button.setEnabled(!isSelected);
   if (!isSelected) _courseList.clearSelection();
 }
Exemplo n.º 12
0
  public void actionPerformed(ActionEvent e) {
    Object src = e.getSource();

    if (src == binfo) {
      JOptionPane.showMessageDialog(
          frame,
          "Programme crée par Sarathai\n"
              + "Licence creative commons\n"
              + "\n"
              + "Pour envoyer des fichiers sur le serveur, cliquer d'abord sur le bouton ajouter,\n"
              + "puis sélectionnez le dossier ou fichier à ajouter. Répétez cette opération autant de foi que nécessaire.\n"
              + "Puis cliquez sur le bouton envoyer en ayant d'abord rempli les champs de l'adresse ip et du port.\n"
              + "\n"
              + "Pour recevoir des fichiers sauvegardés sur le serveur, cliquez sur le bouton recevoir,\n"
              + "puis sélectionnez le ou les fichier(s) voulu(s) dans la liste de gauche, et enfin recliquez\n"
              + "sur le bouton recevoir pour importer les fichiers.\n"
              + "\n"
              + "Pour toutes les infos, bien lire le texte qui s'affiche dans le champ de texte en bas.",
          "Informations",
          JOptionPane.INFORMATION_MESSAGE);
    } else if (src == ajouter) {
      JFileChooser chooser = new JFileChooser();
      chooser.setFileFilter(chooser.getAcceptAllFileFilter());
      chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);

      int i = chooser.showOpenDialog(Fenetre.frame);
      if (i == JFileChooser.APPROVE_OPTION) {
        frame.setCursor(waitCursor);

        File file = chooser.getSelectedFile();

        if (file.isDirectory()) {
          name = file.getAbsolutePath().toString() + sep;
          selection.addElement(name);
          new WhatIDo("Ajouté à la séléction", name);
        } else {
          name = file.getAbsolutePath().toString();
          selection.addElement(name);
          new WhatIDo("Ajouté à la séléction", name);
        }
        liste.updateUI();
        enlever.setEnabled(true);
        frame.setCursor(Cursor.getDefaultCursor());
      }
    } else if (src == enlever) {
      try {
        int j = liste.getSelectedIndex();
        new WhatIDo("Supprimé de la séléction", selection.elementAt(j).toString());
        selection.removeElementAt(j);
      } catch (ArrayIndexOutOfBoundsException e1) {
        new WhatIDo("Supprimé de la séléction", selection.elementAt(0).toString());
        selection.removeElementAt(0);
      }
      if (selection.size() == 0) {
        selection.clear();
        liste.clearSelection();
        enlever.setEnabled(false);
      }
      liste.updateUI();
    } else if (src == bquitter) {
      System.exit(0);
    } else if (src == bnouveau) {
      selection.clear();
      liste.clearSelection();
      liste.updateUI();
      new WhatIDo("Nouvelle sauvegarde");
    } else if (src == benvoyer) {
      if (!selection.isEmpty()) {
        new Envoyer(selection);
      } else {
        new WhatIDo("Veuillez ajouter des fichiers ou dossiers");
      }
    } else if (src == brecevoir) {
      if (!liste.isSelectionEmpty()) {
        Vector<String> vec = new Vector<String>();
        for (int i : liste.getSelectedIndices()) {
          vec.addElement(selection.elementAt(i));
        }
        new Recevoir(vec);
      } else {
        new Recevoir();
      }
    }
  }
Exemplo n.º 13
0
 /**
  * Reset a keyword list
  *
  * @param l list to reset
  */
 public static void resetList(JList l) {
   l.clearSelection();
   //      for( int i=0; i<l.countItems(); i++ )
   //        if( l.isSelected(i) ) l.deselect(i);
   //          l.makeVisible(0);
 }