コード例 #1
0
 public boolean setFormInput(Object input) {
   if (input instanceof IProductPlugin) {
     fPluginTable.setSelection(new StructuredSelection(input), true);
     return true;
   }
   return super.setFormInput(input);
 }
コード例 #2
0
  @Override
  public void modelChanged(IModelChangedEvent event) {
    if (event.getChangeType() == IModelChangedEvent.WORLD_CHANGED) {
      fHeader = null;
      markStale();
      return;
    }

    if (getExportedPackageHeader().equals(event.getChangedProperty())) {
      refresh();
      // Bug 171896
      // Since the model sends a CHANGE event instead of
      // an INSERT event on the very first addition to the empty table
      // Selection should fire here to take this first insertion into account
      Object lastElement =
          fPackageViewer.getElementAt(fPackageViewer.getTable().getItemCount() - 1);
      if (lastElement != null) {
        fPackageViewer.setSelection(new StructuredSelection(lastElement));
      }

      return;
    }

    Object[] objects = event.getChangedObjects();
    for (Object changedObject : objects) {
      if (changedObject instanceof ExportPackageObject) {
        ExportPackageObject object = (ExportPackageObject) changedObject;
        switch (event.getChangeType()) {
          case IModelChangedEvent.INSERT:
            fPackageViewer.add(object);
            fPackageViewer.setSelection(new StructuredSelection(object), false);
            fPackageViewer.getTable().setFocus();
            break;
          case IModelChangedEvent.REMOVE:
            Table table = fPackageViewer.getTable();
            int index = table.getSelectionIndex();
            fPackageViewer.remove(object);
            table.setSelection(index < table.getItemCount() ? index : table.getItemCount() - 1);
            break;
          default:
            fPackageViewer.refresh(object);
        }
      }
    }
  }
コード例 #3
0
 private void addPlugin(String id, String version) {
   IProduct product = getProduct();
   IProductModelFactory factory = product.getModel().getFactory();
   IProductPlugin plugin = factory.createPlugin();
   plugin.setId(id);
   plugin.setVersion(version);
   product.addPlugins(new IProductPlugin[] {plugin});
   fPluginTable.setSelection(new StructuredSelection(plugin));
 }