Exemplo n.º 1
0
  /**
   * (inheritDoc)
   *
   * @param listener
   * @see org.goko.featuremanager.service.IFeatureManager#install(java.util.List)
   */
  @Override
  public IStatus install(
      List<GkInstallableUnit> units, IProgressMonitor monitor, IJobChangeListener listener)
      throws GkException {
    // get the repository managers and define our repositories
    IMetadataRepositoryManager manager =
        (IMetadataRepositoryManager)
            getProvisioningAgent().getService(IMetadataRepositoryManager.SERVICE_NAME);

    List<IInstallableUnit> p2Units = new ArrayList<IInstallableUnit>();
    for (GkInstallableUnit gkInstallableUnit : units) {
      if (!gkInstallableUnit.isInstalled()) {
        p2Units.add(gkInstallableUnit.getBaseUnit());
      }
    }
    final InstallOperation installOperation =
        new InstallOperation(new ProvisioningSession(getProvisioningAgent()), p2Units);
    LOG.info("installOperation created " + String.valueOf(installOperation));

    IStatus operationStatus = installOperation.resolveModal(monitor);
    LOG.info("operationStatus " + String.valueOf(operationStatus));

    if (operationStatus.getSeverity() > IStatus.WARNING) {
      LOG.error("installOperation detail :" + installOperation.getResolutionDetails());

      LOG.error("Install operation failed :" + operationStatus.toString());
      if (operationStatus.isMultiStatus()) {
        for (IStatus status : operationStatus.getChildren()) {
          LOG.error("   + " + status.getMessage());
        }
      }
      LOG.error(new CoreException(operationStatus));
      return operationStatus;
    }

    final ProvisioningJob provisioningJob = installOperation.getProvisioningJob(monitor);
    LOG.info("ProvisioningJob created " + String.valueOf(provisioningJob));

    provisioningJob.schedule();

    provisioningJob.addJobChangeListener(listener);

    LOG.info("Installation of feature done");

    return operationStatus;
  }
Exemplo n.º 2
0
  /**
   * Create contents of the view part.
   *
   * @throws GkException
   */
  @PostConstruct
  public void createControls(Composite parent, MPart part) {
    try {
      GridLayout gl_parent = new GridLayout(1, false);
      gl_parent.marginWidth = 0;
      gl_parent.marginHeight = 0;
      parent.setLayout(gl_parent);

      Composite composite = new Composite(parent, SWT.NONE);
      composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
      formToolkit.adapt(composite);
      formToolkit.paintBordersFor(composite);
      composite.setLayout(new GridLayout(2, false));

      lblStatus = formToolkit.createLabel(composite, "Status :", SWT.NONE);
      lblStatus.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
      lblStatus.setBounds(0, 0, 55, 15);

      Composite composite_3 = formToolkit.createComposite(composite, SWT.NONE);
      formToolkit.paintBordersFor(composite_3);
      composite_3.setLayout(new GridLayout(2, false));

      lblDisconnected = formToolkit.createLabel(composite_3, "Disconnected", SWT.NONE);
      lblDisconnected.setImage(
          ResourceManager.getPluginImage("org.goko.serial", "icons/bullet_red.png"));

      lblDisconnected_1 = formToolkit.createLabel(composite_3, "Disconnected", SWT.NONE);

      Label lblSerialPort = new Label(composite, SWT.NONE);
      lblSerialPort.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
      lblSerialPort.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));
      formToolkit.adapt(lblSerialPort, true, true);
      lblSerialPort.setText("Serial port :");

      Composite composite_1 = new Composite(composite, SWT.NONE);
      composite_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
      formToolkit.adapt(composite_1);
      formToolkit.paintBordersFor(composite_1);
      GridLayout gl_composite_1 = new GridLayout(3, false);
      gl_composite_1.marginWidth = 0;
      gl_composite_1.marginHeight = 0;
      composite_1.setLayout(gl_composite_1);

      comboSerialPort = new GkCombo<LabeledValue>(composite_1, SWT.NONE | SWT.READ_ONLY);
      Combo combo = comboSerialPort.getCombo();
      GridData gd_combo = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
      gd_combo.widthHint = 40;
      combo.setLayoutData(gd_combo);

      comboBaudrate = new GkCombo<LabeledValue>(composite_1, SWT.NONE | SWT.READ_ONLY);
      Combo combo_1 = comboBaudrate.getCombo();
      GridData gd_combo_1 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
      gd_combo_1.widthHint = 40;
      combo_1.setLayoutData(gd_combo_1);

      Button button = formToolkit.createButton(composite_1, "", SWT.NONE);
      button.addMouseListener(
          new MouseAdapter() {
            @Override
            public void mouseUp(MouseEvent e) {
              controller.refreshSerialPortList();
            }
          });

      button.setImage(
          ResourceManager.getPluginImage("org.goko.serial", "icons/arrow-circle-double.png"));
      new Label(composite, SWT.NONE);

      Composite composite_2 = formToolkit.createComposite(composite, SWT.NONE);
      formToolkit.paintBordersFor(composite_2);
      composite_2.setLayout(new GridLayout(2, false));

      btnConnect = formToolkit.createButton(composite_2, "Connect", SWT.NONE);
      btnConnect.addMouseListener(
          new MouseAdapter() {
            @Override
            public void mouseUp(MouseEvent e) {
              controller.connect();
            }
          });
      btnConnect.setEnabled(false);

      btnDisconnect = formToolkit.createButton(composite_2, "Disconnect", SWT.NONE);
      btnDisconnect.addMouseListener(
          new MouseAdapter() {
            @Override
            public void mouseUp(MouseEvent e) {
              controller.disconnect();
            }
          });
      btnDisconnect.setEnabled(false);
      btnDisconnect.setBounds(0, 0, 75, 25);
      m_bindingContext = initDataBindings();
      applyPersistedStates(part);
    } catch (GkException e) {
      LOG.error(e);
    }
  }