Beispiel #1
0
 public void setInitializationData(IConfigurationElement config, String propertyName, Object data)
     throws CoreException {
   String variable = data != null && data instanceof String ? data.toString() : null;
   if (variable != null) {
     for (int i = 0; i < samples.length; i++) {
       IConfigurationElement element = samples[i];
       String id = element.getAttribute("id"); // $NON-NLS-1$
       if (id != null && id.equals(variable)) {
         setSelection(element);
         break;
       }
     }
   }
 }
Beispiel #2
0
 public boolean performFinish() {
   try {
     String perspId = selection.getAttribute("perspectiveId"); // $NON-NLS-1$
     IWorkbenchPage page = PDEPlugin.getActivePage();
     if (perspId != null && switchPerspective) {
       PlatformUI.getWorkbench().showPerspective(perspId, page.getWorkbenchWindow());
     }
     SampleOperation op =
         new SampleOperation(selection, namesPage.getProjectNames(), new ImportOverwriteQuery());
     getContainer().run(true, true, op);
     IFile sampleManifest = op.getSampleManifest();
     if (selectRevealEnabled) {
       selectReveal(getShell());
     }
     if (activitiesEnabled) enableActivities();
     if (sampleEditorNeeded && sampleManifest != null) IDE.openEditor(page, sampleManifest, true);
   } catch (InvocationTargetException e) {
     PDEPlugin.logException(e);
     return false;
   } catch (InterruptedException e) {
     // PDEPlugin.logException(e);
     return false;
   } catch (CoreException e) {
     PDEPlugin.logException(e);
     return false;
   } catch (OperationCanceledException e) {
     return false;
   }
   return true;
 }
Beispiel #3
0
  /*private void doSelectReveal() {
  	if (selection == null || createdProjects==null)
  		return;
  	String viewId = selection.getAttribute("targetViewId"); //$NON-NLS-1$
  	if (viewId == null)
  		return;
  	IWorkbenchWindow window = PlatformUI.getWorkbench()
  			.getActiveWorkbenchWindow();
  	if (window == null)
  		return;
  	IWorkbenchPage page = window.getActivePage();
  	if (page == null)
  		return;
  	IViewPart view = page.findView(viewId);
  	if (view == null || !(view instanceof ISetSelectionTarget))
  		return;
  	ISetSelectionTarget target = (ISetSelectionTarget) view;
  	IConfigurationElement[] projects = selection.getChildren("project"); //$NON-NLS-1$

  	ArrayList items = new ArrayList();
  	for (int i = 0; i < projects.length; i++) {
  		String path = projects[i].getAttribute("selectReveal"); //$NON-NLS-1$
  		if (path == null)
  			continue;
  		IResource resource = createdProjects[i].findMember(path);
  		if (resource.exists())
  			items.add(resource);
  	}
  	if (items.size() > 0)
  		target.selectReveal(new StructuredSelection(items));
  }
  */
  public void enableActivities() {
    IConfigurationElement[] elements = selection.getChildren("activity"); // $NON-NLS-1$
    HashSet activitiesToEnable = new HashSet();
    IWorkbenchActivitySupport workbenchActivitySupport =
        PlatformUI.getWorkbench().getActivitySupport();

    for (int i = 0; i < elements.length; i++) {
      IConfigurationElement element = elements[i];
      String id = element.getAttribute("id"); // $NON-NLS-1$
      if (id == null) continue;
      activitiesToEnable.add(id);
    }
    HashSet set =
        new HashSet(workbenchActivitySupport.getActivityManager().getEnabledActivityIds());
    set.addAll(activitiesToEnable);
    workbenchActivitySupport.setEnabledActivityIds(set);
  }
  /**
   * {@inheritDoc} The <code>WorkbenchPart</code> implementation of this <code>IExecutableExtension
   * </code> records the configuration element in and internal state variable (accessible via <code>
   * getConfigElement</code>). It also loads the title image, if one is specified in the
   * configuration element. Subclasses may extend.
   *
   * <p>Should not be called by clients. It is called by the core plugin when creating this
   * executable extension.
   */
  public void setInitializationData(IConfigurationElement cfig, String propertyName, Object data) {

    // Save config element.
    configElement = cfig;

    // Part name and title.
    partName = Util.safeString(cfig.getAttribute("name")); // $NON-NLS-1$;
    title = partName;

    // Icon.
    String strIcon = cfig.getAttribute("icon"); // $NON-NLS-1$
    if (strIcon == null) {
      return;
    }

    imageDescriptor =
        AbstractUIPlugin.imageDescriptorFromPlugin(configElement.getNamespace(), strIcon);

    if (imageDescriptor == null) {
      return;
    }

    titleImage = JFaceResources.getResources().createImageWithDefault(imageDescriptor);
  }