/**
  * Update the specified item with the new info from the resource descriptor. Create a new table
  * item if there is no item.
  *
  * @param index index of the resource descriptor
  * @param itemPos position of the existing item to update
  * @param itemCount number of items in the resources table widget
  */
 private void updateItem(int index, int itemPos, int itemCount) {
   ResourceDescriptor desc = descriptors[index];
   TableItem item;
   if (itemPos < itemCount) {
     item = resourceNames.getItem(itemPos);
     if (item.getData() != desc) {
       item.setText(desc.label);
       item.setData(desc);
       item.setImage(getImage(desc));
       if (itemPos == 0) {
         resourceNames.setSelection(0);
         updateFolders(desc);
       }
     }
   } else {
     item = new TableItem(resourceNames, SWT.NONE);
     item.setText(desc.label);
     item.setData(desc);
     item.setImage(getImage(desc));
     if (itemPos == 0) {
       resourceNames.setSelection(0);
       updateFolders(desc);
     }
   }
   updateOKState(true);
 }
  private void fillTargetData(AbstractTarget target) {
    AbstractIncrementalFileSystemMedium medium =
        (AbstractIncrementalFileSystemMedium) target.getMedium();
    File[] archives = new File[0];
    try {
      Logger.defaultLogger()
          .info(
              "Looking for archives in "
                  + medium.getFileSystemPolicy().getDisplayableParameters(true),
              "Physical View");
      archives = medium.listArchives(null, null, true);
    } catch (Throwable e) {
      this.application.handleException(e);
    }

    if (archives == null) {
      archives = new File[0];
    }

    medium.checkArchivesEncoding(archives);

    for (int i = archives.length - 1; i >= 0; i--) {
      TableItem item = new TableItem(table, SWT.NONE);
      item.setData(archives[i]);

      try {
        Manifest manifest = ArchiveManifestCache.getInstance().getManifest(medium, archives[i]);

        String prp = null;
        if (manifest != null) {
          item.setText(1, Utils.formatDisplayDate(manifest.getDate()));
          initText(item, 0, manifest);
          prp = manifest.getStringProperty(ManifestKeys.OPTION_BACKUP_SCHEME);
        }

        if ((prp != null && prp.equals(AbstractTarget.BACKUP_SCHEME_FULL)) || i == 0) {
          item.setImage(0, ArecaImages.ICO_FS_FOLDER_FULL);
        } else if (prp != null && prp.equals(AbstractTarget.BACKUP_SCHEME_DIFFERENTIAL)) {
          item.setImage(0, ArecaImages.ICO_FS_FOLDER_DIFFERENTIAL);
        } else {
          item.setImage(0, ArecaImages.ICO_FS_FOLDER);
        }
        initSize(item, 2, archives[i], medium);
      } catch (ApplicationException e) {
        application.handleException(e);
      }
    }

    /*
    if (archives.length == 0) {
    	showViewMessage();
    } else {
    	removeViewMessage();
    }
    */
  }
示例#3
0
  private void changeCurrentNode() {

    boolean hasMatchSelectedName = false;
    FileObject[] children = null;
    try {
      children = currentFileObject.getChildren();
    } catch (Exception e) {
      e.printStackTrace();
    }
    if (children == null) return;

    sortFiles(children);

    String selectedName = historyManager.getSelectedItem(currentFileObject.getName().getPath());
    table.removeAll();
    TableItem item;

    for (int i = 0; i < children.length; i++) {
      FileName fileName = children[i].getName();

      if (fileName.getBaseName().equals(selectedName)) {
        currentRow = i;
        hasMatchSelectedName = true;
      }

      item = new TableItem(table, SWT.NONE);
      item.setData("fileObject", children[i]);
      item.setText(fileName.getBaseName());

      try {
        FileType fileType = children[i].getType();
        FileContent fileContent = children[i].getContent();

        if (fileType.equals(FileType.FOLDER)) {
          item.setImage(folderImage);
          item.setText(1, "--");
          item.setText(2, StringUtil.formatDate(fileContent.getLastModifiedTime()));
        } else {
          item.setImage(fileImage);
          item.setText(1, StringUtil.formatSize(fileContent.getSize()));
          item.setText(2, StringUtil.formatDate(fileContent.getLastModifiedTime()));
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    if (!hasMatchSelectedName) currentRow = 0;
    table.setSelection(currentRow);
    table.setFocus();
  }
  /**
   * Updates the visual of the given TableItem according to its IPathManager.
   *
   * @param item TableItem whose visual needs to be updated
   */
  private void updateTableItem(TableItem item) {

    AVRPathManager path = (AVRPathManager) item.getData();

    // add warn / error icons if path is empty / invalid
    boolean valid = path.isValid();
    boolean optional = path.isOptional();
    boolean empty = (path.getPath().isEmpty());

    if (valid && !empty) {
      // valid path
      item.setImage((Image) null);
    } else if ((valid && empty) || (!valid && optional)) {
      // valid but empty path or invalid and optional path (use for optional paths)
      item.setImage(
          PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK));
    } else {
      // Path is invalid
      item.setImage(
          PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK));
    }

    item.setText(COLUMN_NAME, path.getName());
    item.setText(COLUMN_TYPE, path.getSourceType().toString());
    item.setText(COLUMN_PATH, path.getPath().toOSString());

    // Adjust color/font according to source type
    switch (path.getSourceType()) {
      case System:
        item.setFont(COLUMN_TYPE, fDialogFont);
        item.setFont(COLUMN_PATH, fDialogFont);
        item.setForeground(COLUMN_PATH, fTable.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
        break;
      case Bundled:
        item.setFont(COLUMN_TYPE, fDialogFont);
        item.setFont(COLUMN_PATH, fDialogFont);
        item.setForeground(COLUMN_PATH, fTable.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
        break;
      case Custom:
        item.setFont(COLUMN_TYPE, fBoldFont);
        item.setFont(COLUMN_PATH, fBoldFont);
        item.setForeground(COLUMN_PATH, fTable.getDisplay().getSystemColor(SWT.COLOR_BLACK));
    }

    // Updates the table layout.
    fTable.getColumn(COLUMN_NAME).pack();
    fTable.getColumn(COLUMN_TYPE).pack();
    fTable.getColumn(COLUMN_PATH).pack();
    fTable.layout();
  }
示例#5
0
 @Test
 public void testGetItemMetricsImageCutOffInSecondColumn() throws IOException {
   Image image = createImage(display, Fixture.IMAGE1);
   shell.setBounds(0, 0, 200, 200);
   shell.setLayout(new FillLayout());
   table.setHeaderVisible(true);
   TableColumn column = new TableColumn(table, SWT.NONE);
   column.setText("column1");
   column.setWidth(400);
   TableColumn column2 = new TableColumn(table, SWT.NONE);
   column2.setText("column2");
   column2.setWidth(30);
   ITableAdapter adapter = table.getAdapter(ITableAdapter.class);
   adapter.setLeftOffset(5);
   TableItem item1 = new TableItem(table, SWT.NONE);
   item1.setText("item1");
   TableItem item2 = new TableItem(table, SWT.NONE);
   item2.setText("item2");
   TableItem item3 = new TableItem(table, SWT.NONE);
   item3.setText("item3");
   item2.setImage(1, image);
   ItemMetrics[] metrics = TableLCA.getItemMetrics(table);
   assertEquals(403, metrics[1].imageLeft);
   assertEquals(27, metrics[1].imageWidth);
 }
示例#6
0
  private void updateListWidget(int[] indices, int size) {
    if (fList == null || fList.isDisposed()) return;
    fList.setRedraw(false);
    int itemCount = fList.getItemCount();
    if (size < itemCount) {
      fList.remove(0, itemCount - size - 1);
    }

    TableItem[] items = fList.getItems();
    for (int i = 0; i < size; i++) {
      TableItem ti = null;
      if (i < itemCount) {
        ti = items[i];
      } else {
        ti = new TableItem(fList, i);
      }
      ti.setText(fRenderedStrings[indices[i]]);
      Image img = fRenderer.getImage(fElements[indices[i]]);
      if (img != null) ti.setImage(img);
    }
    if (fList.getItemCount() > 0) {
      fList.setSelection(0);
    }

    fList.setRedraw(true);
    Event event = new Event();
    fList.notifyListeners(SWT.Selection, event);
  }
示例#7
0
 /**
  * Sets the image for multiple columns in the table.
  *
  * @param images the array of new images
  * @exception IllegalArgumentException
  *     <ul>
  *       <li>ERROR_NULL_ARGUMENT - if the array of images is null
  *       <li>ERROR_INVALID_ARGUMENT - if one of the images has been disposed
  *     </ul>
  *
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public void setImage(Image[] images) {
   checkWidget();
   if (images == null) error(SWT.ERROR_NULL_ARGUMENT);
   for (int i = 0; i < images.length; i++) {
     setImage(i, images[i]);
   }
 }
示例#8
0
  @Test
  public void testGetItemMetrics() throws IOException {
    Image image = createImage(display, Fixture.IMAGE1);
    shell.setBounds(0, 0, 800, 600);
    shell.setLayout(new FillLayout());
    table.setHeaderVisible(true);
    TableColumn column = new TableColumn(table, SWT.NONE);
    column.setText("column1");
    column.setWidth(200);
    TableItem item1 = new TableItem(table, SWT.NONE);
    item1.setText("item1");
    TableItem item2 = new TableItem(table, SWT.NONE);
    item2.setText("item2");
    TableItem item3 = new TableItem(table, SWT.NONE);
    item3.setText("item3");

    item2.setImage(image);
    ItemMetrics[] metrics = TableLCA.getItemMetrics(table);
    assertTrue(metrics[0].imageWidth > 0);

    item1.setImage(image);
    metrics = TableLCA.getItemMetrics(table);
    int defaultLeftPadding = 3;
    assertEquals(defaultLeftPadding, metrics[0].imageLeft);
    assertTrue(metrics[0].imageWidth > 0);

    // spacing must be respected
    int defaultSpacing = 3;
    int expected = metrics[0].imageLeft + metrics[0].imageWidth + defaultSpacing;
    assertEquals(expected, metrics[0].textLeft);

    // left offset must be compensated
    ITableAdapter adapter = table.getAdapter(ITableAdapter.class);
    adapter.setLeftOffset(10);
    metrics = TableLCA.getItemMetrics(table);
    assertEquals(0, metrics[0].left);
    assertEquals(defaultLeftPadding, metrics[0].imageLeft);
    expected = metrics[0].imageLeft + metrics[0].imageWidth + defaultSpacing;
    assertEquals(expected, metrics[0].textLeft);

    // image must not exceed right column border
    column.setWidth(12);
    metrics = TableLCA.getItemMetrics(table);
    assertEquals(9, metrics[0].imageWidth);
  }
  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());
  }
 @Override
 protected void doResetItem(Item item) {
   TableItem tableItem = (TableItem) item;
   int columnCount = Math.max(1, table.getColumnCount());
   for (int i = 0; i < columnCount; i++) {
     tableItem.setText(i, ""); // $NON-NLS-1$
     if (tableItem.getImage(i) != null) {
       tableItem.setImage(i, null);
     }
   }
 }
示例#11
0
 @Test
 public void testRenderNonNegativeImageWidth() throws IOException {
   TableColumn column = new TableColumn(table, SWT.NONE);
   TableItem item = new TableItem(table, SWT.NONE);
   Image image = createImage(display, Fixture.IMAGE1);
   item.setImage(image);
   column.setWidth(2);
   ItemMetrics[] metrics = TableLCA.getItemMetrics(table);
   assertEquals(1, metrics.length);
   assertEquals(0, metrics[0].imageWidth);
 }
示例#12
0
 private void loadLibraries(LibraryCategory category, Table table) {
   List<LibraryArtifact> libraryArtifacts = category.getLibraryArtifacts();
   for (LibraryArtifact libraryArtifact : libraryArtifacts) {
     if (!isLibraryExists(libraryArtifact.getFileName())) {
       TableItem tableItem = new TableItem(table, SWT.NONE);
       tableItem.setImage(LibImageUtils.getInstance().getJarImage().createImage());
       tableItem.setText(
           new String[] {libraryArtifact.getName(), libraryArtifact.getDescription()});
       tableItem.setData(libraryArtifact);
     }
   }
 }
示例#13
0
    public void handleEvent(Event event) {
      TableItem item = (TableItem) event.item;
      int tableIndex = indexOf(item);

      ScanningResult scanningResult = scanningResults.getResult(tableIndex);
      List<?> values = scanningResult.getValues();
      String[] resultStrings = new String[values.size()];
      for (int i = 0; i < values.size(); i++) {
        Object value = values.get(i);
        if (value != null) resultStrings[i] = value.toString();
      }
      item.setText(resultStrings);
      item.setImage(0, listImages[scanningResult.getType().ordinal()]);
    }
示例#14
0
 /**
  * Sets the image for multiple columns in the table.
  *
  * @param images the array of new images
  * @exception IllegalArgumentException
  *     <ul>
  *       <li>ERROR_NULL_ARGUMENT - if the array of images is null
  *       <li>ERROR_INVALID_ARGUMENT - if one of the images has been disposed
  *     </ul>
  *
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public void setImage(final Image[] images) {
   checkWidget();
   if (images == null) {
     error(SWT.ERROR_NULL_ARGUMENT);
   }
   for (int i = 0; i < images.length; i++) {
     if (images[i] != null && images[i].isDisposed()) {
       error(SWT.ERROR_INVALID_ARGUMENT);
     }
   }
   for (int i = 0; i < images.length; i++) {
     setImage(i, images[i]);
   }
 }
  private void updateTable(LsFolderRequest lsRequest, LsFolderResponse lsResponse) {
    logger.log(
        Level.INFO,
        "Detail panel: Updating table with "
            + lsResponse.getResult().getFileVersions().size()
            + " file versions ...");

    // Add new file version items
    List<PartialFileHistory> fileVersions =
        new ArrayList<>(lsResponse.getResult().getFileVersions().values());
    selectedFileHistory = fileVersions.get(0);

    for (FileVersion fileVersion : selectedFileHistory.getFileVersions().values()) {
      String checksumStr =
          (fileVersion.getChecksum() != null) ? fileVersion.getChecksum().toString() : "";

      TableItem tableItem = new TableItem(historyTable, SWT.NONE);

      tableItem.setData(fileVersion);
      tableItem.setImage(COLUMN_INDEX_STATUS, getStatusImage(fileVersion.getStatus()));
      tableItem.setText(COLUMN_INDEX_PATH, fileVersion.getPath());
      tableItem.setText(COLUMN_INDEX_VERSION, Long.toString(fileVersion.getVersion()));
      tableItem.setText(COLUMN_INDEX_TYPE, fileVersion.getType().toString());
      tableItem.setText(COLUMN_INDEX_SIZE, FileUtil.formatFileSize(fileVersion.getSize()));
      tableItem.setText(COLUMN_INDEX_POSIX_PERMS, fileVersion.getPosixPermissions());
      tableItem.setText(COLUMN_INDEX_DOS_ATTRS, fileVersion.getDosAttributes());
      tableItem.setText(COLUMN_INDEX_CHECKSUM, checksumStr);
      tableItem.setText(COLUMN_INDEX_LAST_MODIFIED, "" + fileVersion.getLastModified());
      tableItem.setText(COLUMN_INDEX_UPDATED, "" + fileVersion.getUpdated());
    }

    if (historyTable.getItemCount() > 0) {
      restoreButton.setEnabled(false);
      historyTable.select(historyTable.getItemCount() - 1);
    }

    resizeColumns();
  }
示例#16
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++;
      }
    }
  }
  /** Initialize the fields in this editor. */
  protected void initialize() {
    if (ports == null) return;

    ports.removeAll();

    Iterator iterator = tomcatConfiguration.getServerPorts().iterator();
    while (iterator.hasNext()) {
      ServerPort port = (ServerPort) iterator.next();
      TableItem item = new TableItem(ports, SWT.NONE);
      String portStr = "-";
      if (port.getPort() >= 0) portStr = port.getPort() + "";
      String[] s = new String[] {port.getName(), portStr};
      item.setText(s);
      item.setImage(TomcatUIPlugin.getImage(TomcatUIPlugin.IMG_PORT));
      item.setData(port);
    }

    if (readOnly) {
      viewer.setCellEditors(new CellEditor[] {null, null});
      viewer.setCellModifier(null);
    } else {
      setupPortEditors();
    }
  }
示例#18
0
    /*
     * (non-Javadoc)
     *
     * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
     */
    @Override
    public IStatus runInUIThread(IProgressMonitor monitor) {
      if (fTable.isDisposed()) {
        return Status.CANCEL_STATUS;
      }
      int itemCount = fTable.getItemCount();

      // Remove excess items
      if (fCount < itemCount) {
        fTable.setRedraw(false);
        fTable.remove(fCount, itemCount - 1);
        fTable.setRedraw(true);
        itemCount = fTable.getItemCount();
      }
      // table empty -> no selection
      if (fCount == 0) {
        fTable.notifyListeners(SWT.Selection, new Event());
        return Status.OK_STATUS;
      }
      // How many we are going to do this time.
      int iterations = Math.min(250, fCount - currentIndex);
      for (int i = 0; i < iterations; i++) {
        if (monitor.isCanceled()) {
          return Status.CANCEL_STATUS;
        }
        final TableItem item =
            (currentIndex < itemCount)
                ? fTable.getItem(currentIndex)
                : new TableItem(fTable, SWT.NONE);
        final Label label = fLabels[fFilteredIndices[fFoldedIndices[currentIndex]]];
        item.setText(label.string);
        item.setImage(label.image);
        currentIndex++;
      }
      if (monitor.isCanceled()) {
        return Status.CANCEL_STATUS;
      }
      if (currentIndex < fCount) {
        schedule(0);
      } else {
        if (indicesToSelect == null) {
          // Make a default selection in the table if there is none.
          // If a selection has already been made, honor it.
          // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=112146
          if (fCount > 0) {
            if (fTable.getSelectionIndices().length == 0) {
              defaultSelect();
            } else {
              // There is a selection, but it likely hasn't changed since the
              // job started.  Force a selection notification, since the
              // items represented by the selection have changed.
              // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=119456
              fTable.notifyListeners(SWT.Selection, new Event());
            }
          }
        } else {
          // Set the selection as indicated.
          selectAndNotify(indicesToSelect);
        }
        // This flag signifies that the selection can now be directly
        // updated in the widget.
        readyForSelection = true;
      }
      return Status.OK_STATUS;
    }
示例#19
0
 public void setImage(final Image image) {
   checkWidget();
   setImage(0, image);
 }
    @Override
    public void run() {
      item = new TableItem(table, SWT.VIRTUAL | SWT.BORDER);
      String userName = "";
      if (StringUtil.inull2Val(message.getUser_id()).toString().equals(message.getUser_id())) {
        Integer userid = StringUtil.inull2Val(message.getUser_id());
        // ユーザ名
        if (userNameCache.containsKey(userid)) {
          userName = userNameCache.get(userid);
        } else {
          new Thread(
                  new Runnable() {
                    @Override
                    public void run() {
                      Integer userid = StringUtil.inull2Val(message.getUser_id());
                      // <title>___さんのユーザーページ - niconico</title>
                      String html =
                          StringUtil.null2Val(
                              new NicoRequestUtil(commentViewer.getCookie())
                                  .get(
                                      String.format(
                                          "http://www.nicovideo.jp/user/%s",
                                          message.getUser_id())));
                      String userName =
                          StringUtil.null2Val(
                              StringUtil.groupMatchFirst(
                                  "<title>(.*?)さんのユーザーページ[^<]+<\\/title>", html));
                      userNameCache.put(userid, userName);
                      // ファイルキャッシュ
                      new SerializerUtil<HashMap<Integer, String>>()
                          .save(USERNAME_CACHE_FILE, userNameCache);
                    }
                  })
              .start();
        }
        // サムネ
        if (imageCache.containsKey(userid)) {
          item.setImage(0, imageCache.get(userid));
        } else {
          new Thread(
                  new Runnable() {
                    @Override
                    public void run() {
                      Integer userid = StringUtil.inull2Val(message.getUser_id());
                      Integer dir = userid / 10000;
                      Image im =
                          SWTUtil.getImage(
                              getDisplay(),
                              String.format(
                                  "http://usericon.nimg.jp/usericon/%d/%d.jpg", dir, userid),
                              getDisplay(),
                              30,
                              30);
                      if (im != null) {
                        //								item.setImage(0, im);
                        imageCache.put(userid, im);
                      }
                    }
                  })
              .start();
        }
      }
      if (message.isNgComment()) {
        Color color = new Color(getDisplay(), new RGB(128, 128, 128));
        item.setForeground(color);
      } else if (message.getPremium().equals(PremiumConstants.BROADCASTER.toString())
          || message.getPremium().equals(PremiumConstants.SYSTEM_UNEI.toString())) {
        Color color = new Color(getDisplay(), new RGB(255, 0, 0));
        item.setForeground(color);
      } else if (message.isFirstComment()) {
        Color color = new Color(getDisplay(), new RGB(0, 255, 0));
        item.setForeground(1, color);
        item.setForeground(2, color);
        item.setForeground(3, color);
      }
      String[] data =
          new String[] {
            "", // サムネ
            StringUtil.null2Val(message.getNo()),
            StringUtil.null2Val(SWTUtil.vpos2Time(message.getVposFromStartTime())),
            StringUtil.null2Val(message.getText()).trim(),
            StringUtil.null2Val(message.getHandleName()),
            StringUtil.null2Val(message.getMail()),
            StringUtil.null2Val(message.getPremium()),
            userName,
            StringUtil.null2Val(message.getUser_id()),
            StringUtil.null2Val(message.getScore()),
          };

      //			//growl通知
      //			if (PropertyUtil.isMac()) {
      //				//TODO macでかつ、設定がONだったら
      //				String title = message.getUser_id();
      //				GrowlNotification.getInstance().notify(title, message.getText());
      //			}

      //			String[] links = StringUtil.groupMatch(MATCH_URL,
      // StringUtil.null2Val(message.getText()).trim());
      //			//TODO URL自動リンク
      //			if (links.length > 0) {
      //				Hyperlink link = new Hyperlink(table, SWT.WRAP);
      //				link.setText(StringUtil.null2Val(message.getText()).trim().replaceAll(MATCH_URL, "$1"));
      //				link.setUnderlined(true);
      //				TableEditor editor = new TableEditor(table);
      //				editor.grabHorizontal = true;
      //				editor.setEditor(link, item, 3);
      //			}

      //			//最終コメが見えていて、初期ロードが終わってれば自動スクロール
      //			boolean scrollFlag = (table.getItem(table.getItemCount()-1).getBounds().y ==
      // table.getClientArea().y + table.getClientArea().height);
      item.setText(data);
      table.setTopIndex(table.getItemCount() - 1);
      //			if ((StringUtil.inull2Val(threadMessage.getLast_res()) ==
      // StringUtil.inull2Val(message.getNo()))) {
      //				//初期ロード後1回はスクロール
      //				table.setTopIndex(table.getItemCount()-1);
      //			} else if (scrollFlag && (StringUtil.inull2Val(message.getNo()) == 0 ||
      //				//初期ロード後であればアイテムが見えてる時だけスクロール
      //			}
    }
  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);
  }
示例#22
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("");
  }