Skip to content

Commit

Permalink
UserNotification: use event's suggestedWindowId if any
Browse files Browse the repository at this point in the history
  • Loading branch information
teosarca committed May 29, 2017
1 parent 2c81bb2 commit 02f1352
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions src/main/java/de/metas/ui/web/notification/UserNotification.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-2.0.html>.
* #L%
*/
Expand Down Expand Up @@ -68,20 +68,20 @@ public class UserNotification
public static enum TargetType
{
None("none"), Window("window");

final private String jsonValue;

TargetType(final String jsonValue)
{
this.jsonValue = jsonValue;
}

@JsonValue
public String getJsonValue()
{
return jsonValue;
}

public static TargetType forJsonValue(final String jsonValue)
{
return Stream.of(values())
Expand Down Expand Up @@ -118,10 +118,22 @@ private UserNotification(final Event event)
if (targetRecord != null)
{
targetType = TargetType.Window;
final RecordZoomWindowFinder recordWindowFinder = RecordZoomWindowFinder.newInstance(targetRecord);
target_adWindowId = recordWindowFinder.findAD_Window_ID();
target_tableName = recordWindowFinder.getTableName();
target_recordId = recordWindowFinder.getRecord_ID();

final Object suggestedWindowIdObj = event.getProperty(Event.PROPERTY_SuggestedWindowId);
final int suggestedWindowId = (suggestedWindowIdObj instanceof Number) ? ((Number)suggestedWindowIdObj).intValue() : -1;
if (suggestedWindowId > 0)
{
target_adWindowId = suggestedWindowId;
target_tableName = targetRecord.getTableName();
target_recordId = targetRecord.getRecord_ID();
}
else
{
final RecordZoomWindowFinder recordWindowFinder = RecordZoomWindowFinder.newInstance(targetRecord);
target_adWindowId = recordWindowFinder.findAD_Window_ID();
target_tableName = recordWindowFinder.getTableName();
target_recordId = recordWindowFinder.getRecord_ID();
}
}
//
// Target: none
Expand Down

0 comments on commit 02f1352

Please sign in to comment.