Example #1
0
    protected void saveCellEditorValue(CellEditor cellEditor, ViewerCell cell) {
      int idx = ((Integer) cellEditor.getValue()).intValue();
      String[] items = ((ComboBoxCellEditor) cellEditor).getItems();

      String selectedVersion = items[idx];
      cell.setText(selectedVersion);

      if (cell.getElement() instanceof JarDiff) {
        ((JarDiff) cell.getElement()).setSelectedVersion(selectedVersion);
        return;
      }
      PackageInfo modelElement = (PackageInfo) cell.getElement();
      modelElement.setSelectedVersion(selectedVersion);
    }
Example #2
0
    protected CellEditor getCellEditor(Object element) {

      //			String suggestedVersion = null;

      Set<String> versions = new TreeSet<String>();
      if (element instanceof JarDiff) {
        JarDiff diff = (JarDiff) element;
        if (diff.getCurrentVersion() != null) {
          versions.add(diff.getCurrentVersion());
        }

        for (String suggestedVersion : diff.getSuggestedVersions()) {
          versions.add(suggestedVersion);
        }

      } else {
        PackageInfo pi = (PackageInfo) element;

        if (pi.getCurrentVersion() != null) {
          versions.add(pi.getCurrentVersion());
        }
        for (String suggestedVersion : pi.getSuggestedVersions()) {
          versions.add(suggestedVersion);
        }
        if (pi.getJarDiff().getCurrentVersion() != null) {
          versions.add(pi.getJarDiff().getCurrentVersion());
        }
        if (pi.getJarDiff().getSuggestedVersion() != null) {
          versions.add(pi.getJarDiff().getSuggestedVersion());
        }
        for (String suggestedVersion : pi.getJarDiff().getSuggestedVersions()) {
          versions.add(suggestedVersion);
        }
      }

      //			String[] items = versions.toArray(new String[versions.size()]);
      //			int idx = 0;
      //			for (int i = 0; i < items.length; i++) {
      //				if (items[i].equals(suggestedVersion)) {
      //					idx = i;
      //					break;
      //				}
      //			}
      editor.setItems(versions.toArray(new String[versions.size()]));
      //			editor.setValue(idx);
      return editor;
    }
Example #3
0
    protected void initializeCellEditorValue(CellEditor cellEditor, ViewerCell cell) {

      String selectedVersion;
      if (cell.getElement() instanceof JarDiff) {
        selectedVersion = ((JarDiff) cell.getElement()).getSelectedVersion();
      } else {
        PackageInfo pi = (PackageInfo) cell.getElement();
        selectedVersion = pi.getSelectedVersion();
      }

      String[] items = ((ComboBoxCellEditor) cellEditor).getItems();
      int idx = 0;
      for (int i = 0; i < items.length; i++) {
        if (items[i].equals(selectedVersion)) {
          idx = i;
          break;
        }
      }

      cellEditor.setValue(idx);
      cell.setText(selectedVersion);
    }
Example #4
0
 protected boolean canEdit(Object element) {
   if (element instanceof JarDiff) {
     return true;
   }
   if (element instanceof PackageInfo) {
     PackageInfo pi = (PackageInfo) element;
     if (pi.isImported() && !pi.isExported()) {
       return false;
     }
     if (pi.getChangeCode() == PackageInfo.CHANGE_CODE_REMOVED) {
       return false;
     }
     if (pi.getChangeCode() == PackageInfo.CHANGE_CODE_VERSION_MISSING) {
       return true;
     }
     return pi.getSuggestedVersion() != null;
   }
   return false;
 }