Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add toggle button in Demo #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package org.concordion.ext.demo.selenium;

import org.concordion.api.extension.Extensions;
import org.concordion.api.extension.Extension;
import org.concordion.ext.LoggingTooltipExtension;
import org.concordion.ext.demo.selenium.web.GoogleResultsPage;
import org.concordion.ext.tooltip.TooltipButton;
import org.concordion.integration.junit4.ConcordionRunner;
import org.junit.runner.RunWith;

Expand All @@ -18,13 +19,18 @@
* Run this class as a JUnit test to produce the Concordion results.
*/
@RunWith(ConcordionRunner.class)
@Extensions(LoggingTooltipExtension.class)
public class LoggingTooltipDemo extends GoogleFixture {

GoogleResultsPage resultsPage;
TooltipButton toggleButton;

@Extension
public LoggingTooltipExtension extension = new LoggingTooltipExtension();

public LoggingTooltipDemo() {
super(true);
toggleButton = new ToggleTooltipButton();
extension.setTooltipButton(toggleButton);
}

/**
Expand All @@ -40,4 +46,16 @@ public void searchFor(String topic) {
public String getCalculatorResult() {
return resultsPage.getCalculatorResult();
}

/**
* Hides tooltips if parameter is not empty
*/
public void hideTooltip(String tooltipHidden) {
boolean displayTooltip = true;
if(tooltipHidden != null) {
// Tooltip is hidden only if param is set and not empty
displayTooltip = tooltipHidden.isEmpty();
}
extension.toggleTooltip(displayTooltip);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.concordion.ext.demo.selenium;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;

import org.concordion.ext.tooltip.TooltipButton;

public class ToggleTooltipButton implements TooltipButton {

private List<ActionListener> actionListeners;

public ToggleTooltipButton() {
actionListeners = new ArrayList<ActionListener>();
}

@Override
public void addActionListener(ActionListener l) {
actionListeners.add(l);

}

@Override
public void removeActionListener(ActionListener l) {
actionListeners.remove(l);
}

@Override
public ActionListener[] getActionListeners() {
ActionListener[] listenersArray = new ActionListener[actionListeners.size()];
return actionListeners.toArray(listenersArray);
}

public void processActionEvent(ActionEvent e) {
for(ActionListener a : actionListeners) {
a.actionPerformed(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@ <h1>Google Calculator</h1>

<p>Google acts as a calculator if you enter a sum.</p>

<!-- Optional: it is possible to hide tooltips by setting #tooltipHidden variable -->
<div style="display: none;">
<span c:set="#tooltipHidden"></span>
</div>

<div class="example">
<h4>Example</h4>
<p>Googling "<span c:execute="searchFor(#TEXT)">11 * 12</span>" displays "<span c:assertEquals="getCalculatorResult()">132</span>".</p>
<p style="font-style: italic;">(Hover over the i icons to see the logging.)</p>
<br />
<input type="button" c:execute="hideTooltip(#tooltipHidden)" onclick="toggleTooltip();" value="Toggle tooltip" />
</div>

</body>
Expand Down