-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add possibility to set 'destructive' action style. Change-Id: I181d889a042196e507e145c48f5aabf2304daa0c
- Loading branch information
1 parent
09a4ac4
commit 04517f9
Showing
6 changed files
with
130 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...e.tabris.test/src/com/eclipsesource/tabris/widgets/enhancement/MenuItemDecoratorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2018 EclipseSource and others. | ||
* 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: | ||
* EclipseSource - initial API and implementation | ||
******************************************************************************/ | ||
package com.eclipsesource.tabris.widgets.enhancement; | ||
|
||
import static com.eclipsesource.tabris.internal.DataWhitelist.WhiteListEntry.ACTION_STYLE; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.verify; | ||
|
||
import org.eclipse.swt.widgets.MenuItem; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.runners.MockitoJUnitRunner; | ||
|
||
import com.eclipsesource.tabris.test.util.TabrisEnvironment; | ||
|
||
@RunWith( MockitoJUnitRunner.class ) | ||
public class MenuItemDecoratorTest { | ||
|
||
@Rule | ||
public TabrisEnvironment environment = new TabrisEnvironment(); | ||
private MenuItemDecorator decorator; | ||
private MenuItem menuItem; | ||
|
||
@Before | ||
public void setUp() { | ||
menuItem = mock( MenuItem.class ); | ||
decorator = new MenuItemDecorator( menuItem ); | ||
} | ||
|
||
@Test | ||
public void testDestructiveStyle() { | ||
decorator.useDestructiveStyle(); | ||
|
||
verify( menuItem ).setData( ACTION_STYLE.getKey(), "destructive" ); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...ipsesource.tabris/src/com/eclipsesource/tabris/widgets/enhancement/MenuItemDecorator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2018 EclipseSource and others. | ||
* 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: | ||
* EclipseSource - initial API and implementation | ||
******************************************************************************/ | ||
package com.eclipsesource.tabris.widgets.enhancement; | ||
|
||
import static com.eclipsesource.tabris.internal.DataWhitelist.WhiteListEntry.ACTION_STYLE; | ||
|
||
import org.eclipse.swt.widgets.MenuItem; | ||
|
||
import com.eclipsesource.tabris.internal.WidgetsUtil; | ||
|
||
/** | ||
* @since 3.5 | ||
*/ | ||
public class MenuItemDecorator { | ||
|
||
private final MenuItem item; | ||
|
||
MenuItemDecorator( MenuItem item ) { | ||
this.item = item; | ||
} | ||
|
||
/** | ||
* Enables the 'destructive' action style for this menu item (iOs only). | ||
* A destructive action is shown in red. | ||
* | ||
* @since 3.5 | ||
*/ | ||
public MenuItemDecorator useDestructiveStyle() { | ||
WidgetsUtil.setData( item, ACTION_STYLE, "destructive" ); | ||
return this; | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters