Package org.eclipse.ui.progress

Examples of org.eclipse.ui.progress.UIJob


  private void loadNamespaces(SelectionEvent event) {
    String xml = null;
    try {
      xml = XPathEvaluationView.getActiveTextEditorContent();
    } catch (final GUIException e) {
      new UIJob(bundle.getString("label.namespace.loader")) {
        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
          Notification.showToolTip(SWT.BALLOON | SWT.ICON_ERROR, bundle.getString("label.error"), e.getMessage(), query);
          return Status.OK_STATUS;
        }
View Full Code Here


    String xpath = query.getText();
    String xml = null;
    try {
      xml = XPathEvaluationView.getActiveTextEditorContent();
    } catch (final GUIException e) {
      new UIJob(bundle.getString("label.xpath.evaluation")) {
        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
          Notification.showToolTip(SWT.BALLOON | SWT.ICON_ERROR, bundle.getString("label.error"), e.getMessage(), query);
          return Status.OK_STATUS;
        }
View Full Code Here

    try {
      XdmValue evaluatedResult = XPathEvaluator.evaluate(xpath, namespaces, xml, isPrettyPrint);
      String evaluatedResultXml = XPathEvaluator.transformResult(evaluatedResult, isPrettyPrint);
      outputResult(evaluatedResultXml, evaluatedResult.size());
    } catch (final Exception e) {
      new UIJob(bundle.getString("label.xpath.evaluation")) {
        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
          Notification.showToolTip(SWT.BALLOON | SWT.ICON_ERROR, bundle.getString("label.error"), e.getMessage(), query);
          return Status.OK_STATUS;
        }
View Full Code Here

          return;
        }

        final Shell shell = aShell;

        UIJob job = new UIJob("Notify of incoming shared task") {
          public IStatus runInUIThread(IProgressMonitor monitor) {
            final IncomingSharedTaskNotificationPopup popup = new IncomingSharedTaskNotificationPopup(shell);
            popup.setTask(task);
            popup.open();

            new UIJob(shell.getDisplay(), "Close Popup Job") { //$NON-NLS-1$
              public IStatus runInUIThread(IProgressMonitor monitor) {
                Shell shell = popup.getShell();
                if (shell != null && !shell.isDisposed()) {
                  popup.close();
                }
                monitor.done();
                return Status.OK_STATUS;
              }
            }.schedule(5000);
            return Status.OK_STATUS;
          }
        };
        job.schedule();
      } catch (Exception ex) {
        ex.printStackTrace();
      } finally {
        file.delete();
      }
View Full Code Here

      tasks.remove(task);
      contexts.remove(task);
    }

    private void scheduleTaskActivationJob() {
      UIJob job = new UIJob(shell.getDisplay(), "Activate imported task") {
        public IStatus runInUIThread(IProgressMonitor monitor) {
          TasksUi.getTaskActivityManager().activateTask(task);
          return Status.OK_STATUS;
        }
      };
      job.schedule();
    }
View Full Code Here

        if (isFirstMessage) {
          final MessageNotificationPopup popup = new MessageNotificationPopup(getSite().getWorkbenchWindow(), tabFolder.getShell(), remoteID);
          popup.setContent(name, body);
          popup.open();

          new UIJob(tabFolder.getDisplay(), "Close Popup Job") { //$NON-NLS-1$
            public IStatus runInUIThread(IProgressMonitor monitor) {
              Shell shell = popup.getShell();
              if (shell != null && !shell.isDisposed()) {
                popup.close();
              }
View Full Code Here

  /**
   *
   * @param event
   */
  protected void fireEventComplete(final IUserSearchCompleteEvent event) {
    new UIJob(Messages.SearchContactDialog_UserSearchJobName) {
      public IStatus runInUIThread(IProgressMonitor monitor) {
        try {
          final UserSearchView view = (UserSearchView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(UserSearchView.VIEW_ID);
          view.showMessage(Messages.SearchContactDialog_SearchingMessage);
          view.addMultiRosterAccount(account);
View Full Code Here

      delegate.run(this);
    }
  }
 
  public void update() {
    UIJob job = new UIJob("") { //$NON-NLS-1$
      public IStatus runInUIThread(IProgressMonitor monitor) {
        setEnabled(isEnabled());
        return Status.OK_STATUS;
      }
    };
    job.setSystem(true);
    job.setPriority(Job.INTERACTIVE);
    job.schedule();
  }
View Full Code Here

    // }
    delegate.run(view);
  }
 
  public void update() {
    UIJob job = new UIJob("") { //$NON-NLS-1$
      public IStatus runInUIThread(IProgressMonitor monitor) {
        setEnabled(isEnabled());
        return Status.OK_STATUS;
      }
    };
    job.setSystem(true);
    job.setPriority(Job.INTERACTIVE);
    job.schedule();
  }
View Full Code Here

     */
    public IStatus configure(final IProgressMonitor monitor) {
      final String userSettingsFileName = MavenPlugin.getMavenConfiguration().getUserSettingsFile();
      this.oldUserSettingsFileName = userSettingsFileName;

      UIJob job = new UIJob("Configure Maven Repository") {

        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
          try {
            File globalRespository = MavenPlugin.getRepositoryRegistry().getLocalRepository()
                .getBasedir();

            if (ask(location.getCanonicalPath())) {
              PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
              Resource[] resources = resolver.getResources("file://" + location.getCanonicalPath()
                  + File.separatorChar + "**");
              for (Resource resource : resources) {
                File fileResource = resource.getFile();
                if (fileResource.isFile()) {
                  String relativePath = fileResource.getCanonicalPath().substring(
                      location.getCanonicalPath().length() + 1,
                      fileResource.getCanonicalPath().length());
                  monitor.subTask(String.format("Copying '%s'", relativePath));
                  File newFileResource = new File(globalRespository, relativePath);
                  if (!newFileResource.exists()) {
                    newFileResource.getParentFile().mkdirs();
                    FileCopyUtils.copy(fileResource, newFileResource);
                  }
                }
              }
            }
            else {
              File userSettingsFile = new File(userSettingsFileName);
              // check if the file already exists; if not create new one
              if (!userSettingsFile.exists()) {
                BufferedWriter writer = new BufferedWriter(new FileWriter(getSettingsFile()));
                writer.append(SETTINGS_TEMPLATE);
                writer.close();
              }
              else {
                // if the settings.xml file exists; copy it into the workspace
                FileCopyUtils.copy(userSettingsFile, getSettingsFile());
              }

              // load file to search for existing <localRepository> node
              Document document = SpringCoreUtils.parseDocument(getSettingsFile().toURI());
              NodeList nodes = document.getDocumentElement().getChildNodes();
              boolean found = false;
              for (int i = 0; i < nodes.getLength(); i++) {
                Node node = nodes.item(i);
                if (LOCAL_REPOSITORY_ELEMENT_NAME.equals(node.getLocalName())
                    || LOCAL_REPOSITORY_ELEMENT_NAME.equals(node.getNodeName())) {
                  // point to the detected maven repository
                  node.setTextContent(location.getCanonicalPath());
                  found = true;
                  break;
                }
              }

              // if no <localRepository> node exists, create a new one
              if (!found) {
                Element node = document.createElement(LOCAL_REPOSITORY_ELEMENT_NAME);
                node.appendChild(document.createTextNode(location.getCanonicalPath()));
                document.getDocumentElement().appendChild(node);
              }

              // write the new settings file out to disk
              TransformerFactory transformerFactory = TransformerFactory.newInstance();
              Transformer transformer = transformerFactory.newTransformer();
              transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
              transformer.setOutputProperty(OutputKeys.INDENT, "yes");
              transformer.setOutputProperty(OutputKeys.ENCODING, document.getInputEncoding());

              Writer out = new OutputStreamWriter(new FileOutputStream(getSettingsFile()),
                  document.getInputEncoding());
              StreamResult result = new StreamResult(out);
              DOMSource source = new DOMSource(document);
              transformer.transform(source, result);
              out.close();

              // set the new settings.xml path
              MavenPlugin.getMavenConfiguration()
                  .setUserSettingsFile(getSettingsFile().getCanonicalPath());
            }
          }
          catch (Exception e) {
            MavenCorePlugin.getDefault().getLog()
                .log(new Status(IStatus.ERROR, MavenCorePlugin.PLUGIN_ID, 1, e.getMessage(), e));
            return Status.CANCEL_STATUS;
          }
          return Status.OK_STATUS;
        }
      };

      // we need to wait until the UI job completes as otherwise the workbench might shut down
      final boolean[] done = new boolean[1];
      job.addJobChangeListener(new JobChangeAdapter() {

        @Override
        public void done(IJobChangeEvent event) {
          done[0] = true;
        }
      });

      job.schedule();

      while (!done[0]) {
        try {
          Thread.sleep(1000);
        }
View Full Code Here

TOP

Related Classes of org.eclipse.ui.progress.UIJob

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.