@Override
 protected boolean handleKeyUp(KeyEvent ke) {
   int state = ke.getState();
   int key = ke.keyCode;
   if (state == 0 && key == SWT.DEL) {
     ISelection selection = viewer.getSelection();
     if (selection instanceof IStructuredSelection) {
       Object element = ((IStructuredSelection) selection).getFirstElement();
       if (element instanceof ITemplate) {
         ITemplate template = (ITemplate) element;
         if (MindMapUI.getResourceManager().isUserTemplate(template)) {
           if (MessageDialog.openConfirm(
               viewer.getControl().getShell(),
               WorkbenchMessages.ConfirmDeleteTemplateDialog_title,
               NLS.bind(
                   WorkbenchMessages.ConfirmDeleteTemplateDialog_message_withTemplateName,
                   template.getName()))) {
             MindMapUI.getResourceManager().removeUserTemplate(template);
           }
         }
       }
     }
   }
   return super.handleKeyUp(ke);
 }
  private void handleTemplateSelected(ISelection selection) {
    templateOpening = true;
    Display.getCurrent()
        .asyncExec(
            new Runnable() {
              public void run() {
                if (viewer == null
                    || viewer.getControl() == null
                    || viewer.getControl().isDisposed()) return;

                viewer.setSelection(StructuredSelection.EMPTY);
              }
            });

    if (selection == null || selection.isEmpty() || !(selection instanceof IStructuredSelection)) {
      templateOpening = false;
      return;
    }

    Object selectedElement = ((IStructuredSelection) selection).getFirstElement();
    if (selectedElement == null || !(selectedElement instanceof ITemplate)) return;

    ITemplate template = (ITemplate) selectedElement;
    IEditorInput editorInput =
        MindMapUI.getEditorInputFactory().createEditorInput(template.createWorkbookRef());
    getContext().openEditor(editorInput, MindMapUI.MINDMAP_EDITOR_ID);

    templateOpening = false;
  }
 private List<ITemplate> getViewerInput() {
   ArrayList<ITemplate> templates = new ArrayList<ITemplate>();
   IResourceManager resourceManager = MindMapUI.getResourceManager();
   templates.addAll(resourceManager.getSystemTemplates());
   templates.addAll(resourceManager.getUserTemplates());
   // move recently added template ahead
   Collections.reverse(templates);
   return templates;
 }
Esempio n. 4
0
    public void createControl(Composite parent) {
      Composite composite = new Composite(parent, SWT.NONE);
      GridLayout gridLayout = new GridLayout(1, false);
      gridLayout.marginWidth = 5;
      gridLayout.marginHeight = 5;
      gridLayout.verticalSpacing = 5;
      gridLayout.horizontalSpacing = 5;
      composite.setLayout(gridLayout);
      setControl(composite);

      Label label = new Label(composite, SWT.NONE);
      label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
      label.setText(WizardMessages.MarkerExportPage_ChooseMarkerGroups_label);

      viewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
      viewer.setContentProvider(new MarkerGroupContentProvider());
      viewer.setLabelProvider(new MarkerGroupLabelProvider());
      viewer.setInput(MindMapUI.getResourceManager().getUserMarkerSheet());
      viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

      Control fileControl = createFileControls(composite);
      fileControl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    }
 @Override
 public void dispose() {
   MindMapUI.getResourceManager().removeResourceManagerListener(this);
   super.dispose();
 }