private void handleRemove() {
   IStructuredSelection ssel = (IStructuredSelection) fImportListViewer.getSelection();
   if (ssel.size() > 0) {
     Table table = fImportListViewer.getTable();
     int index = table.getSelectionIndices()[0];
     doRemove(ssel.toList());
     table.setSelection(index < table.getItemCount() ? index : table.getItemCount() - 1);
     pageChanged(false, true);
   }
 }
 private void handleDelete() {
   IStructuredSelection ssel = (IStructuredSelection) fPluginTable.getSelection();
   if (ssel.size() > 0) {
     Object[] objects = ssel.toArray();
     IProductPlugin[] plugins = new IProductPlugin[objects.length];
     System.arraycopy(objects, 0, plugins, 0, objects.length);
     getProduct().removePlugins(plugins);
     updateRemoveButtons(true, true);
   }
 }
 private void handleAdd() {
   IStructuredSelection ssel = (IStructuredSelection) fAvailableListViewer.getSelection();
   if (ssel.size() > 0) {
     Table table = fAvailableListViewer.getTable();
     int index = table.getSelectionIndices()[0];
     doAdd(ssel.toList());
     table.setSelection(index < table.getItemCount() ? index : table.getItemCount() - 1);
     pageChanged(true, false);
   }
 }
 private void updateNewFolderButtonState() {
   IStructuredSelection selection = (IStructuredSelection) fViewer.getSelection();
   fSelectedContainer = null;
   if (selection.size() == 1) {
     Object first = selection.getFirstElement();
     if (first instanceof IContainer) {
       fSelectedContainer = (IContainer) first;
     }
   }
   fNewFolderButton.setEnabled(fSelectedContainer != null);
 }
 private void doSearch(ISelection sel) {
   IPackageFragment frag = getPackageFragment(sel);
   if (frag != null) {
     FindReferencesAction action = new FindReferencesAction(getPage().getEditorSite());
     action.run(frag);
   } else if (sel instanceof IStructuredSelection) {
     IStructuredSelection selection = (IStructuredSelection) sel;
     PackageObject exportObject = (PackageObject) selection.getFirstElement();
     NewSearchUI.runQueryInBackground(new BlankQuery(exportObject));
   }
 }
 private void handleProperties() {
   IStructuredSelection ssel = (IStructuredSelection) fPluginTable.getSelection();
   if (ssel.size() == 1) {
     IProductPlugin plugin = (IProductPlugin) ssel.toArray()[0];
     VersionDialog dialog =
         new VersionDialog(PDEPlugin.getActiveWorkbenchShell(), isEditable(), plugin.getVersion());
     dialog.create();
     SWTUtil.setDialogSize(dialog, 400, 200);
     if (dialog.open() == Window.OK) {
       plugin.setVersion(dialog.getVersion());
     }
   }
 }
  private IPackageFragment getPackageFragment(ISelection sel) {
    if (sel instanceof IStructuredSelection) {
      IStructuredSelection selection = (IStructuredSelection) sel;
      if (selection.size() != 1) return null;

      IBaseModel model = getPage().getModel();
      if (!(model instanceof IPluginModelBase)) return null;

      return PDEJavaHelper.getPackageFragment(
          ((PackageObject) selection.getFirstElement()).getName(),
          ((IPluginModelBase) model).getPluginBase().getId(),
          getPage().getPDEEditor().getCommonProject());
    }
    return null;
  }
Example #8
0
  protected void initializeViewer() {
    Object[] elems = fSelection.toArray();
    ArrayList checked = new ArrayList(elems.length);

    for (int i = 0; i < elems.length; i++) {
      Object elem = elems[i];
      IProject project = null;

      if (elem instanceof IFile) {
        IFile file = (IFile) elem;
        project = file.getProject();
      } else if (elem instanceof IProject) {
        project = (IProject) elem;
      } else if (elem instanceof IJavaProject) {
        project = ((IJavaProject) elem).getProject();
      }
      if (project != null) {
        IModel model = findModelFor(project);
        if (model != null && !checked.contains(model)) {
          checked.add(model);
        }
      }
    }
    fExportPart.setSelection(checked.toArray());
    if (checked.size() > 0) fExportPart.getTableViewer().reveal(checked.get(0));
  }
 private ISiteFeature[] getFeaturesFromSelection(IStructuredSelection sel) {
   if (sel.isEmpty()) return new ISiteFeature[0];
   if (cachedSelection == sel) return cachedFeatures;
   cachedSelection = sel;
   ArrayList<ISiteFeature> features = new ArrayList<ISiteFeature>(sel.size());
   Iterator<?> iterator = sel.iterator();
   while (iterator.hasNext()) {
     Object next = iterator.next();
     if (next instanceof SiteFeatureAdapter) {
       if ((((SiteFeatureAdapter) next).feature) != null) {
         features.add(((SiteFeatureAdapter) next).feature);
       }
     }
   }
   cachedFeatures = features.toArray(new ISiteFeature[features.size()]);
   return cachedFeatures;
 }
 protected void handleDoubleClick(IStructuredSelection ssel) {
   super.handleDoubleClick(ssel);
   Object selected = ssel.getFirstElement();
   if (selected instanceof SiteFeatureAdapter) {
     IFeature feature = findFeature(((SiteFeatureAdapter) selected).feature);
     FeatureEditor.openFeatureEditor(feature);
   }
 }
 /** Tests if the current workbench selection is a suitable container to use. */
 private void initialize() {
   if (selection != null
       && selection.isEmpty() == false
       && selection instanceof IStructuredSelection) {
     IStructuredSelection ssel = (IStructuredSelection) selection;
     if (ssel.size() > 1) {
       return;
     }
     Object obj = ssel.getFirstElement();
     if (obj instanceof IResource) {
       IContainer container;
       if (obj instanceof IContainer) {
         container = (IContainer) obj;
       } else {
         container = ((IResource) obj).getParent();
       }
       containerText.setText(container.getFullPath().toString());
     }
   }
   fileText.setText("new.gaml");
 }
Example #12
0
 @Override
 public Object execute(ExecutionEvent event) throws ExecutionException {
   IWorkbenchPart part = HandlerUtil.getActivePartChecked(event);
   ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
   if (part instanceof MarketDataView && selection instanceof IStructuredSelection) {
     MarketDataView view = (MarketDataView) part;
     IStructuredSelection sselection = (IStructuredSelection) selection;
     StringBuilder builder = new StringBuilder();
     for (Object obj : sselection.toArray()) {
       if (obj instanceof MarketDataViewItem) {
         MarketDataViewItem item = (MarketDataViewItem) obj;
         builder.append(item);
         builder.append(System.getProperty("line.separator")); // $NON-NLS-1$
       }
     }
     view.getClipboard()
         .setContents(
             new Object[] {builder.toString()}, new Transfer[] {TextTransfer.getInstance()});
   }
   return null;
 }
  /* (non-Javadoc)
   * @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#fillContextMenu(org.eclipse.jface.action.IMenuManager)
   */
  protected void fillContextMenu(IMenuManager manager) {
    IStructuredSelection ssel = (IStructuredSelection) fPluginTable.getSelection();
    if (ssel == null) return;

    Action openAction =
        new Action(PDEUIMessages.PluginSection_open) {
          public void run() {
            handleDoubleClick((IStructuredSelection) fPluginTable.getSelection());
          }
        };
    openAction.setEnabled(isEditable() && ssel.size() == 1);
    manager.add(openAction);

    manager.add(new Separator());

    Action removeAction =
        new Action(PDEUIMessages.PluginSection_remove) {
          public void run() {
            handleDelete();
          }
        };
    removeAction.setEnabled(isEditable() && ssel.size() > 0);
    manager.add(removeAction);

    Action removeAll =
        new Action(PDEUIMessages.PluginSection_removeAll) {
          public void run() {
            handleRemoveAll();
          }
        };
    removeAll.setEnabled(isEditable());
    manager.add(removeAll);

    manager.add(new Separator());

    getPage().getPDEEditor().getContributor().contextMenuAboutToShow(manager);
  }
  private boolean handleRemove() {
    IStructuredSelection ssel = (IStructuredSelection) fCategoryViewer.getSelection();
    Iterator<?> iterator = ssel.iterator();
    boolean success = true;
    Set<?> removedCategories = new HashSet<Object>();
    while (iterator.hasNext()) {
      Object object = iterator.next();
      if (object == null) continue;
      if (object instanceof ISiteCategoryDefinition) {
        if (!handleRemoveCategoryDefinition((ISiteCategoryDefinition) object)) {
          success = false;
        }
      } else {
        // check if some of features was not removed during category removal
        SiteFeatureAdapter fa = (SiteFeatureAdapter) object;
        if (removedCategories.contains(fa.category)) continue;

        if (!handleRemoveSiteFeatureAdapter(fa)) {
          success = false;
        }
      }
    }
    return success;
  }
 private void handleOpen(IStructuredSelection selection) {
   Object object = selection.getFirstElement();
   if (object instanceof IProductPlugin) {
     ManifestEditor.openPluginEditor(((IProductPlugin) object).getId());
   }
 }