Package org.eclipse.ui

Examples of org.eclipse.ui.IViewReference


    if (idParts[0].length() == selectedTabId.length())
      idParts[1] = null;
   
    List fvs = getFastViews(id);
    for (Iterator fvIter = fvs.iterator(); fvIter.hasNext();) {
      IViewReference ref = (IViewReference) fvIter.next();
      removeViewReference(ref, true, !fvIter.hasNext());
    }

    // Restore the correct tab to the 'top'
    LayoutPart stack = perspective.getPresentation().findPart(id, null);
View Full Code Here


        continue;
     
      // Restore the views
      List fvs = getFastViews(id);
      for (Iterator fvIter = fvs.iterator(); fvIter.hasNext();) {
        IViewReference ref = (IViewReference) fvIter.next();
        removeViewReference(ref, true, !fvIter.hasNext());
      }

      // Blow the trim away
      IWindowTrim trim = tbm.getTrim(id);
View Full Code Here

      if (fvRefs.size() > 0) {
        IMemento childMem = memento
            .createChild(IWorkbenchConstants.TAG_FAST_VIEWS);
        Iterator itr = fvRefs.iterator();
        while (itr.hasNext()) {
          IViewReference ref = (IViewReference) itr.next();
          IMemento viewMemento = childMem
              .createChild(IWorkbenchConstants.TAG_VIEW);
          String id = ViewFactory.getKey(ref);
          viewMemento.putString(IWorkbenchConstants.TAG_ID, id);
          float ratio = perspective.getFastViewWidthRatio(ref);
          viewMemento.putFloat(IWorkbenchConstants.TAG_RATIO, ratio);
        }
      }
    }

    // Write all the current (non-empty) bars
    IMemento barsMemento = memento
        .createChild(IWorkbenchConstants.TAG_FAST_VIEW_BARS);

    Iterator mapIter = idToFastViewsMap.keySet().iterator();
    while (mapIter.hasNext()) {
      String id = (String) mapIter.next();

      // Legacy FV's are stored above...
      if (FastViewBar.FASTVIEWBAR_ID.equals(id))
        continue;

      List fvs = getFastViews(id);
      if (fvs.size() > 0) {
        IMemento barMemento = barsMemento
            .createChild(IWorkbenchConstants.TAG_FAST_VIEW_BAR);
        barMemento.putString(IWorkbenchConstants.TAG_ID, id);

        // Orientation / restore
        ViewStackTrimToolBar vstb = (ViewStackTrimToolBar) tbm
            .getTrim(id);
        if (vstb != null) {
          barMemento.putInteger(
              IWorkbenchConstants.TAG_FAST_VIEW_SIDE,
              vstb.getCurrentSide());
         
          barMemento.putInteger(
              IWorkbenchConstants.TAG_FAST_VIEW_ORIENTATION,
              vstb.getPaneOrientation());
         
          int boolVal = vstb.restoreOnUnzoom() ? 1 : 0;
          barMemento.putInteger(IWorkbenchConstants.TAG_FAST_VIEW_STYLE, boolVal);
         
          barMemento.putString(IWorkbenchConstants.TAG_FAST_VIEW_SEL_ID, vstb.getSelectedTabId());
        }

        IMemento viewsMem = barMemento
            .createChild(IWorkbenchConstants.TAG_FAST_VIEWS);
        Iterator itr = fvs.iterator();
        while (itr.hasNext()) {
          IMemento refMem = viewsMem
              .createChild(IWorkbenchConstants.TAG_VIEW);
          IViewReference ref = (IViewReference) itr.next();

          // id
          String viewId = ViewFactory.getKey(ref);
          refMem.putString(IWorkbenchConstants.TAG_ID, viewId);
         
View Full Code Here

      IMemento[] views = fastViewsMem
          .getChildren(IWorkbenchConstants.TAG_VIEW);
      for (int x = 0; x < views.length; x++) {
        // Get the view details.
        IMemento childMem = views[x];
        IViewReference ref = perspective.restoreFastView(childMem,
            result);
        if (ref != null)
          refsList.add(ref);
      }
    }

    // Load the Trim Stack info
    IMemento barsMem = memento
        .getChild(IWorkbenchConstants.TAG_FAST_VIEW_BARS);
   
    // It's not there for old workspaces
    if (barsMem == null)
      return;
   
    IMemento[] bars = barsMem
        .getChildren(IWorkbenchConstants.TAG_FAST_VIEW_BAR);
    for (int i = 0; i < bars.length; i++) {
      final String id = bars[i].getString(IWorkbenchConstants.TAG_ID);
      fastViewsMem = bars[i].getChild(IWorkbenchConstants.TAG_FAST_VIEWS);

      // -Replace- the current list with the one from the store
      refsList = new ArrayList();
      idToFastViewsMap.put(id, refsList);

      if (fastViewsMem != null) {
        IMemento[] views = fastViewsMem
            .getChildren(IWorkbenchConstants.TAG_VIEW);
              result.merge(perspective.createReferences(views));
       
        // Create the trim area for the trim stack
        // Only create the TB if there are views in it
        if (views.length > 0) {
          final int side = bars[i].getInteger(
              IWorkbenchConstants.TAG_FAST_VIEW_SIDE)
              .intValue();
          final int orientation = bars[i].getInteger(
              IWorkbenchConstants.TAG_FAST_VIEW_ORIENTATION)
              .intValue();
          int boolVal = bars[i].getInteger(
              IWorkbenchConstants.TAG_FAST_VIEW_STYLE).intValue();
          final boolean restoreOnUnzoom = (boolVal > 0);
         
          final String selId = bars[i].getString(IWorkbenchConstants.TAG_FAST_VIEW_SEL_ID);
         
          // Create the stack
              StartupThreading.runWithoutExceptions(new StartupRunnable() {
            public void runWithException() throws Throwable {
              ViewStackTrimToolBar vstb = getTrimForViewStack(id, side, orientation);
              vstb.setRestoreOnUnzoom(restoreOnUnzoom);
              if (selId != null)
                vstb.setSelectedTabId(selId);
            }
          });
        }
       
        for (int x = 0; x < views.length; x++) {
          // Get the view details.
          IMemento childMem = views[x];
          IViewReference ref = perspective.restoreFastView(childMem,
              result);
          if (ref != null)
            refsList.add(ref);
        }
      }
View Full Code Here

    while (mapIter.hasNext()) {
      String id = (String) mapIter.next();
      List fvList = (List) idToFastViewsMap.get(id);
      System.out.println("FastView: " + id + " count = " + fvList.size())//$NON-NLS-1$//$NON-NLS-2$
      for (Iterator fvIter = fvList.iterator(); fvIter.hasNext();) {
        IViewReference ref = (IViewReference) fvIter.next();
        System.out.println("  Ref: " + ref.getId()); //$NON-NLS-1$
      }
    }
  }
View Full Code Here

    IMemento viewMem = memento.createChild(IWorkbenchConstants.TAG_VIEWS);

    IViewReference[] refs = page.getViewReferences();

    for (int i = 0; i < refs.length; i++) {
      IViewReference viewReference = refs[i];
      String tagId = ViewFactory.getKey(viewReference);
      if (tagId != null) {
        IMemento childMem = viewMem
            .createChild(IWorkbenchConstants.TAG_VIEW);
        childMem.putString(IWorkbenchConstants.TAG_ID, tagId);
        String name = viewReference.getPartName();
        if (name != null) {
          childMem.putString(IWorkbenchConstants.TAG_PART_NAME, name);
        }
      }
    }

    // Create persp block.
    IMemento perspectiveMemento = memento
        .createChild(IWorkbenchConstants.TAG_PERSPECTIVES);
    if (page.getPerspective() != null) {
      perspectiveMemento.putString(
          IWorkbenchConstants.TAG_ACTIVE_PERSPECTIVE, page
              .getPerspective().getId());
    }
    if (page.getActivePart() != null) {
      if (page.getActivePart() instanceof IViewPart) {
        IViewReference ref = (IViewReference) page.getReference(page
            .getActivePart());
        if (ref != null) {
          perspectiveMemento.putString(
              IWorkbenchConstants.TAG_ACTIVE_PART, ViewFactory
                  .getKey(ref));
View Full Code Here

      public void fill(Menu parent, int index) {
            MenuItem closeItem = new MenuItem(parent, SWT.NONE, index++);
            closeItem.setText(WorkbenchMessages.WorkbenchWindow_close);
            closeItem.addSelectionListener(new SelectionAdapter() {
                public void widgetSelected(SelectionEvent e) {
                  IViewReference selectedView = null;
                  if (contextToolItem != null) {
                    selectedView = (IViewReference) contextToolItem.getData(ShowFastViewContribution.FAST_VIEW);
                  }
                 
                    if (selectedView != null) {
                        WorkbenchPage page = wbw.getActiveWorkbenchPage();
                        if (page != null) {
                            page.hideView(selectedView);
                        }
                    }
                }
            });
      }
    };
   
    // We have to manage the visiblity this way...?
    menuMgr.addMenuListener(new IMenuListener() {
      public void menuAboutToShow(IMenuManager manager) {
              IViewReference selectedView = null;
              if (contextToolItem != null) {
                selectedView = (IViewReference) contextToolItem.getData(ShowFastViewContribution.FAST_VIEW);
              }
             
              // Only show the 'close' item if we've clicked on a view
View Full Code Here

    // If there's a fast view showing, toggle it to pick up the change
    if (wbw.getActivePage() instanceof WorkbenchPage) {
      WorkbenchPage wbp = (WorkbenchPage) wbw.getActivePage();
      Perspective persp = wbp.getActivePerspective();
      if (persp != null) {
        IViewReference curRef = persp.getActiveFastView();
        if (curRef != null) {
          persp.setActiveFastView(null);
          persp.setActiveFastView(curRef);
        }
      }
View Full Code Here

        PartPlaceholder placeholder = null;
        LayoutPart testPart = null;
        String primaryId = part.getID();
        String secondaryId = null;

        IViewReference ref = null;
        if (part instanceof ViewPane) {
            ViewPane pane = (ViewPane) part;
            ref = (IViewReference) pane.getPartReference();
            secondaryId = ref.getSecondaryId();
        }
        if (secondaryId != null) {
      testPart = findPart(primaryId, secondaryId);
    } else {
      testPart = findPart(primaryId);
View Full Code Here

     * Deref a given part. Deconstruct its container as required. Do not remove
     * drag listeners.
     */
    /* package */void derefPart(LayoutPart part) {
        if (part instanceof ViewPane) {
          IViewReference ref = ((ViewPane) part).getViewReference();
          if (perspective.isFastView(ref)) {
            // Special check: if it's a fast view then it's actual ViewStack
            // may only contain placeholders and the stack is represented in
            // the presentation by a container placeholder...make sure the
            // PartPlaceHolder for 'ref' is removed from the ViewStack
            String id = perspective.getFastViewManager().getIdForRef(ref);
            LayoutPart parentPart = findPart(id, null);
            if (parentPart instanceof ContainerPlaceholder) {
              ViewStack vs = (ViewStack) ((ContainerPlaceholder)parentPart).getRealContainer();
              LayoutPart[] kids = vs.getChildren();
              for (int i = 0; i < kids.length; i++) {
            if (kids[i] instanceof PartPlaceholder) {
              if (ref.getId().equals(kids[i].id))
                vs.remove(kids[i]);
            }
          }
            }
            perspective.getFastViewManager().removeViewReference(ref, true, true);
View Full Code Here

TOP

Related Classes of org.eclipse.ui.IViewReference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.