public static boolean isManagedByEMFStore(EObject object) {
    Workspace currentWorkspace = WorkspaceManager.getInstance().getCurrentWorkspace();
    for (Resource resource : currentWorkspace.getResourceSet().getResources()) {
      TreeIterator<EObject> allContents = resource.getAllContents();
      while (allContents.hasNext()) {
        EObject currentObject = allContents.next();
        if (object.equals(currentObject)) {
          return true;
        }
      }
    }

    return false;
  }
  private EObject findManagedEObject(String uriFragment) {
    Workspace currentWorkspace = WorkspaceManager.getInstance().getCurrentWorkspace();

    for (Resource resource : currentWorkspace.getResourceSet().getResources()) {
      TreeIterator<EObject> allContents = resource.getAllContents();
      while (allContents.hasNext()) {
        EObject currentObject = allContents.next();
        if (uriFragment.equals(currentObject.eResource().getURIFragment(currentObject))) {
          return currentObject;
        }
      }
    }

    return null;
  }
コード例 #3
0
  public void showHistory() throws EmfStoreException {
    if (projectSpace == null) {
      projectSpace =
          WorkspaceManager.getInstance()
              .getCurrentWorkspace()
              .getProjectSpace(ModelUtil.getProject(modelElement));
    }

    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    HistoryBrowserView historyBrowserView = null;
    String viewId =
        "org.eclipse.emf.emfstore.client.ui.views.historybrowserview.HistoryBrowserView";
    try {
      historyBrowserView = (HistoryBrowserView) page.showView(viewId);
    } catch (PartInitException e) {
      EMFStoreMessageDialog.showExceptionDialog(e);
    }
    if (historyBrowserView != null) {
      historyBrowserView.setInput(projectSpace, modelElement);
    }
  }
  /**
   * {@inheritDoc}
   *
   * @see
   *     org.eclipse.emf.emfstore.client.model.connectionmanager.SessionProvider#provideUsersession(org.eclipse.emf.emfstore.client.model.ServerInfo)
   */
  @Override
  public Usersession provideUsersession(ServerInfo serverInfo) throws EmfStoreException {
    if (serverInfo == null) {
      // try to retrieve a server info by showing a server info selection dialog
      ServerInfoSelectionDialog dialog =
          new ServerInfoSelectionDialog(
              Display.getCurrent().getActiveShell(),
              WorkspaceManager.getInstance().getCurrentWorkspace().getServerInfos());
      if (dialog.open() == Dialog.OK) {
        serverInfo = dialog.getResult();
      }
    }
    if (serverInfo == null) {
      throw new AccessControlException("Couldn't determine which server to connect.");
    }

    // TODO Review this
    // if (serverInfo.getLastUsersession() != null && serverInfo.getLastUsersession().isLoggedIn())
    // {
    // return serverInfo.getLastUsersession();
    // }

    return new LoginDialogController().login(serverInfo);
  }