@Override
  public void fillContextMenu(IMenuManager menu) {
    boolean onlyEnvironmentsSelected = true;
    StructuredSelection selection =
        (StructuredSelection) getActionSite().getStructuredViewer().getSelection();
    Iterator iterator = selection.iterator();
    List<EnvironmentDescription> environments = new ArrayList<EnvironmentDescription>();
    while (iterator.hasNext()) {
      Object obj = iterator.next();
      if (obj instanceof EnvironmentDescription) {
        environments.add((EnvironmentDescription) obj);
      } else {
        onlyEnvironmentsSelected = false;
      }
    }

    if (onlyEnvironmentsSelected) {
      if (environments.size() == 1) {
        menu.add(new OpenEnvironmentEditorAction(environments.get(0)));
        menu.add(new Separator());
      }

      menu.add(new TerminateEnvironmentsAction(environments));
    }
  }
Ejemplo n.º 2
0
  /** @see IActionDelegate#selectionChanged(IAction, ISelection) */
  public void selectionChanged(IAction action, ISelection selection) {

    if (selection instanceof StructuredSelection) {
      currentSelection = (StructuredSelection) selection;
      Iterator<StructuredSelection> it = currentSelection.iterator();

      while (it.hasNext()) {
        file = (IFile) it.next();
      }
    }
  }
 @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);
     }
   }
 }
 public void toggleExpandState(int state, StructuredSelection selection) {
   TreeItem[] items = fExtensionTree.getTree().getSelection();
   if (state == NEEDS_EXPAND) { // expand sub tree
     traverseChildrenAndSetExpanded(items); // load non-expanded children
     fExtensionTree.refresh();
     expandChildrenElements(selection.toArray(), true);
     fExtensionTree.setSelection(selection, false);
   } else { // collapse sub tree
     for (Iterator<?> iterator = selection.iterator(); iterator.hasNext(); ) {
       fExtensionTree.setExpandedState(iterator.next(), false);
     }
   }
 }
 /** @generated */
 public void setInput(IWorkbenchPart part, ISelection selection) {
   if (selection.isEmpty() || false == selection instanceof StructuredSelection) {
     super.setInput(part, selection);
     return;
   }
   final StructuredSelection structuredSelection = ((StructuredSelection) selection);
   ArrayList transformedSelection = new ArrayList(structuredSelection.size());
   for (Iterator it = structuredSelection.iterator(); it.hasNext(); ) {
     Object r = transformSelection(it.next());
     if (r != null) {
       transformedSelection.add(r);
     }
   }
   super.setInput(part, new StructuredSelection(transformedSelection));
 }
Ejemplo n.º 6
0
 @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$
     }
   }
 }
Ejemplo n.º 7
0
 @SuppressWarnings({"rawtypes", "unchecked"})
 @Override
 public void setInput(final IWorkbenchPart part, final ISelection selection) {
   if (selection.isEmpty() || false == selection instanceof StructuredSelection) {
     super.setInput(part, selection);
     return;
   }
   final StructuredSelection structuredSelection = ((StructuredSelection) selection);
   final ArrayList transformedSelection = new ArrayList(structuredSelection.size());
   for (final Iterator it = structuredSelection.iterator(); it.hasNext(); ) {
     final Object r = transformSelection(it.next());
     if (r != null) {
       transformedSelection.add(r);
     }
   }
   super.setInput(part, new StructuredSelection(transformedSelection));
 }
  @Override
  public boolean isEnabled() {
    // Get workbench page for the Control View
    IWorkbenchPage page = getWorkbenchPage();
    if (page == null) {
      return false;
    }

    TraceChannelComponent channel = null;
    TraceSessionComponent session = null;
    ISelection selection = page.getSelection(ControlView.ID);
    if (selection instanceof StructuredSelection) {
      StructuredSelection structered = ((StructuredSelection) selection);
      for (Iterator<?> iterator = structered.iterator(); iterator.hasNext(); ) {
        Object element = iterator.next();
        if (element instanceof TraceChannelComponent) {
          // Add only if corresponding TraceSessionComponents is inactive and not destroyed
          TraceChannelComponent tmpChannel = (TraceChannelComponent) element;
          session = tmpChannel.getSession();
          if (session.getSessionState() == TraceSessionState.INACTIVE && !session.isDestroyed()) {
            channel = tmpChannel;
          }
        }
      }
    }

    boolean isEnabled = (channel != null);
    fLock.lock();
    try {
      fParam = null;
      if (isEnabled) {
        fParam = new ChannelCommandParameter(session, channel);
      }
    } finally {
      fLock.unlock();
    }
    return isEnabled;
  }
  @Override
  public boolean isEnabled() {

    // Get workbench page for the Control View
    IWorkbenchPage page = getWorkbenchPage();
    if (page == null) {
      return false;
    }

    TraceDomainComponent kernelDomain = null;
    TraceDomainComponent ustDomain = null;
    List<TraceChannelComponent> kernelChannels = new ArrayList<>();
    List<TraceChannelComponent> ustChannels = new ArrayList<>();

    // Check if one or more session are selected
    ISelection selection = page.getSelection(ControlView.ID);
    if (selection instanceof StructuredSelection) {
      StructuredSelection structered = ((StructuredSelection) selection);
      String sessionName = null;
      for (Iterator<?> iterator = structered.iterator(); iterator.hasNext(); ) {
        Object element = iterator.next();

        if (element instanceof TraceChannelComponent) {

          // Add only TraceChannelComponents that are disabled
          TraceChannelComponent channel = (TraceChannelComponent) element;
          if (sessionName == null) {
            sessionName = String.valueOf(channel.getSessionName());
          }

          // Enable command only for channels of same session
          if (!sessionName.equals(channel.getSessionName())) {
            kernelChannels.clear();
            ustChannels.clear();
            break;
          }

          if ((channel.getState() != getNewState())) {
            if (channel.isKernel()) {
              kernelChannels.add(channel);
              if (kernelDomain == null) {
                kernelDomain = (TraceDomainComponent) channel.getParent();
              }
            } else {
              ustChannels.add(channel);
              if (ustDomain == null) {
                ustDomain = (TraceDomainComponent) channel.getParent();
              }
            }
          }
        }
      }
    }

    boolean isEnabled = (!kernelChannels.isEmpty() || !ustChannels.isEmpty());
    fLock.lock();
    try {
      if (isEnabled) {
        fParam = new Parameter(kernelDomain, ustDomain, kernelChannels, ustChannels);
      }
    } finally {
      fLock.unlock();
    }

    return isEnabled;
  }
Ejemplo n.º 10
0
  @Override
  public boolean isEnabled() {
    // Get workbench page for the Control View
    IWorkbenchPage page = getWorkbenchPage();
    if (page == null) {
      return false;
    }

    // Check if one or more session are selected
    ISelection selection = page.getSelection(ControlView.ID);

    TraceChannelComponent channel = null;
    List<TraceEventComponent> events = new ArrayList<>();

    if (selection instanceof StructuredSelection) {
      StructuredSelection structered = ((StructuredSelection) selection);
      String sessionName = null;
      String channelName = null;

      for (Iterator<?> iterator = structered.iterator(); iterator.hasNext(); ) {
        Object element = iterator.next();

        if (element instanceof TraceEventComponent) {

          TraceEventComponent event = (TraceEventComponent) element;
          if (sessionName == null) {
            sessionName = String.valueOf(event.getSessionName());
          }

          if (channel == null) {
            channel = (TraceChannelComponent) event.getParent();
          }

          if (channelName == null) {
            channelName = event.getChannelName();
          }

          // Enable command only for events of same session, same channel and domain
          if ((!sessionName.equals(event.getSessionName()))
              || (!channelName.equals(event.getChannelName()))
              || (channel.isKernel() != event.isKernel())) {
            events.clear();
            break;
          }

          if ((event.getState() != getNewState())) {
            events.add(event);
          }
        }
      }
    }
    boolean isEnabled = !events.isEmpty();

    fLock.lock();
    try {
      fParam = null;
      if (isEnabled) {
        fParam = new Parameter(channel, events);
      }
    } finally {
      fLock.unlock();
    }
    return isEnabled;
  }