Package dk.contix.eclipse.hudson

Examples of dk.contix.eclipse.hudson.Job


public class NameFilter extends ViewerFilter implements PropertyChangeListener{

  private String filterStr = null;

  public boolean select(Viewer viewer, Object parentElement, Object element) {
    Job job = (Job) element;
    String name = job.getName();
    IPreferenceStore prefs = Activator.getDefault().getPreferenceStore();          
    if(!prefs.getBoolean(Activator.PREF_FILTER_NAME)) {                    
      return true;
    }
    if (filterStr == null || name.startsWith(filterStr)) {                  
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 == 3 && j.getStatus() != null) {
      return j.getStatus().getImage();
    }
    if (columnIndex == 4 && j.getHealth() != null) {
      return j.getHealth().getImage();
    }
    return null;
  }
View Full Code Here

    }
    return null;
  }

  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 "#" + j.getLastBuild().getNumber();
      case 2:
        if (j.getLastBuild() == null) {
          return "No build";
        }
        return j.getLastBuild().getTimestamp().toLocaleString();
    }
    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) {
            final HudsonClient hudsonClient = new HudsonClient();
            try {
              hudsonClient.scheduleJob(j.getName());
            } catch (IOException e1) {
              return new Status(Status.ERROR, Activator.PLUGIN_ID, 0, "Unable to schedule job", e1);
            } catch (ParametersRequiredException e) {
              Display.getDefault().syncExec(new Runnable() {
                public void run() {
                  ParameterizedBuildDialog d = new ParameterizedBuildDialog(hudsonClient, j, getSite().getShell(), Activator.getDefault().getPluginPreferences());
                  d.open();
                  Activator.getDefault().savePluginPreferences();
                }
              });
            }

            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);

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

        showSecurityTokenDialog(j);
      }
    };
    securityTokenAction.setText("Set security token...");
    securityTokenAction.setToolTipText("Configure the security token used to schedule builds");
    securityTokenAction.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);
        securityTokenAction.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

import dk.contix.eclipse.hudson.Job;

public class StatusFilter extends ViewerFilter {

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

    switch (j.getStatus().getStatus()) {
      case SUCCESS:
        return prefs.getBoolean(Activator.PREF_FILTER_SUCCESS);
      case FAIL:
        return prefs.getBoolean(Activator.PREF_FILTER_FAIL);
      case TEST_FAIL:
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 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) {
            monitor.beginTask("Scheduling job " + j.getName(), 1);
            try {
              final HudsonClient hudsonClient = new HudsonClient();
              try {
                hudsonClient.scheduleJob(j.getName());
              } catch (IOException e1) {
                return new Status(Status.ERROR, Activator.PLUGIN_ID, 0, "Unable to schedule job", e1);
              } catch (ParametersRequiredException e) {
                Display.getDefault().syncExec(new Runnable() {
                  public void run() {
                    ParameterizedBuildDialog d = new ParameterizedBuildDialog(hudsonClient, j, getSite().getShell(), Activator.getDefault().getPluginPreferences());
                    d.open();
                    Activator.getDefault().savePluginPreferences();
                  }
                });
              }

              try {
                Thread.sleep(2000);
              } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
              }
              refreshAction.run();
            } finally {
              monitor.done();
            }
            return Status.OK_STATUS;
          }

        };
        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);

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

        showSecurityTokenDialog(j);
      }
    };
    securityTokenAction.setText("Set security token...");
    securityTokenAction.setToolTipText("Configure the security token used to schedule builds");
    securityTokenAction.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);
        securityTokenAction.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

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.