protected void handleAdd() {
    ElementListSelectionDialog dialog =
        new ElementListSelectionDialog(getShell(), new StyledBundleLabelProvider(false, false));

    try {
      dialog.setElements(getValidBundles());
    } catch (CoreException e) {
      dialog.setMessage(e.getMessage());
    }

    dialog.setTitle(PDEUIMessages.PluginSelectionDialog_title);
    dialog.setMessage(PDEUIMessages.PluginSelectionDialog_message);
    dialog.setMultipleSelection(true);
    if (dialog.open() == Window.OK) {

      Object[] models = dialog.getResult();
      ArrayList<NameVersionDescriptor> pluginsToAdd = new ArrayList<NameVersionDescriptor>();
      for (int i = 0; i < models.length; i++) {
        BundleInfo desc = ((BundleInfo) models[i]);
        pluginsToAdd.add(new NameVersionDescriptor(desc.getSymbolicName(), null));
      }
      Set<NameVersionDescriptor> allDependencies = new HashSet<NameVersionDescriptor>();
      allDependencies.addAll(pluginsToAdd);
      NameVersionDescriptor[] currentBundles = getTargetDefinition().getImplicitDependencies();
      if (currentBundles != null) {
        allDependencies.addAll(Arrays.asList(currentBundles));
      }
      getTargetDefinition()
          .setImplicitDependencies(
              allDependencies.toArray(new NameVersionDescriptor[allDependencies.size()]));
      fElementViewer.refresh();
      updateImpButtons();
    }
  }
 private void handleFilter() {
   boolean changed = false;
   String newFilter;
   if (fFilterText == null || (newFilter = fFilterText.getText().trim()).length() == 0)
     newFilter = "*"; // $NON-NLS-1$
   changed = fAvailableFilter.setPattern(newFilter);
   if (changed) {
     fAvailableListViewer.refresh();
     updateButtonEnablement(false, false);
   }
 }
 @Override
 protected void refreshPage() {
   fAvailableListViewer.addFilter(fSourceFilter);
   fImportListViewer.getTable().removeAll();
   fSelected.clear();
   fAvailableFilter.setPattern("*"); // $NON-NLS-1$
   fSourceFilter.setState(fPage1.getState());
   fVersionFilter.setModel(fModels);
   fAvailableListViewer.refresh();
   pageChanged();
 }
  /**
   * 通过将检索结果结合中的记录分页加载的方法,实现控制检索结果记录的分页显示与快速加载
   *
   * @param facttable 显示检索结果的GUI表格对象
   * @param pagenum 显示在表格对象中的检索结果页码,从1开始计算
   */
  private void openCurrentTable(final int pagenum) {

    table.clearAll(); // 清空表格所有项目中的数据
    // 数据记录在检索结果结合中的下标开始值
    final int recordstart = (pagenum - 1) * pageSize;
    // 当前表格能显示的最后一条记录在检索结果集合中的索引号
    int end = recordstart + pageSize;
    // 若表格可显示的记录大于检索结果记录的总数,就只显示到最后一条检索结果记录
    final int recordend = Math.min(end, stationData.getRowCount()); // 显示的最后一条记录在检索结果集合中的索引号

    // 当前页面显示的检索结果记录数
    final int currentdispnum = recordend - recordstart;
    // 根据当前的页码,从检索结果集合中加载相应的数据到表的item域中
    tableViewer.setInput(stationData.getRow(recordstart, recordstart + currentdispnum)); // 自动输入数据
    tableViewer.refresh(); // 刷新表格false
  }
 private void handleRemove() {
   LinkedList<NameVersionDescriptor> bundles = new LinkedList<NameVersionDescriptor>();
   bundles.addAll(Arrays.asList(getTargetDefinition().getImplicitDependencies()));
   Object[] removeBundles = ((IStructuredSelection) fElementViewer.getSelection()).toArray();
   if (removeBundles.length > 0) {
     for (int i = 0; i < removeBundles.length; i++) {
       if (removeBundles[i] instanceof NameVersionDescriptor) {
         bundles.remove(removeBundles[i]);
       }
     }
     getTargetDefinition()
         .setImplicitDependencies(bundles.toArray((new NameVersionDescriptor[bundles.size()])));
     fElementViewer.refresh();
     updateImpButtons();
   }
 }
  @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);
        }
      }
    }
  }
  /* (non-Javadoc)
   * @see org.eclipse.pde.internal.ui.editor.PDESection#modelChanged(org.eclipse.pde.core.IModelChangedEvent)
   */
  public void modelChanged(IModelChangedEvent e) {
    // No need to call super, handling world changed event here
    if (e.getChangeType() == IModelChangedEvent.WORLD_CHANGED) {
      handleModelEventWorldChanged(e);
      return;
    }
    Object[] objects = e.getChangedObjects();
    if (e.getChangeType() == IModelChangedEvent.INSERT) {
      for (int i = 0; i < objects.length; i++) {
        if (objects[i] instanceof IProductPlugin) fPluginTable.add(objects[i]);
      }
    } else if (e.getChangeType() == IModelChangedEvent.REMOVE) {

      Table table = fPluginTable.getTable();
      int index = table.getSelectionIndex();

      for (int i = 0; i < objects.length; i++) {
        if (objects[i] instanceof IProductPlugin) fPluginTable.remove(objects[i]);
      }

      // Update Selection

      int count = table.getItemCount();

      if (count == 0) {
        // Nothing to select
      } else if (index < count) {
        table.setSelection(index);
      } else {
        table.setSelection(count - 1);
      }

    } else if (e.getChangeType() == IModelChangedEvent.CHANGE) {
      fPluginTable.refresh();
    }
    updateRemoveButtons(false, true);
  }
Ejemplo n.º 8
0
 private void refresh() {
   globalJob.invalidate();
   viewer.refresh(true);
 }
 @Override
 public void refresh() {
   fPackageViewer.refresh();
   super.refresh();
 }
 private void handleRemoveAll() {
   getTargetDefinition().setImplicitDependencies(null);
   fElementViewer.refresh();
   updateImpButtons();
 }
  /* (non-Javadoc)
   * @see org.eclipse.pde.internal.ui.wizards.target.TargetDefinitionPage#targetChanged()
   */
  protected void targetChanged(ITargetDefinition definition) {
    super.targetChanged(definition);
    if (definition != null) {
      // When  If the page isn't open yet, try running a UI job so the dialog has time to finish
      // opening
      new UIJob(PDEUIMessages.TargetDefinitionContentPage_0) {
        public IStatus runInUIThread(IProgressMonitor monitor) {
          ITargetDefinition definition = getTargetDefinition();
          if (!definition.isResolved()) {
            try {
              getContainer()
                  .run(
                      true,
                      true,
                      new IRunnableWithProgress() {
                        public void run(IProgressMonitor monitor)
                            throws InvocationTargetException, InterruptedException {
                          getTargetDefinition().resolve(new ResolutionProgressMonitor(monitor));
                          if (monitor.isCanceled()) {
                            throw new InterruptedException();
                          }
                        }
                      });
            } catch (InvocationTargetException e) {
              PDECore.log(e);
            } catch (InterruptedException e) {
              fContentTree.setCancelled();
              return Status.CANCEL_STATUS;
            }
          }
          fContentTree.setInput(definition);
          fLocationTree.setInput(definition);
          if (definition.isResolved() && definition.getStatus().getSeverity() == IStatus.ERROR) {
            fLocationTab.setImage(
                PlatformUI.getWorkbench()
                    .getSharedImages()
                    .getImage(ISharedImages.IMG_OBJS_ERROR_TSK));
          } else {
            fLocationTab.setImage(null);
          }
          return Status.OK_STATUS;
        }
      }.schedule();
      String name = definition.getName();
      if (name == null) {
        name = EMPTY_STRING;
      }

      if (name.trim().length() > 0) fNameText.setText(name);
      else setMessage(PDEUIMessages.TargetDefinitionContentPage_8);

      fLocationTree.setInput(definition);
      fContentTree.setInput(definition);

      String presetValue = (definition.getOS() == null) ? EMPTY_STRING : definition.getOS();
      fOSCombo.setText(presetValue);
      presetValue = (definition.getWS() == null) ? EMPTY_STRING : definition.getWS();
      fWSCombo.setText(presetValue);
      presetValue = (definition.getArch() == null) ? EMPTY_STRING : definition.getArch();
      fArchCombo.setText(presetValue);
      presetValue =
          (definition.getNL() == null)
              ? EMPTY_STRING
              : LocaleUtil.expandLocaleName(definition.getNL());
      fNLCombo.setText(presetValue);

      IPath jrePath = definition.getJREContainer();
      if (jrePath == null || jrePath.equals(JavaRuntime.newDefaultJREContainerPath())) {
        fDefaultJREButton.setSelection(true);
      } else {
        String ee = JavaRuntime.getExecutionEnvironmentId(jrePath);
        if (ee != null) {
          fExecEnvButton.setSelection(true);
          fExecEnvsCombo.select(fExecEnvsCombo.indexOf(ee));
        } else {
          String vm = JavaRuntime.getVMInstallName(jrePath);
          if (vm != null) {
            fNamedJREButton.setSelection(true);
            fNamedJREsCombo.select(fNamedJREsCombo.indexOf(vm));
          }
        }
      }

      if (fExecEnvsCombo.getSelectionIndex() == -1)
        fExecEnvsCombo.setText(fExecEnvChoices.first().toString());

      if (fNamedJREsCombo.getSelectionIndex() == -1)
        fNamedJREsCombo.setText(VMUtil.getDefaultVMInstallName());

      updateJREWidgets();

      presetValue =
          (definition.getProgramArguments() == null)
              ? EMPTY_STRING
              : definition.getProgramArguments();
      fProgramArgs.setText(presetValue);
      presetValue =
          (definition.getVMArguments() == null) ? EMPTY_STRING : definition.getVMArguments();
      fVMArgs.setText(presetValue);

      fElementViewer.refresh();
    }
  }
 /* (non-Javadoc)
  * @see org.eclipse.ui.forms.AbstractFormPart#refresh()
  */
 public void refresh() {
   fPluginTable.refresh();
   updateRemoveButtons(true, true);
   super.refresh();
 }