Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 4e5e95d7f7b0b86e689e78aed020e21cc7439e71 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*******************************************************************************
 * Copyright (c) 2008-2010 Sonatype, Inc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *      Sonatype, Inc. - initial API and implementation
 *******************************************************************************/

package org.eclipse.m2e.integration.tests.common;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swtbot.swt.finder.ReferenceBy;
import org.eclipse.swtbot.swt.finder.SWTBotWidget;
import org.eclipse.swtbot.swt.finder.Style;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.utils.MessageFormat;
import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBotControl;
import org.eclipse.ui.forms.widgets.Hyperlink;
import org.hamcrest.SelfDescribing;

@SWTBotWidget( clasz = Hyperlink.class, style = @Style( name = "SWT.NONE", value = SWT.NONE ), preferredName = "hyperlink", referenceBy = { ReferenceBy.LABEL, ReferenceBy.MNEMONIC } )//$NON-NLS-1$
public class HyperlinkBot
    extends AbstractSWTBotControl<Hyperlink>
{

    public HyperlinkBot( Hyperlink h )
        throws WidgetNotFoundException
    {
        this( h, null );
    }

    public HyperlinkBot( Hyperlink h, SelfDescribing selfDescribing )
    {
        super( h, selfDescribing );
    }

    public HyperlinkBot click()
    {
        log.debug( MessageFormat.format( "Clicking on {0}", SWTUtils.getText( widget ) ) ); //$NON-NLS-1$
        waitForEnabled();
        Event e = createEvent();
        e.character = SWT.CR;
        notify( SWT.KeyDown, e );
        log.debug( MessageFormat.format( "Clicked on {0}", SWTUtils.getText( widget ) ) ); //$NON-NLS-1$
        return this;
    }
}

Back to the top