コード例 #1
0
 @Test
 public void testWorkbenchRunningPredicateFalse() {
   IWorkbench wb = mock(IWorkbench.class);
   when(wb.isClosing()).thenReturn(false);
   sut = new WorkbenchRunningPredicate(wb);
   assertTrue(sut.apply(status));
 }
コード例 #2
0
  /** @see org.eclipse.jface.action.Action#run() */
  @Override
  public void run() {
    IResource resource = null;
    IWorkbench workbench = PlatformUI.getWorkbench();
    if ((workbench != null) && !workbench.isClosing()) {
      IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
      if (window != null) {
        if (dbNodeSelected != null) {
          // db node selected => get parent to retrieve the resource
          // or the project (if the resource does not exist)
          if (dbNodeSelected.getParent() instanceof ProjectNode) {
            ProjectNode pNode = (ProjectNode) dbNodeSelected.getParent();
            resource =
                ResourcesPlugin.getWorkspace()
                    .getRoot()
                    .getProject(pNode.getName())
                    .getFile(ProjectNode.DB_FOLDER + IPath.SEPARATOR + dbNodeSelected.getName());
            if (!resource.exists()) {
              resource = resource.getProject();
            }
          }
        } else if (dbProjectNodeSelected != null) {

          ProjectNode pNode = dbProjectNodeSelected;
          resource =
              ResourcesPlugin.getWorkspace()
                  .getRoot()
                  .getProject(pNode.getName())
                  .getFile(
                      ProjectNode.DB_FOLDER + IPath.SEPARATOR + dbProjectNodeSelected.getName());
          if (!resource.exists()) {
            resource = resource.getProject();
          }
        } else {
          // db node not selected on tree => try to get resource based
          // on selection from package explorer
          Object selectionElement = getSelectionElement(window);
          if (selectionElement == null) {
            // the wizard was requested to open from Andmore menu -
            // open wizard without selecting project or .db file
            resource = null;
          } else {
            // there is an item selected, get the resource
            // associated
            resource = getResourceFromSelection(selectionElement);
          }
        }
        openDialogBasedOnResourceSelected(resource, window);
      }
    }
  }