use of org.apiguardian.api.API in project jmeter by apache.
the class TextComponentUI method installUndo.
/**
* Installs an undo manager and keyboard shortcuts to a text component
* @param component JTextField or JTextArea
*/
@API(since = "5.3", status = API.Status.INTERNAL)
public void installUndo(JTextComponent component) {
// JMeter reuses Swing JComponents, so when user switches to another component,
// JComponent#name is updated. However, we don't want user to be able to "undo" that
// So when tree selection is changed, we increase undoEpoch. That enables
// UndoManagers to treat that as "end of undo history"
UndoManager manager = new DefaultUndoManager(undoEpoch);
manager.setLimit(200);
component.addPropertyChangeListener("document", new AddUndoableEditListenerPropertyChangeListener(manager));
component.getActionMap().put("undo", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
if (manager.canUndo()) {
manager.undo();
}
}
});
component.getActionMap().put("redo", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
if (manager.canRedo()) {
manager.redo();
}
}
});
KeyStroke commandZ = KeyStroke.getKeyStroke(KeyEvent.VK_Z, COMMAND_KEY);
component.getInputMap().put(commandZ, "undo");
KeyStroke shiftCommandZ = KeyStroke.getKeyStroke(KeyEvent.VK_Z, COMMAND_KEY | InputEvent.SHIFT_DOWN_MASK);
component.getInputMap().put(shiftCommandZ, "redo");
}
use of org.apiguardian.api.API in project junit5 by junit-team.
the class ConsoleLauncher method execute.
@API(status = INTERNAL, since = "1.0")
public static ConsoleLauncherExecutionResult execute(PrintWriter out, PrintWriter err, String... args) {
CommandLineOptionsParser parser = new PicocliCommandLineOptionsParser();
ConsoleLauncher consoleLauncher = new ConsoleLauncher(parser, out, err);
return consoleLauncher.execute(args);
}
use of org.apiguardian.api.API in project junit5 by junit-team.
the class TestIdentifier method from.
/**
* Factory for creating a new {@link TestIdentifier} from a {@link TestDescriptor}.
*/
@API(status = INTERNAL, since = "1.0")
public static TestIdentifier from(TestDescriptor testDescriptor) {
Preconditions.notNull(testDescriptor, "TestDescriptor must not be null");
UniqueId uniqueId = testDescriptor.getUniqueId();
String displayName = testDescriptor.getDisplayName();
TestSource source = testDescriptor.getSource().orElse(null);
Set<TestTag> tags = testDescriptor.getTags();
Type type = testDescriptor.getType();
UniqueId parentId = testDescriptor.getParent().map(TestDescriptor::getUniqueId).orElse(null);
String legacyReportingName = testDescriptor.getLegacyReportingName();
return new TestIdentifier(uniqueId, displayName, source, tags, type, parentId, legacyReportingName);
}
use of org.apiguardian.api.API in project junit5 by junit-team.
the class TestPlan method from.
/**
* Construct a new {@code TestPlan} from the supplied collection of
* {@link TestDescriptor TestDescriptors}.
*
* <p>Each supplied {@code TestDescriptor} is expected to be a descriptor
* for a {@link org.junit.platform.engine.TestEngine TestEngine}.
*
* @param engineDescriptors the engine test descriptors from which the test
* plan should be created; never {@code null}
* @param configurationParameters the {@code ConfigurationParameters} for
* this test plan; never {@code null}
* @return a new test plan
*/
@API(status = INTERNAL, since = "1.0")
public static TestPlan from(Collection<TestDescriptor> engineDescriptors, ConfigurationParameters configurationParameters) {
Preconditions.notNull(engineDescriptors, "Cannot create TestPlan from a null collection of TestDescriptors");
Preconditions.notNull(configurationParameters, "Cannot create TestPlan from null ConfigurationParameters");
TestPlan testPlan = new TestPlan(engineDescriptors.stream().anyMatch(TestDescriptor::containsTests), configurationParameters);
Visitor visitor = descriptor -> testPlan.addInternal(TestIdentifier.from(descriptor));
engineDescriptors.forEach(engineDescriptor -> engineDescriptor.accept(visitor));
return testPlan;
}
use of org.apiguardian.api.API in project junit5 by junit-team.
the class TestPlan method from.
/**
* Construct a new {@code TestPlan} from the supplied collection of
* {@link TestDescriptor TestDescriptors}.
*
* <p>Each supplied {@code TestDescriptor} is expected to be a descriptor
* for a {@link org.junit.platform.engine.TestEngine TestEngine}.
*
* @param engineDescriptors the engine test descriptors from which the test
* plan should be created; never {@code null}
* @return a new test plan
*/
@API(status = INTERNAL, since = "1.0")
public static TestPlan from(Collection<TestDescriptor> engineDescriptors) {
Preconditions.notNull(engineDescriptors, "Cannot create TestPlan from a null collection of TestDescriptors");
TestPlan testPlan = new TestPlan(engineDescriptors.stream().anyMatch(TestDescriptor::containsTests));
Visitor visitor = descriptor -> testPlan.add(TestIdentifier.from(descriptor));
engineDescriptors.forEach(engineDescriptor -> engineDescriptor.accept(visitor));
return testPlan;
}
Aggregations