예제 #1
0
 /** {@inheritDoc} */
 public boolean performFinish() {
   final String name = m_projectSettingWizardPage.getNewProjectName();
   if (ProjectPM.doesProjectNameExist(name)) {
     ErrorHandlingUtil.createMessageDialog(
         MessageIDs.E_PROJECTNAME_ALREADY_EXISTS, new Object[] {name}, null);
     return false;
   }
   try {
     PlatformUI.getWorkbench()
         .getProgressService()
         .run(
             false,
             false,
             new IRunnableWithProgress() {
               public void run(IProgressMonitor monitor) throws InterruptedException {
                 monitor.beginTask(
                     NLS.bind(Messages.ProjectWizardCreatingProject, name),
                     IProgressMonitor.UNKNOWN);
                 try {
                   createNewProject(name, monitor);
                   m_newProject = null;
                 } finally {
                   monitor.done();
                 }
               }
             });
   } catch (InvocationTargetException ite) {
     // Exception occurred during operation
     log.error(ite.getLocalizedMessage(), ite.getCause());
   } catch (InterruptedException ie) {
     // Operation was canceled.
     // Do nothing.
   }
   return true;
 }
예제 #2
0
 /**
  * This method creates the constraint instance.
  *
  * @param constraintStructure the constraint's structure (bConstraint clss in blender 2.49).
  * @param ownerOMA the old memory address of the constraint's owner
  * @param influenceIpo the ipo curve of the influence factor
  * @param blenderContext the blender context
  * @throws BlenderFileException this exception is thrown when the blender file is somehow
  *     corrupted
  */
 protected Constraint createConstraint(
     Structure constraintStructure, Long ownerOMA, Ipo influenceIpo, BlenderContext blenderContext)
     throws BlenderFileException {
   String constraintClassName = this.getConstraintClassName(constraintStructure, blenderContext);
   Class<? extends Constraint> constraintClass = constraintClasses.get(constraintClassName);
   if (constraintClass != null) {
     try {
       return (Constraint)
           constraintClass.getDeclaredConstructors()[0].newInstance(
               constraintStructure, ownerOMA, influenceIpo, blenderContext);
     } catch (IllegalArgumentException e) {
       throw new BlenderFileException(e.getLocalizedMessage(), e);
     } catch (SecurityException e) {
       throw new BlenderFileException(e.getLocalizedMessage(), e);
     } catch (InstantiationException e) {
       throw new BlenderFileException(e.getLocalizedMessage(), e);
     } catch (IllegalAccessException e) {
       throw new BlenderFileException(e.getLocalizedMessage(), e);
     } catch (InvocationTargetException e) {
       throw new BlenderFileException(e.getLocalizedMessage(), e);
     }
   } else {
     throw new BlenderFileException("Unknown constraint type: " + constraintClassName);
   }
 }
  @Override
  protected void backPressed() {
    // move workflow to previous state, start up a new thread to do it.
    final Workflow pipe = getWizard().getWorkflow();

    if (pipe.getCurrentState().getPreviousState() == null) {
      // this means that this wizard is part of a larger wizard and we need to return control
      // to it.  See setAdapter for details
      workflowWizardAdapter.backPressed();
    }

    IRunnableWithProgress runnable =
        new IRunnableWithProgress() {
          public void run(IProgressMonitor monitor)
              throws InvocationTargetException, InterruptedException {

            pipe.previous(monitor);
          }
        };
    try {
      run(false, true, runnable);
    } catch (InvocationTargetException e) {
      CatalogUIPlugin.log(e.getLocalizedMessage(), e);
    } catch (InterruptedException e) {
      CatalogUIPlugin.log(e.getLocalizedMessage(), e);
    }
  }
예제 #4
0
 public void handleMessage(Message msg) {
   if (!doTask) return;
   /**
    * currentPosView = getChildAt(dragCurPos - getFirstVisiblePosition()); if (currentPosView
    * != null) currentPosView.setBackgroundDrawable(null); /*
    */
   int position;
   if (!downing) {
     position = getFirstVisiblePosition();
     if (position == 0) {
       doTask = false;
     } else {
       position -= 5;
     }
   } else {
     position = getLastVisiblePosition();
     if (position == getCount() - 1) {
       doTask = false;
     } else {
       position += 5;
     }
   }
   if (SDK8 && method != null)
     try {
       method.invoke(DDGridView.this, position);
     } catch (IllegalArgumentException e) {
       // TODO Auto-generated catch block
       FileManager.error(
           "IllegalArgumentException: " + e.getLocalizedMessage() + "\n" + e.getMessage());
       method = null;
       setSelection(position);
     } catch (IllegalAccessException e) {
       // TODO Auto-generated catch block
       FileManager.error(
           "IllegalAccessException: " + e.getLocalizedMessage() + "\n" + e.getMessage());
       method = null;
       setSelection(position);
     } catch (InvocationTargetException e) {
       // TODO Auto-generated catch block
       FileManager.error(
           "InvocationTargetException: " + e.getLocalizedMessage() + "\n" + e.getMessage());
       method = null;
       setSelection(position);
     }
   else setSelection(position);
   if (!doTask) ha.removeMessages(0);
 }
예제 #5
0
 public void setPropertyValue(String fieldName, Object newValue) {
   PropertyHolder pp = properties.get(fieldName);
   if (pp == null)
     throw new NullPointerException(
         "Can not find property '" + fieldName + "' in bean " + obj.getClass().getName());
   Method m = pp.getWriteMethod();
   if (m == null)
     throw new NullPointerException(
         "Can not find set method '" + fieldName + "' in bean " + obj.getClass().getName());
   try {
     m.invoke(obj, new Object[] {newValue});
   } catch (IllegalArgumentException e) {
     StringBuilder sb =
         new StringBuilder("IllegalArgumentException:")
             .append(e.getLocalizedMessage())
             .append('\n');
     sb.append(obj.getClass().getName())
         .append('\t')
         .append(fieldName)
         .append('\t')
         .append(newValue.getClass().getName());
     throw new IllegalArgumentException(sb.toString());
   } catch (IllegalAccessException e) {
     StringBuilder sb =
         new StringBuilder("IllegalAccessException:").append(e.getLocalizedMessage()).append('\n');
     sb.append(obj.getClass().getName())
         .append('\t')
         .append(fieldName)
         .append('\t')
         .append(newValue);
     throw new IllegalArgumentException(sb.toString());
   } catch (InvocationTargetException e) {
     StringBuilder sb =
         new StringBuilder("InvocationTargetException:")
             .append(e.getLocalizedMessage())
             .append('\n');
     sb.append(obj.getClass().getName())
         .append('\t')
         .append(fieldName)
         .append('\t')
         .append(newValue);
     throw new IllegalArgumentException(sb.toString());
   }
 }
  /**
   * {@inheritDoc}
   *
   * @see org.eclipse.jface.wizard.Wizard#performFinish()
   */
  @Override
  public boolean performFinish() {
    EObject element = selectElementPage.getSelectedElement();
    if (element != null && representationWizardPage.get() != null) {

      try {
        final String representationName = selectElementPage.get();

        IRunnableWithProgress representationCreationRunnable =
            new IRunnableWithProgress() {

              public void run(IProgressMonitor monitor)
                  throws InvocationTargetException, InterruptedException {
                try {
                  monitor.beginTask(
                      org.eclipse.sirius.viewpoint.provider.Messages
                          .CreateRepresentationAction_creationTask,
                      5);
                  CreateRepresentationCommand createRepresentationCommand =
                      new CreateRepresentationCommand(
                          existingSession,
                          representationWizardPage.get(),
                          selectElementPage.getSelectedElement(),
                          representationName,
                          new SubProgressMonitor(monitor, 4));

                  IEditingSession editingSession =
                      SessionUIManager.INSTANCE.getUISession(existingSession);
                  editingSession.notify(
                      EditingSessionEvent.REPRESENTATION_ABOUT_TO_BE_CREATED_BEFORE_OPENING);
                  existingSession
                      .getTransactionalEditingDomain()
                      .getCommandStack()
                      .execute(createRepresentationCommand);
                  editingSession.notify(EditingSessionEvent.REPRESENTATION_CREATED_BEFORE_OPENING);
                  createdDRepresentation = createRepresentationCommand.getCreatedRepresentation();
                  monitor.worked(1);
                } finally {
                  monitor.done();
                }
              }
            };

        getContainer().run(true, false, representationCreationRunnable);
        IRunnableWithProgress runnable =
            new IRunnableWithProgress() {

              public void run(final IProgressMonitor monitor) {
                try {
                  monitor.beginTask(
                      org.eclipse.sirius.viewpoint.provider.Messages
                          .CreateRepresentationAction_openingTask,
                      1);
                  DialectUIManager.INSTANCE.openEditor(
                      existingSession, createdDRepresentation, new SubProgressMonitor(monitor, 1));
                } finally {
                  monitor.done();
                }
              }
            };
        Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
        IRunnableContext context = new ProgressMonitorDialog(shell);
        PlatformUI.getWorkbench().getProgressService().runInUI(context, runnable, null);
      } catch (final InvocationTargetException e) {
        SiriusEditPlugin.getPlugin()
            .getLog()
            .log(new Status(IStatus.ERROR, SiriusEditPlugin.ID, e.getLocalizedMessage(), e));
      } catch (final InterruptedException e) {
        SiriusEditPlugin.getPlugin()
            .getLog()
            .log(new Status(IStatus.ERROR, SiriusEditPlugin.ID, e.getLocalizedMessage(), e));
      }
    }
    return true;
  }
  public void initHasFields(UserSpecifiedRegionAttributes<K, V> other) {
    Field thisFields[] = UserSpecifiedRegionAttributes.class.getDeclaredFields();
    Object[] emptyArgs = new Object[] {};
    int hasCounter = 0;
    String fieldName = null;
    for (int i = 0; i < thisFields.length; i++) {
      fieldName = thisFields[i].getName();
      if (fieldName.startsWith("has")) {
        hasCounter++;
        boolean bval = false;

        try {
          Method otherMeth = other.getClass().getMethod(fieldName /*, (Class[])null*/);
          bval = ((Boolean) otherMeth.invoke(other, emptyArgs)).booleanValue();
        } catch (NoSuchMethodException darnit) {
          Assert.assertTrue(false, "A has* method accessor is required for field " + fieldName);
        } catch (IllegalAccessException boom) {
          Assert.assertTrue(false, "Could not access method " + fieldName + " on " + getClass());
        } catch (IllegalArgumentException e) {
          Assert.assertTrue(
              false, "Illegal argument trying to set field " + e.getLocalizedMessage());
        } catch (InvocationTargetException e) {
          Assert.assertTrue(false, "Failed trying to invoke method " + e.getLocalizedMessage());
        }

        try {
          thisFields[i].setBoolean(this, bval);
        } catch (IllegalAccessException ouch) {
          Assert.assertTrue(false, "Could not access field" + fieldName + " on " + getClass());
        }
      }
    }
    Assert.assertTrue(
        hasCounter == HAS_COUNT,
        "Expected " + HAS_COUNT + " methods, got " + hasCounter + " last field: " + fieldName);

    //    this.hasCacheListeners = other.hasCacheListeners();
    //    this.hasCacheLoader = other.hasCacheLoader();
    //    this.hasCacheWriter = other.hasCacheWriter();
    //    this.hasConcurrencyLevel = other.hasConcurrencyLevel();
    //    this.hasDataPolicy = other.hasDataPolicy();
    //    this.hasDiskDirs = other.hasDiskDirs();
    //    this.hasDiskWriteAttributes = other.hasDiskWriteAttributes();
    //    this.hasEarlyAck = other.hasEarlyAck();
    //    this.hasEnableAsyncConflation = other.hasEnableAsyncConflation();
    //    this.hasEnableSubscriptionConflation = other.hasEnableSubscriptionConflation();
    //    this.hasEnableGateway = other.hasEnableGateway();
    //    this.hasEntryIdleTimeout = other.hasEntryIdleTimeout();
    //    this.hasEntryTimeToLive = other.hasEntryTimeToLive();
    //    this.hasEvictionAttributes = other.hasEvictionAttributes();
    //    this.hasIgnoreJTA = other.hasIgnoreJTA();
    //    this.hasIndexMaintenanceSynchronous = other.hasIndexMaintenanceSynchronous();
    //    this.hasInitialCapacity = other.hasInitialCapacity();
    //    this.hasIsLockGrantor = other.hasIsLockGrantor();
    //    this.hasKeyConstraint = other.hasKeyConstraint();
    //    this.hasLoadFactor = other.hasLoadFactor();
    //    this.hasMembershipAttributes = other.hasMembershipAttributes();
    //    this.hasMulticastEnabled = other.hasMulticastEnabled();
    //    this.hasPartitionAttributes = other.hasPartitionAttributes();
    //    this.hasPublisher = other.hasPublisher();
    //    this.hasRegionIdleTimeout = other.hasRegionIdleTimeout();
    //    this.hasRegionTimeToLive = other.hasRegionTimeToLive();
    //    this.hasScope = other.hasScope();
    //    this.hasStatisticsEnabled = other.hasStatisticsEnabled();
    //    this.hasSubscriptionAttributes = other.hasSubscriptionAttributes();
    //    this.hasValueConstraint = other.hasValueConstraint();
  }
예제 #8
0
  /**
   * Setup parameter accordnig to ZkParameter annotation.
   *
   * @param <T> type of field.
   * @param annot the annotation with parameter definition
   * @param field the field to set
   * @param clazz class of the field and parameter
   */
  protected static <T> void setupZkParameter(
      ZkParameter annot,
      String paramName,
      Class<T> clazz,
      Field field,
      Method method,
      Object instance) {
    T result = null;

    Map[] paramMaps =
        new Map[] {
          Executions.getCurrent().getArg(),
          Executions.getCurrent().getAttributes(),
          Executions.getCurrent().getParameterMap()
        };

    Map paramMap = paramMaps[0];
    for (Map map : paramMaps) {
      if (map.containsKey(paramName)) {
        paramMap = map;
        break;
      }
    }

    try {
      if (annot.required()) result = ZKHelper.getRequiredParameter(paramMap, paramName, clazz);
      else if (!paramMap.containsKey(paramName)) return; // optional parameter doesn't do anything
      else result = ZKHelper.getOptionalParameter(paramMap, paramName, clazz, null);
    } catch (IllegalArgumentException ex) {
      throw new IllegalArgumentException(
          "@ZkParameter(name='"
              + paramName
              + "', "
              + "required="
              + (annot.required() ? "true" : "false")
              + ", "
              + "createIfNull="
              + (annot.createIfNull() ? "true" : "false")
              + "): "
              + ex.getLocalizedMessage());
    }

    if (result == null && annot.createIfNull())
      try {
        result = (T) clazz.newInstance();
      } catch (InstantiationException ex) {
        throw new InstantiationError(
            "@ZkParameter(name='"
                + paramName
                + "', "
                + "required="
                + (annot.required() ? "true" : "false")
                + ", "
                + "createIfNull="
                + (annot.createIfNull() ? "true" : "false")
                + ") - Parameter is null, unable to create new object with error: "
                + ex.getLocalizedMessage());
      } catch (IllegalAccessException ex) {
        throw new InstantiationError(
            "@ZkParameter(name='"
                + paramName
                + "', "
                + "required="
                + (annot.required() ? "true" : "false")
                + ", "
                + "createIfNull="
                + (annot.createIfNull() ? "true" : "false")
                + ") - Parameter is null, unable to create new object, no public default constructor: "
                + ex.getLocalizedMessage());
      }

    if (field != null)
      try {
        field.setAccessible(true);
        field.set(instance, result);
        field.setAccessible(false);
      } catch (IllegalArgumentException ex) {
        throw new IllegalArgumentException(
            "@ZkParameter(name='"
                + paramName
                + "', "
                + "required="
                + (annot.required() ? "true" : "false")
                + ", "
                + "createIfNull="
                + (annot.createIfNull() ? "true" : "false")
                + ") - Unable to set new value of field to '"
                + result
                + "': "
                + ex.getLocalizedMessage(),
            ex);
      } catch (IllegalAccessException ex) {
        throw SystemException.Aide.wrap(ex);
      }
    if (method != null)
      try {
        method.setAccessible(true);
        method.invoke(instance, new Object[] {result});
        method.setAccessible(false);
      } catch (IllegalAccessException ex) {
        throw SystemException.Aide.wrap(ex);
      } catch (IllegalArgumentException ex) {
        throw new IllegalArgumentException(
            "@ZkParameter(name='"
                + paramName
                + "', "
                + "required="
                + (annot.required() ? "true" : "false")
                + ", "
                + "createIfNull="
                + (annot.createIfNull() ? "true" : "false")
                + ") - Unable to set new value of method to '"
                + result
                + "': "
                + ex.getClass()
                + " - "
                + ex.getLocalizedMessage(),
            ex);
      } catch (InvocationTargetException ex) {
        throw new IllegalArgumentException(
            "@ZkParameter(name='"
                + paramName
                + "', "
                + "required="
                + (annot.required() ? "true" : "false")
                + ", "
                + "createIfNull="
                + (annot.createIfNull() ? "true" : "false")
                + ") - Unable to set new value of method to '"
                + result
                + "', error in method invocation: "
                + ex.getClass()
                + " - "
                + (ex.getTargetException() == null
                    ? ex.getLocalizedMessage()
                    : ex.getTargetException().getLocalizedMessage()),
            ex);
      }
  }