private void addItem(final String item) {
   Display.syncExec(
       new Runnable() {
         @Override
         public void run() {
           new DefaultList().getSWTWidget().add(item);
         }
       });
 }
示例#2
0
  /**
   * Gets items included in specified {@link CCombo}.
   *
   * @param ccombo custom combo to handle
   * @return names of items included in custom combo
   */
  public String[] getItems(final CCombo ccombo) {
    return Display.syncExec(
        new ResultRunnable<String[]>() {

          @Override
          public String[] run() {
            return ccombo.getItems();
          }
        });
  }
示例#3
0
  /**
   * Gets index of the selection of specified {@link CCombo}.
   *
   * @param ccombo custom combo to handle
   * @return index of the selection of specified custom combo
   */
  public int getSelectionIndex(final CCombo ccombo) {
    return Display.syncExec(
        new ResultRunnable<Integer>() {

          @Override
          public Integer run() {
            return ccombo.getSelectionIndex();
          }
        });
  }
示例#4
0
 /**
  * Finds a diagram editor in a given editor part.
  *
  * @param editorPart Editor part
  * @return Diagram editor
  */
 public DiagramEditor findDiagramEditor(final IEditorPart editorPart) {
   DiagramEditor diagramEditor =
       Display.syncExec(
           new ResultRunnable<DiagramEditor>() {
             @Override
             public DiagramEditor run() {
               return (DiagramEditor) editorPart.getAdapter(DiagramEditor.class);
             }
           });
   if (diagramEditor == null) {
     throw new GEFLayerException("Cannot find diagram editor in a given editor part");
   }
   return diagramEditor;
 }
 @After
 public void cleanup() {
   org.jboss.reddeer.core.util.Display.syncExec(
       new Runnable() {
         @Override
         public void run() {
           for (Shell shell : org.jboss.reddeer.core.util.Display.getDisplay().getShells()) {
             if (shell.getText().equals(title)) {
               shell.dispose();
               break;
             }
           }
           new WaitWhile(new ShellWithTextIsActive(title));
         }
       });
 }
示例#6
0
  /**
   * Gets text of the selection of specified {@link CCombo}.
   *
   * @param ccombo custom combo to handle
   * @return text of specified selection of specified custom combo
   */
  public String getSelection(final CCombo ccombo) {
    return Display.syncExec(
        new ResultRunnable<String>() {

          @Override
          public String run() {
            Point selection = ccombo.getSelection();
            String comboText = ccombo.getText();
            String selectionText = "";
            if (selection.y > selection.x) {
              selectionText = comboText.substring(selection.x, selection.y);
            }
            return selectionText;
          }
        });
  }
 public FacesConfigSourceEditor getFacesConfigSourceEditor() {
   activateSourceTab();
   IEditorPart editorPart = EditorPartLookup.getInstance().getActiveEditor();
   final org.jboss.tools.jsf.ui.editor.FacesConfigEditor fce =
       ((org.jboss.tools.jsf.ui.editor.FacesConfigEditor)
           ((EditorPartWrapper) editorPart).getEditor());
   ITextEditor iTextEditor =
       (ITextEditor)
           Display.syncExec(
               new ResultRunnable<IEditorPart>() {
                 @Override
                 public IEditorPart run() {
                   return fce.getSourceEditor();
                 }
               });
   return new FacesConfigSourceEditor(iTextEditor);
 }
示例#8
0
  /**
   * Sets selection of specified {@link CCombo} to the item on specified position.
   *
   * @param ccombo custom combo to handle
   * @param index index of item to select
   */
  public void setSelection(final CCombo ccombo, final int index) {
    Display.syncExec(
        new Runnable() {

          @Override
          public void run() {
            int itemsLength = getItems(ccombo).length;
            if (index >= itemsLength) {
              log.error("CCombo does not have " + index + 1 + "items!");
              log.info("CCombo has " + itemsLength + " items");
              throw new CoreLayerException("Nonexisted item in combo was requested");
            } else {
              ccombo.select(index);
            }
          }
        });
  }
示例#9
0
  @Before
  public void setUp() {
    shell = new WorkbenchShell().getSWTWidget();
    org.jboss.reddeer.core.util.Display.asyncExec(
        new Runnable() {

          @Override
          public void run() {
            wizard = new TestingWizard();

            org.eclipse.jface.wizard.WizardDialog swtWizardDialog =
                new org.eclipse.jface.wizard.WizardDialog(shell, wizard);
            swtWizardDialog.create();
            swtWizardDialog.open();
          }
        });
    new WaitUntil(new ShellWithTextIsActive(TestingWizard.TITLE));
    wizardDialog = new WizardDialog();
  }
示例#10
0
  /**
   * Adds a tool in a given group from a palette to the specified coordinates.
   *
   * @param tool Tool label
   * @param group Group label
   * @param x X-axis
   * @param y Y-axis
   * @return the org.jboss.reddeer.gef.api. edit part
   */
  public org.jboss.reddeer.gef.api.EditPart addToolFromPalette(
      String tool, String group, final int x, final int y) {
    int oldCount = getNumberOfEditParts();

    final ViewerListener viewerListener = new ViewerListener();
    Display.asyncExec(
        new Runnable() {
          @Override
          public void run() {
            List<EditPart> editParts = ViewerHandler.getInstance().getEditParts(viewer);
            for (EditPart editPart : editParts) {
              editPart.addEditPartListener(viewerListener);
            }
          }
        });

    getPalette().activateTool(tool, group);
    click(x, y);

    return getAddedEditPart(viewerListener, oldCount);
  }
示例#11
0
  @Before
  public void setUp() {
    org.jboss.reddeer.core.util.Display.syncExec(
        new Runnable() {
          @Override
          public void run() {
            JFaceResources.getColorRegistry()
                .put(JFacePreferences.COUNTER_COLOR, new RGB(0, 127, 174));

            Shell shell = new Shell(Display.getDefault(), SWT.CLOSE | SWT.RESIZE);
            shell.setText(title);
            shell.setSize(400, 400);
            shell.setLayout(new GridLayout(2, false));

            Composite composite = createPartControl(shell);
            composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));

            shell.open();
          }
        });
  }
示例#12
0
  /**
   * Sets selection of specified {@link CCombo} to specified text.
   *
   * @param ccombo custom combo to handle
   * @param text text to set
   */
  public void setSelection(final CCombo ccombo, final String text) {
    Display.syncExec(
        new Runnable() {

          @Override
          public void run() {
            String[] items = getItems(ccombo);
            int index = Arrays.asList(items).indexOf(text);
            if (index == -1) {
              log.error("'" + text + "' is not contained in custom combo items");
              log.info("Items present in custom combo:");
              int i = 0;
              for (String item : items) {
                log.info("    " + item + "(index " + i);
                i++;
              }
              throw new CoreLayerException("Nonexisting item in custom combo was requested");
            } else {
              ccombo.select(index);
            }
          }
        });
  }
  /**
   * Closes Report Usage Windows and enable Atlassian Connector Usage Reporting Window. Did not find
   * other way how to disable Atlassian Connector Usage Reporting Window displaying
   *
   * @param reportJbtUsage
   * @param reportSubclipseUsage
   */
  public static void manageBlockingWidows(boolean reportJbtUsage, boolean reportSubclipseUsage) {
    // Manage JBT/JBDS and Subclipse Usage Reporting
    SWTWorkbenchBot bot = new SWTWorkbenchBot();
    SWTBotShell shJbtUsage = null;
    SWTBotShell shSubclipseUsage = null;
    bot.sleep(Timing.time5S());
    new SWTUtilExt(bot).waitForNonIgnoredJobs();
    SWTBotShell[] shells = bot.shells();
    int index = 0;
    while ((shJbtUsage == null || shSubclipseUsage == null) && index < shells.length) {
      if (shells[index].getText().equals(IDELabel.Shell.JBOSS_DEVELOPER_STUDIO_USAGE)
          || shells[index].getText().equals(IDELabel.Shell.JBOSS_TOOLS_USAGE)) {
        shJbtUsage = shells[index];
      } else if (shells[index].getText().equals(IDELabel.Shell.SUBCLIPSE_USAGE)) {
        shSubclipseUsage = shells[index];
      }
      index++;
    }
    if (shJbtUsage != null && shJbtUsage.isActive()) {
      closeJBossToolsUsageWindow(shJbtUsage, reportJbtUsage);
      if (shSubclipseUsage != null) {
        closeSubclipseUsageWindow(shSubclipseUsage, reportSubclipseUsage);
      }
    } else if (shSubclipseUsage != null && shSubclipseUsage.isActive()) {
      closeSubclipseUsageWindow(shSubclipseUsage, reportSubclipseUsage);
      if (shJbtUsage != null) {
        closeJBossToolsUsageWindow(shJbtUsage, reportJbtUsage);
      }
    }
    // Manage Atlassian Connector Usage Reporting
    try {
      SWTBot prefBot =
          new SWTOpenExt(new SWTBotExt())
              .preferenceOpen(ActionItem.Preference.AtlassianConnectorUsageData.LABEL);
      SWTBotCheckBox chbEnableMonitoring = prefBot.checkBox();
      if (!chbEnableMonitoring.isChecked()) {
        chbEnableMonitoring.click();
      }
      prefBot.button(IDELabel.Button.OK).click();
    } catch (WidgetNotFoundException wnfe) {
      // do nothing there is no Atlassian Connector installed
    }

    // Get rid of welcome screen. Simple close did not work when run in maven
    log.debug("Trying to close Welcome Screen");
    for (IViewReference viewReference : WorkbenchPartLookup.getInstance().findAllViewReferences()) {
      if (viewReference.getPartName().equals("Welcome")) {
        final IViewReference iViewReference = viewReference;
        Display.syncExec(
            new Runnable() {
              @Override
              public void run() {
                iViewReference.getPage().hideView(iViewReference);
              }
            });
        log.debug("Welcome Screen closed");
        break;
      }
      // ok, Welcome screen not present
      log.info("Welcome window not present");
    }
  }