Beispiel #1
0
 /** @see ActionDelegate#run(IAction) */
 public void run(IAction action) {
   if (this.selection instanceof StructuredSelection) {
     StructuredSelection selection = (StructuredSelection) this.selection;
     if (!selection.isEmpty()) {
       IWorkbench workbench = PlatformUI.getWorkbench();
       Shell shell = workbench.getActiveWorkbenchWindow().getShell();
       IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
       InputDialog inputDialog =
           new InputDialog(
               Activator.getDefault().getWorkbench().getWorkbenchWindows()[0].getShell(),
               "Ingreso de version",
               "Ingrese la version a generar",
               "",
               null);
       int manual = inputDialog.open();
       if (manual == 0) {
         String value = inputDialog.getValue();
         IFolder folder = (IFolder) selection.getFirstElement();
         try {
           IFolder folder1 = folder.getFolder(new Path(value));
           folder1.create(true, false, new NullProgressMonitor());
           IFile file = folder1.getFile(new Path("000_db_version_insert.sql"));
           file.create(
               new ByteArrayInputStream(VERSION_SCRIPT.replace("DBVERSION", value).getBytes()),
               true,
               new NullProgressMonitor());
         } catch (CoreException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
         }
       }
     }
   }
 }
  private IModelNode getFirstElementInSelection() {
    StructuredSelection currentSelection = (StructuredSelection) getSelection();
    if (currentSelection == null || currentSelection.isEmpty()) {
      return null;
    }

    return (IModelNode) currentSelection.getFirstElement();
  }
 @Override
 public boolean test() throws Exception {
   StructuredSelection eventsTableSelection = getEventsTableSelection();
   if (eventsTableSelection.isEmpty()) {
     return false;
   }
   fCurValue = ((ITmfEvent) eventsTableSelection.getFirstElement()).getTimestamp().getValue();
   return fCurValue == fSelectionTime;
 }
 @SuppressWarnings("unchecked")
 private void openKontaktDialog() {
   final StructuredSelection selection = (StructuredSelection) kontakteTableViewer.getSelection();
   if (!selection.isEmpty()) {
     Iterator<KontaktEntry> iterator = selection.iterator();
     while (iterator.hasNext()) {
       final KontaktEntry selectedKontakt = iterator.next();
       searchForm.openKontaktDialog(selectedKontakt);
     }
   }
 }
 @SuppressWarnings("unchecked")
 protected void removePerson() {
   StructuredSelection selection = (StructuredSelection) viewer.getSelection();
   if (selection != null && !selection.isEmpty()) {
     for (Iterator<PersonInfo> iterator = selection.iterator(); iterator.hasNext(); ) {
       PersonInfo permission = iterator.next();
       this.personSet.remove(permission);
     }
     try {
       refreshTable();
     } catch (Throwable t) {
       log.error("Error while setting table data", t); // $NON-NLS-1$
     }
   }
 }
Beispiel #6
0
 @Override
 public void setSelection(ISelection selection) {
   if (selection instanceof StructuredSelection) {
     StructuredSelection sel = (StructuredSelection) selection;
     if (sel.isEmpty()) productTypeGUIList.setSelection(-1);
     else {
       ProductType spi = (ProductType) sel.getFirstElement();
       int idx = 0;
       for (Iterator it = productTypeItemList.iterator(); it.hasNext(); ++idx) {
         ProductType pi = (ProductType) it.next();
         if (spi.getPrimaryKey().equals(pi.getPrimaryKey())) {
           productTypeGUIList.setSelection(idx);
           break;
         }
       }
     }
   }
 }
 public Object execute(ExecutionEvent event) throws ExecutionException {
   StructuredSelection mainViewSelection =
       (StructuredSelection)
           PlatformUI.getWorkbench()
               .getActiveWorkbenchWindow()
               .getSelectionService()
               .getSelection("de.berlios.quotations.ui.MainView");
   if (!mainViewSelection.isEmpty()) {
     Quotation quotation = (Quotation) mainViewSelection.getFirstElement();
     if (quotation.getId() != null) {
       if (MessageBoxes.question(Messages.getString("DeleteRecordAction.Question"))
           == SWT.YES) { //$NON-NLS-1$
         Activator.getDB().deleteById(quotation.getId());
         Activator.refresh();
       }
     }
   }
   return null;
 }
  /** {@inheritDoc} */
  @Override
  public Object execute(final ExecutionEvent event) throws ExecutionException {
    final StructuredSelection selection =
        (StructuredSelection) HandlerUtil.getCurrentSelection(event);

    if (selection.isEmpty()) {
      return null;
    }

    final int size = selection.size();
    MessageBox confirmDelete =
        new MessageBox(HandlerUtil.getActiveShell(event), SWT.OK | SWT.CANCEL | SWT.ICON_QUESTION);
    confirmDelete.setText("Confirm Delete");
    confirmDelete.setMessage(
        "Are you sure you want to delete the "
            + size
            + " selected environment"
            + ((size > 1) ? "s" : "")
            + "?");
    boolean confirmed = SWT.OK == confirmDelete.open();

    if (confirmed) {
      Job deleteEnvironmentsJob =
          new Job("Delete Environment(s) Job") {

            @Override
            protected IStatus run(IProgressMonitor monitor) {
              List<Status> statuses = new ArrayList<>();
              for (Iterator<?> it = selection.iterator(); it.hasNext(); ) {
                Object selected = it.next();
                if (selected instanceof IEnvironmentProvider) {
                  CmrRepositoryDefinition repositoryDefinition =
                      ((IEnvironmentProvider) selected).getCmrRepositoryDefinition();
                  Environment environment = ((IEnvironmentProvider) selected).getEnvironment();

                  try {
                    if (repositoryDefinition.getOnlineStatus() != OnlineStatus.OFFLINE) {
                      repositoryDefinition
                          .getConfigurationInterfaceService()
                          .deleteEnvironment(environment);

                      InspectIT.getDefault()
                          .getInspectITConfigurationInterfaceManager()
                          .environmentDeleted(environment, repositoryDefinition);
                    }
                  } catch (BusinessException e) {
                    statuses.add(
                        new Status(
                            IStatus.ERROR,
                            InspectIT.ID,
                            "Error deleting environment "
                                + environment.getName()
                                + " from the CMR.",
                            e));
                  }
                }
              }

              if (CollectionUtils.isNotEmpty(statuses)) {
                if (1 == statuses.size()) {
                  return statuses.iterator().next();
                } else {
                  return new MultiStatus(
                      InspectIT.ID,
                      IStatus.OK,
                      statuses.toArray(new Status[statuses.size()]),
                      "Delete of several environments failed.",
                      null);
                }
              } else {
                return Status.OK_STATUS;
              }
            }
          };
      deleteEnvironmentsJob.setUser(true);
      deleteEnvironmentsJob.setProperty(
          IProgressConstants.ICON_PROPERTY,
          InspectIT.getDefault().getImageDescriptor(InspectITImages.IMG_BLOCK));
      deleteEnvironmentsJob.schedule();
    }

    return null;
  }