Package dk.contix.eclipse.hudson

Examples of dk.contix.eclipse.hudson.Job


import dk.contix.eclipse.hudson.Job;

public class JobSorter extends ViewerSorter {

  public int compare(Viewer viewer, Object e1, Object e2) {
    Job j1 = (Job) e1;
    Job j2 = (Job) e2;
    return j1.getName().compareTo(j2.getName());
  }
View Full Code Here


import dk.contix.eclipse.hudson.Job;

public class StatusFilter extends ViewerFilter {

  public boolean select(Viewer viewer, Object parentElement, Object element) {
    Job j = (Job) element;
    String r = j.getColor();
    IPreferenceStore prefs = Activator.getDefault().getPreferenceStore();

    if (r.startsWith(Job.BUILD_SUCCESS)) {
      return prefs.getBoolean(Activator.PREF_FILTER_SUCCESS);
    } else if (r.startsWith(Job.BUILD_FAIL)) {
View Full Code Here

public class JobLabelProvider extends LabelProvider implements
    ITableLabelProvider {

  public Image getColumnImage(Object element, int columnIndex) {
    Job j = (Job) element;
    if (columnIndex == 2 && j.getColor() != null) {
      ImageDescriptor img = Activator.getImageDescriptor("icons/" + j.getColor().toLowerCase() + ".png");
      if (img != null) {
        return img.createImage();
      }
    }
    return null;
View Full Code Here

  }
 
 

  public String getColumnText(Object element, int columnIndex) {
    Job j = (Job) element;
    switch (columnIndex) {
      case 0:
        return j.getName();
      case 1:
        if (j.getLastBuild() == null) {
          return "No build";
        }
        return "Build " + j.getLastBuild();
    }
    return null;
  }
View Full Code Here

  }

  private void makeFilterAction(IMenuManager manager) {
    IStructuredSelection sel = (IStructuredSelection) viewer.getSelection();
    if (sel.size() == 1) {
      Job j = (Job) sel.getFirstElement();
      manager.add(new FilterJobAction("Ignore failed builds", "Do not report build errors for this project", j.getName()));
    }
  }
View Full Code Here

  private void makeActions() {
    scheduleAction = new Action() {
      public void run() {
        IStructuredSelection sel = (IStructuredSelection) viewer.getSelection();
        final Job j = (Job) sel.getFirstElement();

        org.eclipse.core.runtime.jobs.Job sj = new org.eclipse.core.runtime.jobs.Job("Scheduling Hudson build") {
          protected IStatus run(IProgressMonitor monitor) {
            try {
              new HudsonClient().scheduleJob(j.getName());
            } catch (IOException e1) {
              return new Status(Status.ERROR, Activator.PLUGIN_ID, 0, "Unable to schedule job", e1);
            }

            try {
              Thread.sleep(2000);
            } catch (InterruptedException e) {
              Thread.currentThread().interrupt();
            }
            Display.getDefault().syncExec(new Runnable() {
              public void run() {
                viewer.refresh();
              }
            });
            return Status.OK_STATUS;
          }

        };
        sj.setPriority(org.eclipse.core.runtime.jobs.Job.INTERACTIVE);
        sj.schedule();
      }
    };
    scheduleAction.setText("Schedule new build");
    scheduleAction.setToolTipText("Schedule new build for project");
    scheduleAction.setImageDescriptor(Activator.getImageDescriptor("icons/schedule.png"));
    scheduleAction.setEnabled(false);

    openBrowserAction = new Action() {
      public void run() {
        IStructuredSelection sel = (IStructuredSelection) viewer.getSelection();
        openBrowser(sel);
      }
    };
    openBrowserAction.setText("Open in browser");
    openBrowserAction.setToolTipText("Open job status in browser");
    openBrowserAction.setEnabled(false);

    viewConsoleAction = new Action() {
      public void run() {
        IStructuredSelection sel = (IStructuredSelection) viewer.getSelection();
        Job j = (Job) sel.getFirstElement();

        String url = baseUrl + "/job/" + j.getName() + "/lastBuild/consoleText";
        openBrowser(url, "Console output");
      }
    };
    viewConsoleAction.setText("View console output");
    viewConsoleAction.setToolTipText("Open the console output for the latest build");
    viewConsoleAction.setEnabled(false);

    viewer.addSelectionChangedListener(new ISelectionChangedListener() {
      public void selectionChanged(SelectionChangedEvent event) {
        IStructuredSelection sel = (IStructuredSelection) event.getSelection();
        scheduleAction.setEnabled(sel.size() == 1);
        openBrowserAction.setEnabled(sel.size() == 1);

        Job j = (Job) sel.getFirstElement();
        viewConsoleAction.setEnabled(sel.size() == 1 && j.getLastBuild() != null);
      }
    });

    refreshAction = new Action() {
      public void run() {
View Full Code Here

      viewer.getControl().setFocus();
    }
  }

  private void openBrowser(IStructuredSelection selection) {
    final Job j = (Job) selection.getFirstElement();
    final String url = baseUrl + "/job/" + j.getName();
    final String name = j.getName();
    openBrowser(url, name);
  }
View Full Code Here

  private void makeActions() {
    scheduleAction = new Action() {
      public void run() {
        IStructuredSelection sel = (IStructuredSelection) viewer.getSelection();
        final Job j = (Job) sel.getFirstElement();

        org.eclipse.core.runtime.jobs.Job sj = new org.eclipse.core.runtime.jobs.Job("Scheduling Hudson build") {
          protected IStatus run(IProgressMonitor monitor) {
            try {
              new HudsonClient().scheduleJob(j.getName());
            } catch (IOException e1) {
              return new Status(Status.ERROR, Activator.PLUGIN_ID, 0, "Unable to schedule job", e1);
            }

            try {
              Thread.sleep(2000);
            } catch (InterruptedException e) {
              Thread.currentThread().interrupt();
            }
            Display.getDefault().syncExec(new Runnable() {
              public void run() {
                viewer.refresh();
              }
            });
            return Status.OK_STATUS;
          }

        };
        sj.setPriority(org.eclipse.core.runtime.jobs.Job.INTERACTIVE);
        sj.schedule();
      }
    };
    scheduleAction.setText("Schedule new build");
    scheduleAction.setToolTipText("Schedule new build for project");
    scheduleAction.setImageDescriptor(Activator.getImageDescriptor("icons/schedule.png"));
    scheduleAction.setEnabled(false);

    openBrowserAction = new Action() {
      public void run() {
        IStructuredSelection sel = (IStructuredSelection) viewer.getSelection();
        openBrowser(sel);
      }
    };
    openBrowserAction.setText("Open in browser");
    openBrowserAction.setToolTipText("Open job status in browser");
    openBrowserAction.setEnabled(false);

    viewConsoleAction = new Action() {
      public void run() {
        IStructuredSelection sel = (IStructuredSelection) viewer.getSelection();
        Job j = (Job) sel.getFirstElement();

        String url = baseUrl + "/job/" + j.getName() + "/lastBuild/consoleText";
        openBrowser(url, "Console output");
      }
    };
    viewConsoleAction.setText("View console output");
    viewConsoleAction.setToolTipText("Open the console output for the latest build");
    viewConsoleAction.setEnabled(false);

    viewer.addSelectionChangedListener(new ISelectionChangedListener() {
      public void selectionChanged(SelectionChangedEvent event) {
        IStructuredSelection sel = (IStructuredSelection) event.getSelection();
        scheduleAction.setEnabled(sel.size() == 1);
        openBrowserAction.setEnabled(sel.size() == 1);

        Job j = (Job) sel.getFirstElement();
        viewConsoleAction.setEnabled(sel.size() == 1 && j.getLastBuild() != null);
      }
    });

    refreshAction = new Action() {
      public void run() {
View Full Code Here

      viewer.getControl().setFocus();
    }
  }

  private void openBrowser(IStructuredSelection selection) {
    final Job j = (Job) selection.getFirstElement();
    final String url = baseUrl + "/job/" + j.getName();
    final String name = j.getName();
    openBrowser(url, name);
  }
View Full Code Here

import dk.contix.eclipse.hudson.Job;

public class JobLabelProvider extends LabelProvider implements ITableLabelProvider {

  public Image getColumnImage(Object element, int columnIndex) {
    Job j = (Job) element;
    if (columnIndex == 2 && j.getColor() != null) {
      ImageDescriptor img = Activator.getImageDescriptor("icons/" + j.getColor().toLowerCase() + ".png");
      if (img != null) {
        return img.createImage();
      }
    }
    return null;
View Full Code Here

TOP

Related Classes of dk.contix.eclipse.hudson.Job

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.