Пример #1
0
 @Override
 public Object execute(final ExecutionEvent event) throws ExecutionException {
   final INattableModelManager manager = getCurrentNattableModelManager();
   if (manager != null) {
     manager.selectAll();
   }
   return null;
 }
  /**
   * Given the proper references, it displays the dialog pre-filled with data from the current
   * provider.
   *
   * @param currentNattableModelManager
   * @param axisProvider
   * @param axisProvidersHistory
   * @param axisProvidersHistoryEReference
   * @return
   */
  public Object saveAxisProviderConfig(
      final INattableModelManager currentNattableModelManager,
      final AbstractAxisProvider axisProvider,
      EList<AbstractAxisProvider> axisProvidersHistory,
      EReference axisProvidersHistoryEReference) {
    final AbstractAxisProvider copy = EcoreUtil.copy(axisProvider);

    // We ask the user for a name and description
    String name = axisProvider.getName();
    String description = axisProvider.getDescription();

    final List<String> existingProviderNames = new ArrayList<String>();
    for (AbstractAxisProvider abstractAxisProvider : axisProvidersHistory) {
      existingProviderNames.add(abstractAxisProvider.getName());
    }
    TwoInputDialog dialog =
        new TwoInputDialog(
            Display.getCurrent().getActiveShell(),
            Messages.AbstractSaveCurrentAxisProvidersHandler_0,
            Messages.AbstractSaveCurrentAxisProvidersHandler_1,
            Messages.AbstractSaveCurrentAxisProvidersHandler_2,
            name,
            description,
            new IInputValidator() {

              @Override
              public String isValid(String newText) {
                if (newText == null || newText.equals("")) { // $NON-NLS-1$
                  return Messages.AbstractSaveCurrentAxisProvidersHandler_4;
                } else if (existingProviderNames.contains(newText)) {
                  return Messages.AbstractSaveCurrentAxisProvidersHandler_5;
                }
                return null;
              }
            });
    if (dialog.open() == Dialog.OK) {
      // get the name and the description for the table
      name = dialog.getValue();
      description = dialog.getValue_2();

      copy.setName(name);
      copy.setDescription(description);

      final List<AbstractAxisProvider> historyCopy =
          new ArrayList<AbstractAxisProvider>(axisProvidersHistory);
      historyCopy.add(copy);

      // Create the transactional command
      final CompositeCommand cmd =
          new CompositeCommand("SaveCurrentAxisProvidersHandler"); // $NON-NLS-1$
      final IEditCommandRequest request =
          new SetRequest(
              (TransactionalEditingDomain) getTableEditingDomain(),
              currentNattableModelManager.getTable(),
              axisProvidersHistoryEReference,
              historyCopy);
      final IElementEditService provider =
          ElementEditServiceUtils.getCommandProvider(currentNattableModelManager.getTable());
      cmd.add(provider.getEditCommand(request));
      getTableEditingDomain().getCommandStack().execute(new GMFtoEMFCommandWrapper(cmd));

      return copy;
    }
    return null;
  }