Package org.springsource.ide.eclipse.commons.content.core

Examples of org.springsource.ide.eclipse.commons.content.core.ContentManager


  public static File importDirectory(ContentItem item, final Shell shell, boolean promptForDownload,
      SubMonitor monitor) throws CoreException, InterruptedException {
    Assert.isNotNull(item);
    String id = item.getId();
    ContentManager manager = ContentPlugin.getDefault().getManager();
    if (item.needsDownload()) {
      final ContentItem finalItem = item;
      final boolean[] response = { true };

      if (promptForDownload) {
        Display.getDefault().syncExec(new Runnable() {
          public void run() {
            response[0] = promptForDownload(shell, finalItem);
          }
        });
      }

      if (response[0]) {
        TemplateDownloader downloader = getTemplateDownloader(finalItem);
        IStatus status = downloader.downloadTemplate(monitor);
        if (!status.isOK()) {
          String message = NLS.bind("Download of template ''{0}'' failed: {1}", id, status.getMessage());
          throw new CoreException(new Status(IStatus.ERROR, WizardPlugin.PLUGIN_ID, message));
        }

        // re-get template project since it may changed
        item = manager.getItem(id);
        if (item == null) {
          return null;
        }
      }
      else if (!item.isLocal()) {
        return null;
      }
    }

    File baseDir = manager.getInstallDirectory();

    if (item.isRuntimeDefined()) {
      File directory = new File(baseDir, item.getPath());
      String projectName = item.getLocalDescriptor().getUrl();
      IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
View Full Code Here


  public static boolean hasBeenDownloaded(Template template) {
    return template != null && template.getTemplateData() != null;
  }

  private static TemplateDownloader getTemplateDownloader(ContentItem item) {
    ContentManager manager = ContentPlugin.getDefault().getManager();
    // Templates for simple projects are located in the bundle
    return manager.createDownloader(item);
  }
View Full Code Here

   * directory does not exist, it will create it, as well as its parents if
   * necessary.
   * @return installation directory.
   */
  public File getInstallDirectory() {
    ContentManager manager = ContentPlugin.getDefault().getManager();
    // Install Simple projects in a separate directory so that they do not
    // get managed by the content manager
    // for templates, since simple projects get treated differently.
    // However, the parent of the content manager
    // install directory should be the same (i.e. [workspace]/.metadata/.sts
    File file = new File(manager.getDataDirectory(), INSTALL_DIRECTORY);
    if (!file.exists()) {
      file.mkdirs();
    }
    return file;
  }
View Full Code Here

    this.contentManagerListener = new PropertyChangeListener() {

      public void propertyChange(PropertyChangeEvent event) {

        ContentManager manager = event.getSource() instanceof ContentManager ? (ContentManager) event
            .getSource() : null;
        final boolean hasTemplateContentChanged = manager != null && manager.isDirty();
        if (hasTemplateContentChanged) {

          clearTemplateSelection();

          // Only reinitialise templates if the manager is marked as
          // dirty, as template contents may have changed, therefore
          // new templates
          // need to be created in the tree viewer
          initialiseTemplatesFromContentManager();

        }
        // switch to UI thread to refresh the UI controls
        PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
          public void run() {
            refreshPage(hasTemplateContentChanged);
          }
        });

      }

    };

    ContentManager manager = ContentPlugin.getDefault().getManager();
    manager.addListener(contentManagerListener);

    // This does not automatically add the templates to the tree viewer
    // input.
    // Rather it downloads templates asynchronously, and the content manager
    // will then notify the tree viewer when the content is available and at
View Full Code Here

TOP

Related Classes of org.springsource.ide.eclipse.commons.content.core.ContentManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.