Search in sources :

Example 6 with API

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");
}
Also used : UndoManager(javax.swing.undo.UndoManager) ActionEvent(java.awt.event.ActionEvent) KeyStroke(javax.swing.KeyStroke) AbstractAction(javax.swing.AbstractAction) API(org.apiguardian.api.API)

Example 7 with API

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);
}
Also used : CommandLineOptionsParser(org.junit.platform.console.options.CommandLineOptionsParser) PicocliCommandLineOptionsParser(org.junit.platform.console.options.PicocliCommandLineOptionsParser) PicocliCommandLineOptionsParser(org.junit.platform.console.options.PicocliCommandLineOptionsParser) API(org.apiguardian.api.API)

Example 8 with API

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);
}
Also used : UniqueId(org.junit.platform.engine.UniqueId) Type(org.junit.platform.engine.TestDescriptor.Type) TestSource(org.junit.platform.engine.TestSource) TestTag(org.junit.platform.engine.TestTag) API(org.apiguardian.api.API)

Example 9 with API

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;
}
Also used : MAINTAINED(org.apiguardian.api.API.Status.MAINTAINED) Preconditions(org.junit.platform.commons.util.Preconditions) Collections.emptySet(java.util.Collections.emptySet) ConfigurationParameters(org.junit.platform.engine.ConfigurationParameters) Visitor(org.junit.platform.engine.TestDescriptor.Visitor) Predicate(java.util.function.Predicate) Collection(java.util.Collection) JUnitException(org.junit.platform.commons.JUnitException) STABLE(org.apiguardian.api.API.Status.STABLE) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) API(org.apiguardian.api.API) UniqueId(org.junit.platform.engine.UniqueId) Collections.synchronizedSet(java.util.Collections.synchronizedSet) INTERNAL(org.apiguardian.api.API.Status.INTERNAL) Collections.unmodifiableSet(java.util.Collections.unmodifiableSet) DEPRECATED(org.apiguardian.api.API.Status.DEPRECATED) PreconditionViolationException(org.junit.platform.commons.PreconditionViolationException) Map(java.util.Map) Optional(java.util.Optional) TestDescriptor(org.junit.platform.engine.TestDescriptor) LinkedHashSet(java.util.LinkedHashSet) Visitor(org.junit.platform.engine.TestDescriptor.Visitor) API(org.apiguardian.api.API)

Example 10 with API

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;
}
Also used : Preconditions(org.junit.platform.commons.util.Preconditions) Collections.emptySet(java.util.Collections.emptySet) Visitor(org.junit.platform.engine.TestDescriptor.Visitor) Predicate(java.util.function.Predicate) Collection(java.util.Collection) STABLE(org.apiguardian.api.API.Status.STABLE) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) API(org.apiguardian.api.API) INTERNAL(org.apiguardian.api.API.Status.INTERNAL) PreconditionViolationException(org.junit.platform.commons.util.PreconditionViolationException) Collections.unmodifiableSet(java.util.Collections.unmodifiableSet) Map(java.util.Map) Optional(java.util.Optional) TestDescriptor(org.junit.platform.engine.TestDescriptor) Collections(java.util.Collections) LinkedHashSet(java.util.LinkedHashSet) Visitor(org.junit.platform.engine.TestDescriptor.Visitor) API(org.apiguardian.api.API)

Aggregations

API (org.apiguardian.api.API)17 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 Collections (java.util.Collections)3 LinkedHashSet (java.util.LinkedHashSet)3 UniqueId (org.junit.platform.engine.UniqueId)3 Component (java.awt.Component)2 Window (java.awt.Window)2 PropertyChangeListener (java.beans.PropertyChangeListener)2 Collection (java.util.Collection)2 Collections.emptySet (java.util.Collections.emptySet)2 Collections.unmodifiableSet (java.util.Collections.unmodifiableSet)2 List (java.util.List)2 Optional (java.util.Optional)2 Set (java.util.Set)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Predicate (java.util.function.Predicate)2 JComponent (javax.swing.JComponent)2 UIManager (javax.swing.UIManager)2 UnsupportedLookAndFeelException (javax.swing.UnsupportedLookAndFeelException)2