Java Code Examples for org.fest.swing.edt.GuiQuery

The following examples show how to use org.fest.swing.edt.GuiQuery. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: ats-framework   Source File: SwingTable.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Gets table cell backgrounds (as {@link Color}) of all table cells.
 *
 * @return array of java.awt.Color objects one for each cell. First index is
 * table row and second is the column in this row.
 */
@PublicAtsApi
public Color[][] getCellBackgroundColors() {

    new SwingElementState(this).waitToBecomeExisting();

    final JTableFixture tableFixture = (JTableFixture) SwingElementLocator.findFixture(this);
    int rowCount = tableFixture.rowCount();
    // SwingUtilities.
    int columnCount = GuiActionRunner.execute(new GuiQuery<Integer>() {

        @Override
        protected Integer executeInEDT() throws Throwable {

            return tableFixture.component().getColumnCount();
        }

    });
    Color[][] resultArr = new Color[rowCount][columnCount];
    for (int i = 0; i < rowCount; i++) {
        for (int j = 0; j < columnCount; j++) {
            resultArr[i][j] = tableFixture.backgroundAt(new TableCell(i, j) {}).target();
        }
    }
    return resultArr;
}
 
Example 2
public void selectApp(@NotNull String appName) {
  ActionButtonFixture runButton = findRunApplicationButton();
  Container actionToolbarContainer = GuiQuery.getNonNull(() -> runButton.target().getParent());
  String appModuleName = TestModuleUtil.findModule(getProject(), appName).getName();

  ComboBoxActionFixture comboBoxActionFixture = ComboBoxActionFixture.findComboBoxByClientPropertyAndText(
    robot(),
    actionToolbarContainer,
    "styleCombo",
    RunConfigurationsComboBoxAction.class,
    appModuleName);

  comboBoxActionFixture.selectItem(appModuleName);
  robot().pressAndReleaseKey(KeyEvent.VK_ENTER);
  Wait.seconds(1).expecting("ComboBox to be selected").until(() -> appModuleName.equals(comboBoxActionFixture.getSelectedItemText()));
}
 
Example 3
Source Project: nosql4idea   Source File: MongoEditionPanelTest.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {

    mongoEditionPanel = GuiActionRunner.execute(new GuiQuery<MongoEditionPanel>() {
        protected MongoEditionPanel executeInEDT() {
            MongoEditionPanel panel = new MongoEditionPanel() {
                @Override
                void buildPopupMenu() {
                }
            };
            return panel.init(mockMongoOperations, mockActionCallback);
        }
    });

    mongoEditionPanel.updateEditionTree(buildDocument("simpleDocument.json"));

    frameFixture = Containers.showInFrame(mongoEditionPanel);
}
 
Example 4
Source Project: nosql4idea   Source File: MongoResultPanelTest.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(MongoResultPanelTest.class);

    mongoResultPanel = GuiActionRunner.execute(new GuiQuery<MongoResultPanel>() {
        protected MongoResultPanel executeInEDT() {
            return new MongoResultPanel(DummyProject.getInstance(), mongoDocumentOperations) {
                @Override
                void buildPopupMenu() {
                }
            };
        }
    });

    frameFixture = Containers.showInFrame(mongoResultPanel);
}
 
Example 5
Source Project: nosql4idea   Source File: CouchbasePanelTest.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    when(couchbaseClientMock.loadRecords(any(ServerConfiguration.class), any(CouchbaseDatabase.class), any(CouchbaseQuery.class))).thenReturn(new CouchbaseResult("dummy"));


    couchbasePanelWrapper = GuiActionRunner.execute(new GuiQuery<CouchbasePanel>() {
        protected CouchbasePanel executeInEDT() {
            return new CouchbasePanel(DummyProject.getInstance(),
                    couchbaseClientMock,
                    new ServerConfiguration(),
                    new CouchbaseDatabase("default")) {
                @Override
                protected void addCommonsActions() {
                }
            };
        }
    });

    frameFixture = Containers.showInFrame(couchbasePanelWrapper);
}
 
Example 6
Source Project: intellij-xquery   Source File: BaseGuiTest.java    License: Apache License 2.0 6 votes vote down vote up
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    final PanelTestingFrame frame = GuiActionRunner.execute(new GuiQuery<PanelTestingFrame>() {
        protected PanelTestingFrame executeInEDT() {
            return getPanelTestingFrame();
        }
    });
    GuiActionRunner.execute(new GuiTask() {
        protected void executeInEDT() {
            disableTooltipAndBlinkRadeForChildrenToSatisfyIdeasUsefulTestCase(frame);
        }
    });
    window = new FrameFixture(frame);
    window.show();
}
 
Example 7
@Test
public void shouldDisableSetAsDefaultButton() {
    window.cleanUp();
    PanelTestingFrame frame = GuiActionRunner.execute(new GuiQuery<PanelTestingFrame>() {
        protected PanelTestingFrame executeInEDT() {
            cfg.DEFAULT = true;
            panel = new NameAndDefaultButtonPanel();
            return new PanelTestingFrame(panel.getPanel());
        }
    });
    FrameFixture anotherWindow = new FrameFixture(frame);

    anotherWindow.show();
    panel.init(cfg, aggregatingPanel, listener);

    anotherWindow.button(SET_AS_DEFAULT_BUTTON_NAME).requireDisabled();
    anotherWindow.cleanUp();
}
 
Example 8
Source Project: ats-framework   Source File: SwingElementFinder.java    License: Apache License 2.0 5 votes vote down vote up
private static boolean isMatching(
                                   final Component c,
                                   final ComponentMatcher m ) {

    return execute(new GuiQuery<Boolean>() {
        protected Boolean executeInEDT() {

            return m.matches(c);
        }
    });
}
 
Example 9
Source Project: ats-framework   Source File: SwingElementFinder.java    License: Apache License 2.0 5 votes vote down vote up
private static Collection<? extends Component> rootsOf(
                                                        final ComponentHierarchy h ) {

    return execute(new GuiQuery<Collection<? extends Component>>() {
        protected Collection<? extends Component> executeInEDT() {

            return h.roots();
        }
    });
}
 
Example 10
Source Project: ats-framework   Source File: SwingElementFinder.java    License: Apache License 2.0 5 votes vote down vote up
private static Collection<Component> childrenOfComponent(
                                                          final Component c,
                                                          final ComponentHierarchy h ) {

    return execute(new GuiQuery<Collection<Component>>() {
        protected Collection<Component> executeInEDT() {

            return h.childrenOf(c);
        }
    });
}
 
Example 11
/**
 * ActionButtons while being recreated by IJ and queried through the Action system
 * may not have a proper parent. Therefore, we can not rely on FEST's system of
 * checking the component tree, as that will cause the test to immediately fail.
 */
private static boolean hasValidWindowAncestor(@NotNull Component target) {
  return execute(new GuiQuery<Boolean>() {
    @Nullable
    @Override
    protected Boolean executeInEDT() {
      return WindowAncestorFinder.windowAncestorOf(target) != null;
    }
  });
}
 
Example 12
/**
 * Finds the button while refreshing over the toolbar.
 * <p>
 * Due to IJ refresh policy (will only refresh if it detects mouse movement over its window),
 * the toolbar needs to be intermittently updated before the ActionButton moves to the target
 * location and update to its final state.
 */
@NotNull
private ActionButtonFixture findActionButtonWithRefresh(@NotNull String actionId, boolean enabled) {
  Ref<ActionButtonFixture> fixtureRef = new Ref<>();
  Wait.seconds(30)
    .expecting("button to enable")
    .until(() -> {
      updateToolbars();
      // Actions can somehow get replaced, so we need to re-get the action when we attempt to check its state.
      ActionButtonFixture fixture = locateActionButtonByActionId(actionId);
      fixtureRef.set(fixture);
      if (hasValidWindowAncestor(fixture.target())) {
        return execute(new GuiQuery<Boolean>() {
          @Nullable
          @Override
          protected Boolean executeInEDT() {
            if (WindowAncestorFinder.windowAncestorOf(fixture.target()) != null) {
              ActionButton button = fixture.target();
              AnAction action = button.getAction();
              Presentation presentation = action.getTemplatePresentation();
              return presentation.isEnabledAndVisible() &&
                     button.isEnabled() == enabled &&
                     button.isShowing() &&
                     button.isVisible();
            }
            return false;
          }
        });
      }

      return false;
    });
  return fixtureRef.get();
}
 
Example 13
@NotNull
public File getLocationInFileSystem() {
  final TextFieldWithBrowseButton locationField = getLocationField();
  return execute(new GuiQuery<File>() {
    @Override
    protected File executeInEDT() {
      String location = locationField.getText();
      assertThat(location).isNotEmpty();
      return new File(location);
    }
  });
}
 
Example 14
Source Project: nosql4idea   Source File: ServerConfigurationPanelTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    databaseClientMock = Mockito.mock(DatabaseClient.class);
    configurationPanel = GuiActionRunner.execute(new GuiQuery<ServerConfigurationPanel>() {
        protected ServerConfigurationPanel executeInEDT() {
            return new ServerConfigurationPanel(DummyProject.getInstance(),
                    DatabaseVendor.MONGO,
                    databaseClientMock,
                    new MongoAuthenticationPanel()
            );
        }
    });

    frameFixture = Containers.showInFrame(configurationPanel);
}
 
Example 15
Source Project: nosql4idea   Source File: ServerConfigurationPanelTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    databaseClientMock = Mockito.mock(DatabaseClient.class);
    configurationPanel = GuiActionRunner.execute(new GuiQuery<ServerConfigurationPanel>() {
        protected ServerConfigurationPanel executeInEDT() {
            return new ServerConfigurationPanel(DummyProject.getInstance(),
                    DatabaseVendor.REDIS,
                    databaseClientMock,
                    new RedisAuthenticationPanel()
            );
        }
    });

    frameFixture = Containers.showInFrame(configurationPanel);
}
 
Example 16
Source Project: nosql4idea   Source File: RedisPanelTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    when(redisClientMock.loadRecords(any(ServerConfiguration.class), any(RedisDatabase.class), any(RedisQuery.class))).thenReturn(new RedisResult());

    redisPanelWrapper = GuiActionRunner.execute(new GuiQuery<RedisPanel>() {
        protected RedisPanel executeInEDT() {
            return new RedisPanel(dummyProject, redisClientMock, new ServerConfiguration(), new RedisDatabase("0")) {
                @Override
                protected void addCommonsActions() { }
            };
        }
    });

    frameFixture = Containers.showInFrame(redisPanelWrapper);
}
 
Example 17
Source Project: nosql4idea   Source File: ServerConfigurationPanelTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    databaseClientMock = Mockito.mock(DatabaseClient.class);
    configurationPanel = GuiActionRunner.execute(new GuiQuery<ServerConfigurationPanel>() {
        protected ServerConfigurationPanel executeInEDT() {
            return new ServerConfigurationPanel(DummyProject.getInstance(),
                    DatabaseVendor.COUCHBASE,
                    databaseClientMock,
                    new CouchbaseAuthenticationPanel()
            );
        }
    });

    frameFixture = Containers.showInFrame(configurationPanel);
}
 
Example 18
private XQueryFile createFile() {
    return GuiActionRunner.execute(new GuiQuery<XQueryFile>() {
        protected XQueryFile executeInEDT() {
            return XQueryElementFactory.createPhysicalFile(getProject(), "()");
        }
    });
}