/*
   * (non-Javadoc)
   *
   * @see org.eclipse.jface.wizard.Wizard#performFinish()
   */
  @Override
  public boolean performFinish() {
    boolean saved = false;

    try {
      DoSave doSave = new DoSave();

      getContainer().run(false, false, doSave);

      if (doSave.exception != null) {
        throw doSave.exception;
      } else {
        saved = doSave.saved;
      }
    } catch (Exception e) {
      IStatus status =
          new Status(IStatus.ERROR, CodeUtilsActivator.PLUGIN_ID, e.getLocalizedMessage());
      EclipseUtils.showErrorDialog(
          CodeUtilsNLS.UI_GenericErrorDialogTitle,
          CodeUtilsNLS.ERR_BuildingBlockCreation_ErrorMessage,
          status);
    }

    if (saved) {
      ICompilationUnit javaFile =
          getBuildingBlock()
              .getPackageFragment()
              .getCompilationUnit(getBuildingBlock().getName() + ".java"); // $NON-NLS-1$

      if ((javaFile != null) && javaFile.exists()) {
        try {
          JavaUI.openInEditor(javaFile);
        } catch (Exception e) {
          // Do nothing
          AndmoreLogger.error(
              NewActivityBasedOnTemplateWizard.class,
              "Could not open the activity " //$NON-NLS-1$
                  + getBuildingBlock().getName()
                  + " on an editor.",
              e); //$NON-NLS-1$
        }
      }
    }

    if (saved) {
      // Collecting usage data for statistical purposes
      try {
        AndmoreLogger.collectUsageData(
            UsageDataConstants.WHAT_BUILDINGBLOCK_ACTIVITY,
            UsageDataConstants.KIND_BUILDINGBLOCK,
            UsageDataConstants.DESCRIPTION_DEFAULT,
            CodeUtilsActivator.PLUGIN_ID,
            CodeUtilsActivator.getDefault().getBundle().getVersion().toString());
      } catch (Throwable e) {
        // Do nothing, but error on the log should never prevent app
        // from working
      }
    }
    return saved;
  }
Exemplo n.º 2
0
  /**
   * Retrieves an image data. If it has never been used at the current session, loads it from skin.
   * Released image is retrieved if both parameters are false.
   *
   * @param isPressed true if the image to be retrieved is the pressed image
   * @param isEnter true if the image to be retrieved is the enter image. It only has effect if
   *     isPressed == false
   * @return An image data containing the desired image pixels
   */
  private ImageData getImageData(boolean isPressed, boolean isEnter) {

    ImageData imageData = null;

    IAndroidEmulatorInstance instance = UIHelper.getInstanceAssociatedToControl(this);

    try {
      if (isPressed) {
        imageData = skin.getPressedImageData(instance.getCurrentLayout());

      } else {
        if (isEnter) {
          imageData = skin.getEnterImageData(instance.getCurrentLayout());

        } else {
          imageData = skin.getReleasedImageData(instance.getCurrentLayout());
        }
      }
    } catch (SkinException e) {
      error(
          "The image requested from skin could not be retrieved. isPressed="
              + isPressed
              + "; message="
              + e.getMessage());
      EclipseUtils.showErrorDialog(e);
      error("The skin could not provide an important resource. Stopping the instance");
      try {
        instance.stop(true);
      } catch (InstanceStopException e1) {
        error("Error while running service for stopping virtual machine");
        EclipseUtils.showErrorDialog(
            EmulatorNLS.GEN_Error, EmulatorNLS.EXC_General_CannotRunStopService);
      }
    }

    return imageData;
  }
Exemplo n.º 3
0
 @Override
 public void consoleKilled(String name) {
   if (telnetsCache.containsKey(name)) {
     TelnetFrameworkAndroid telnet = telnetsCache.get(name);
     if (telnet.isConnected()) {
       try {
         telnet.disconnect();
       } catch (IOException e) {
         EclipseUtils.showInformationDialog(
             ServicesNLS.GEN_Warning,
             ServicesNLS.WARN_EmulatorConsoleHandler_CouldNotCloseTheConsoleConnection);
       }
     }
     telnetsCache.remove(name);
     DeviceServicesPlugin.removeConsoleKilledListener(listener);
   }
 }
 @Override
 public void run(IProgressMonitor monitor)
     throws InvocationTargetException, InterruptedException {
   try {
     saved = getBuildingBlock().save(getContainer(), monitor);
     getBuildingBlock().getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
     getBuildingBlock().getProject().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
   } catch (CoreException ce) {
     // build failed - show a warning message
     AndmoreLogger.error(this.getClass(), ce.getMessage(), ce);
     EclipseUtils.showWarningDialog(
         CodeUtilsNLS.UI_NewActivityWizard_TitleNewActivityWizard,
         CodeUtilsNLS.NewActivityWizard_MessageSomeProblemsOccurredWhileBuildingProject);
   } catch (AndroidException e) {
     exception = e;
   }
 }
Exemplo n.º 5
0
  @Override
  public void applyLayout(String layoutName) {
    // Populate the attributes with information from skin
    AndroidSkinBean skinBean = null;

    try {
      skinBean = skin.getSkinBean(layoutName);
    } catch (SkinException e) {
      error("The skin data could not be retrieved from skin files. Cause: " + e.getMessage());
      EclipseUtils.showErrorDialog(e);
    }

    // Create layout and set it to composite
    if (skinBean != null) {
      // When changing to a new layout, the key may move to another
      // position
      // It does not make sense to keep the old key object
      currentKey = null;

      // Change the background color to the one that applies to the layout
      // being set
      RGB color = skin.getBackgroundColor(layoutName);
      setBackground(new Color(PlatformUI.getWorkbench().getDisplay(), color));

      Layout prevLayout = getLayout();
      if (prevLayout instanceof AndroidSkinLayout) {
        ((AndroidSkinLayout) prevLayout).dispose();
      }

      AndroidSkinLayout androidLayout = new AndroidSkinLayout(skinBean, skin.isFlipSupported());
      setLayout(androidLayout);

      embeddedViewScale = skinBean.getEmbeddedViewScale();

      layout();
      redraw();
    }
  }
Exemplo n.º 6
0
  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {
    List<ITreeNode> nodesToDelete = getSelection();

    if (!nodesToDelete.isEmpty()) {
      boolean shouldProceed = showQuestion(nodesToDelete);
      if (shouldProceed) {
        Map<IKeyStore, List<String>> deleteNodesMap = getKeysMap(nodesToDelete);

        for (IKeyStore keyStore : deleteNodesMap.keySet()) {
          try {
            keyStore.removeKeys(deleteNodesMap.get(keyStore));
          } catch (KeyStoreManagerException e) {
            EclipseUtils.showErrorDialog(e);
            throw new ExecutionException(e.getMessage(), e);
          }
        }
      }
    }

    nodesToDelete.clear();

    return null;
  }