public void fillChains(Table table) {
    table.removeAll();
    if (_chains != null) {

      List list = _chains.getChildren("job_chain");
      _chainNames = new String[list.size()];
      int index = 0;
      Iterator it = list.iterator();
      while (it.hasNext()) {
        Element chain = (Element) it.next();
        String name = Utils.getAttributeValue("name", chain);
        TableItem item = new TableItem(table, SWT.NONE);

        // item.setChecked(sos.scheduler.editor.conf.listeners.DetailsListener.existDetailsParameter(null, name, null, _dom, update, true));
        if (sos.scheduler.editor.conf.listeners.DetailsListener.existDetailsParameter(
            null, name, null, _dom, update, true, null))
          item.setBackground(Options.getLightBlueColor());
        else item.setBackground(null);
        item.setText(0, name);
        item.setText(1, Utils.isAttributeValue("orders_recoverable", chain) ? "Yes" : "No");
        item.setText(2, Utils.isAttributeValue("visible", chain) ? "Yes" : "No");

        /*item.setText(0, name);
        item.setText(1, Utils.isAttributeValue("orders_recoverable", chain) ? "Yes" : "No");
        item.setText(2, Utils.isAttributeValue("visible", chain) ? "Yes" : "No");
        */
        if (!Utils.isElementEnabled("job_chain", _dom, chain)) {
          item.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));
        }
        _chainNames[index++] = name;
      }
    }
  }
 /** update Row background colors, based on binding and type conflict status. */
 public void updateRowColors() {
   int rows = table.getItemCount();
   for (int i = 0; i < rows; i++) {
     TableItem item = table.getItem(i);
     Binding binding = bindingList.get(i);
     if (!binding.isBound() || binding.hasTypeConflict()) {
       item.setBackground(colorManager.getColor(ColorManager.UNBOUND_BACKGROUND));
     } else {
       item.setBackground(colorManager.getColor(ColorManager.BOUND_BACKGROUND));
     }
   }
 }
Exemplo n.º 3
0
  public void setLeistungen(Konsultation b) {
    List<Verrechnet> lgl = Collections.emptyList();
    if (b != null) {
      lgl = b.getLeistungen();
    }
    tVerr.setRedraw(false);
    tVerr.removeAll();
    StringBuilder sdg = new StringBuilder();
    Money sum = new Money(0);
    for (Verrechnet lst : lgl) {
      sdg.setLength(0);
      int z = lst.getZahl();
      Money preis = lst.getNettoPreis().multiply(z);
      sum.addMoney(preis);
      sdg.append(z)
          .append(" ")
          .append(lst.getCode())
          .append(" ")
          .append(lst.getText()) // $NON-NLS-1$ //$NON-NLS-2$
          .append(" (")
          .append(preis.getAmountAsString())
          .append(")"); // $NON-NLS-1$ //$NON-NLS-2$
      TableItem ti = new TableItem(tVerr, SWT.WRAP);
      ti.setText(sdg.toString());
      ti.setData(lst);

      IVerrechenbar vr = lst.getVerrechenbar();
      if (vr instanceof Artikel) {
        Artikel a = (Artikel) vr;
        int abgabeEinheit = a.getAbgabeEinheit();
        if (abgabeEinheit > 0 && abgabeEinheit < a.getPackungsGroesse()) {
          ti.setImage(Images.IMG_BLOCKS_SMALL.getImage());
        }
      }

      // set table item color
      IVerrechenbar verrBar = lst.getVerrechenbar();
      if (verrBar != null) {
        Color color = UiDesk.getColorFromRGB(defaultRGB);
        String codeName = verrBar.getCodeSystemName();

        if (codeName != null) {
          String rgbColor =
              CoreHub.globalCfg.get(Preferences.LEISTUNGSCODES_COLOR + codeName, defaultRGB);
          color = UiDesk.getColorFromRGB(rgbColor);
        }
        ti.setBackground(color);
      }
    }
    tVerr.setRedraw(true);
    sdg.setLength(0);
    sdg.append(Messages.VerrechnungsDisplay_billed)
        .append(sum.getAmountAsString())
        .append(")"); // $NON-NLS-1$ //$NON-NLS-2$
    hVer.setText(sdg.toString());
  }
 private void addTypeToTable(DBPConnectionType source, DBPConnectionType connectionType) {
   changedInfo.put(connectionType, source);
   TableItem item = new TableItem(typeTable, SWT.LEFT);
   item.setText(0, connectionType.getName());
   item.setText(1, CommonUtils.toString(connectionType.getDescription()));
   if (connectionType.getColor() != null) {
     Color connectionColor = UIUtils.getConnectionTypeColor(connectionType);
     item.setBackground(0, connectionColor);
     item.setBackground(1, connectionColor);
     colorPicker.add(null, COLOR_TEXT, connectionColor, connectionColor);
   }
   item.setData(connectionType);
 }
 private void updateTableInfo() {
   DBPConnectionType connectionType = getSelectedType();
   for (TableItem item : typeTable.getItems()) {
     if (item.getData() == connectionType) {
       item.setText(0, connectionType.getName());
       item.setText(1, connectionType.getDescription());
       Color connectionColor = UIUtils.getConnectionTypeColor(connectionType);
       item.setBackground(0, connectionColor);
       item.setBackground(1, connectionColor);
       break;
     }
   }
 }
Exemplo n.º 6
0
  /*
   * Handle the set data event. Set the item data of the requested item to the
   * corresponding proposal in the proposal cache.
   */
  private void handleSetData(Event event) {
    TableItem item = (TableItem) event.item;
    int index = proposalTable.indexOf(item);

    int proposalIndex = 0;
    for (String provider : proposalList.getProviderList()) {
      if (index == proposalIndex) {
        int count = proposalList.getCount(provider);
        String text = provider + " (" + count + " matching items)";
        item.setText(text);
        // Data == null => not selectable
        item.setData(null);

        Display display = Display.getCurrent();
        Color color = display.getSystemColor(SWT.COLOR_GRAY);
        FontData fontData = item.getFont().getFontData()[0];
        Font font =
            new Font(
                display,
                new FontData(fontData.getName(), fontData.getHeight(), SWT.ITALIC | SWT.BOLD));
        item.setBackground(color);
        item.setFont(font);

        return;
      }
      proposalIndex++;
      for (IContentProposal proposal : proposalList.getProposals(provider)) {
        if (index == proposalIndex) {
          item.setText("  " + getString(proposal));
          item.setImage(getImage(proposal));
          item.setData(proposal);
          return;
        }
        proposalIndex++;
      }
    }
  }
  public void fill(List<PlayerStats> alPlayerStats) {
    this.alPlayersStats = alPlayerStats;
    this.setRedraw(false);
    this.remove(0, this.getItemCount() - 1);
    if (alPlayerStats == null) {
      this.setRedraw(true);
      return;
    }
    for (PlayerStats playerStats : alPlayerStats) {
      TableItem item = new TableItem(this, SWT.NONE);
      if (playerStats.getFormation() == PlayerStats.GK) {
        item.setBackground(Colors.getPositionGK());
      } else if (playerStats.getFormation() == PlayerStats.DEF) {
        item.setBackground(Colors.getPositionDEF());
      } else if (playerStats.getFormation() == PlayerStats.MID) {
        item.setBackground(Colors.getPositionMID());
      } else if (playerStats.getFormation() == PlayerStats.ATT) {
        item.setBackground(Colors.getPositionATT());
      }
      int i = 0;
      if (playerStats.getTimeOut() > 0 && playerStats.getTimeIn() == 0) {
        item.setImage(i++, ImageResources.getImageResources("down_icon.png"));
      } else if (playerStats.getTimeIn() > 0 && playerStats.getTimeOut() == 0) {
        item.setImage(i++, ImageResources.getImageResources("up_icon.png"));
      } else if (playerStats.getTimeIn() > 0 && playerStats.getTimeOut() > 0) {
        item.setImage(i++, ImageResources.getImageResources("in_out.png"));
      } else {
        i++;
      }

      if (playerStats.getTimeIn() > 0) {
        item.setText(i++, "R" + playerStats.getNumber());
      } else if (playerStats.getTimePlayed() == 0) {
        item.setText(i++, "R");
      } else {
        item.setText(i++, String.valueOf(playerStats.getNumber()));
      }

      Player player = playerStats.getPlayer();
      if (player != null && player.getExistsInSokker() != Player.EXISTS_IN_SOKKER_UNCHECKED) {
        if (player.getExistsInSokker() == Player.EXISTS_IN_SOKKER_TRUE
            || player.getExistsInSokker() == Player.EXISTS_IN_SOKKER_COMPLETED) {
          item.setImage(i, FlagsResources.getFlag(player.getCountryfrom()));
          if (player.getName() == null
              || player.getSurname() == null
              || (player.getName().isEmpty() && player.getSurname().isEmpty())) {
            item.setText(i++, String.valueOf(playerStats.getPlayerId()));
          } else {
            if (player.getName().isEmpty()) {
              item.setText(i++, String.format("%s", player.getSurname()));
            } else {
              item.setText(
                  i++,
                  String.format("%s %s.", player.getSurname(), player.getName().substring(0, 1)));
            }
          }
        } else {
          item.setImage(i, FlagsResources.getFlag(FlagsResources.EMPTY_FLAG));
          item.setText(i++, String.valueOf(playerStats.getPlayerId() + " (n/a)"));
        }
      } else {
        item.setImage(i, FlagsResources.getFlag(FlagsResources.QUESTION_FLAG));
        item.setText(i++, String.valueOf(playerStats.getPlayerId() + " (n/d)"));
      }

      if (playerStats.getFormation() >= 0 && playerStats.getFormation() <= 4) {
        item.setText(i++, Messages.getString("formation." + playerStats.getFormation()));
      } else {
        item.setText(i++, "");
      }

      if (playerStats.getTimePlayed() == 0) {
        item.setForeground(ColorResources.getDarkGray());
        item.setBackground(ColorResources.getWhite());
      }
      item.setText(i++, playerStats.getTimePlayed() + "'");

      item.setText(i++, playerStats.getRating() + "%");
      item.setText(i++, String.valueOf(playerStats.getGoals()));
      item.setText(i++, String.valueOf(playerStats.getShoots()));
      item.setText(i++, String.valueOf(playerStats.getAssists()));
      item.setText(i++, String.valueOf(playerStats.getFouls()));

      item.setText(i, "");
      if (SettingsHandler.IS_WINDOWS) {
        item.setBackground(i, this.getBackground());
      }

      if (playerStats.getIsInjured() == PlayerStats.INJURED) {
        item.setImage(i++, ImageResources.getImageResources("injury.png"));
      } else {
        i++;
      }

      item.setText(i, "");
      if (SettingsHandler.IS_WINDOWS) {
        item.setBackground(i, this.getBackground());
      }
      if (playerStats.getYellowCards() < 2 && playerStats.getRedCards() > 0) {
        item.setImage(i++, ImageResources.getImageResources("red_card.png"));
      } else if (playerStats.getYellowCards() > 1 && playerStats.getRedCards() > 0) {
        item.setImage(i++, ImageResources.getImageResources("2_yellow_cards_1_red_card.png"));
      } else if (playerStats.getYellowCards() == 1 && playerStats.getRedCards() < 1) {
        item.setImage(i++, ImageResources.getImageResources("yellow_card.png"));
      } else if (playerStats.getYellowCards() > 1 && playerStats.getRedCards() < 1) {
        item.setImage(i++, ImageResources.getImageResources("2_yellow_cards.png"));
      } else {
        i++;
      }
      // item.setText(i++, String.valueOf(playerStats.getYellowCards() + "
      // " +
      // playerStats.getRedCards()));
    }
    for (int i = 0; i < this.getColumnCount() - 1; i++) {

      if (i == 0) {
        this.getColumn(i).setWidth(25);
      } else {
        this.getColumn(i).pack();
      }
      // else {
      // this.getColumn(i).setWidth(this.getColumn(i).getWidth() + 3);
      // }
    }

    // for (int i = 0; i < this.getItemCount(); i++) {
    // if ((i % 2) == 1) {
    // this.getItem(i).setBackground(this.getDisplay().getSystemColor(SWT.COLOR_GRAY));
    // }
    // }
    this.setRedraw(true);
    // table.pack();
    // table.computeSize(SWT.DEFAULT, SWT.DEFAULT);
  }
Exemplo n.º 8
0
  /*
   * Caches the specified proposals and repopulates the table if it has been
   * created.
   */
  private void setProposals(ContentProposalList newProposalList) {
    if (newProposalList == null || newProposalList.length() == 0) {
      newProposalList = getEmptyProposalArray();
    }
    this.proposalList = newProposalList;
    if (!isValid()) return;

    // If there is a table
    if (isValid()) {
      if (USE_VIRTUAL) {
        // Set and clear the virtual table. Data will be
        // provided in the SWT.SetData event handler.
        proposalTable.setItemCount(getTableLength());
        proposalTable.clearAll();
      } else {
        // Populate the table manually
        proposalTable.setRedraw(false);

        int itemCount = newProposalList.length() + newProposalList.getProviderList().size();
        proposalTable.setItemCount(itemCount);
        TableItem[] items = proposalTable.getItems();

        int index = 0;
        for (String provider : newProposalList.getProviderList()) {
          TableItem item = items[index];
          int count = newProposalList.getCount(provider);
          String text = provider + " (" + count + " matching items)";
          item.setText(text);
          // Data == null => not selectable
          item.setData(null);

          Display display = Display.getCurrent();
          Color color = display.getSystemColor(SWT.COLOR_GRAY);
          FontData fontData = item.getFont().getFontData()[0];
          Font font =
              new Font(
                  display,
                  new FontData(fontData.getName(), fontData.getHeight(), SWT.ITALIC | SWT.BOLD));
          item.setBackground(color);
          item.setFont(font);

          index++;
          for (IContentProposal proposal : newProposalList.getProposals(provider)) {
            item.setText("  " + getString(proposal));
            item.setImage(getImage(proposal));
            item.setData(proposal);
            index++;
          }
        }

        proposalTable.setRedraw(true);
      }
      // Default to the first selection if there is content.
      if (newProposalList.length() > 0) {
        int index = 0;
        boolean selected = false;
        for (String provider : newProposalList.getProviderList()) {
          index++;
          if (!selected && newProposalList.getCount(provider) > 0) {
            selectProposal(index);
            selected = true;
          }
        }
      } else {
        // No selection, close the secondary popup if it was open
        if (infoPopup != null) {
          infoPopup.close();
        }
      }
    }
    footer.setText("");
  }