name
stringlengths 12
178
| code_snippet
stringlengths 8
36.5k
| score
float64 3.26
3.68
|
---|---|---|
AreaShop_BuyRegion_getFormattedPrice_rdh
|
/**
* Get the formatted string of the price (includes prefix and suffix).
*
* @return The formatted string of the price
*/public String getFormattedPrice() {
return Utils.formatCurrency(getPrice());
}
| 3.26 |
AreaShop_BuyRegion_setPrice_rdh
|
/**
* Change the price of the region.
*
* @param price
* The price to set this region to
*/
public void setPrice(Double price) {
setSetting("buy.price", price);
}
| 3.26 |
AreaShop_BuyRegion_getResellPrice_rdh
|
/**
* Get the resell price of this region.
*
* @return The resell price if isInResellingMode(), otherwise 0.0
*/
public double getResellPrice() {
return Math.max(0, config.getDouble("buy.resellPrice"));
}
| 3.26 |
AreaShop_BuyRegion_getFormattedInactiveTimeUntilSell_rdh
|
/**
* Get a human readable string indicating how long the player can be offline until automatic unrent.
*
* @return String indicating the inactive time until unrent
*/
public String getFormattedInactiveTimeUntilSell() {
return Utils.millisToHumanFormat(getInactiveTimeUntilSell());
}
| 3.26 |
AreaShop_BuyRegion_getMoneyBackPercentage_rdh
|
/**
* Get the moneyBack percentage.
*
* @return The % of money the player will get back when selling
*/
public double getMoneyBackPercentage() {
return Utils.evaluateToDouble(getStringSetting("buy.moneyBack"), this);
}
| 3.26 |
AreaShop_BuyRegion_isBuyer_rdh
|
/**
* Check if a player is the buyer of this region.
*
* @param player
* Player to check
* @return true if this player owns this region, otherwise false
*/
public boolean isBuyer(OfflinePlayer player) {
return (player != null) && isBuyer(player.getUniqueId());
}
| 3.26 |
AreaShop_BuyRegion_getInactiveTimeUntilSell_rdh
|
/**
* Minutes until automatic unrent when player is offline.
*
* @return The number of milliseconds until the region is unrented while player is offline
*/
public long getInactiveTimeUntilSell() {
return Utils.getDurationFromMinutesOrStringInput(getStringSetting("buy.inactiveTimeUntilSell"));
}
| 3.26 |
AreaShop_BuyRegion_getBuyer_rdh
|
/**
* Get the UUID of the owner of this region.
*
* @return The UUID of the owner of this region
*/
public UUID getBuyer() {
String buyer = config.getString("buy.buyer");
if (buyer != null) {
try {
return UUID.fromString(buyer);
} catch (IllegalArgumentException e) {
// Incorrect UUID
}
}
return null;
}
| 3.26 |
AreaShop_BuyRegion_getMoneyBackAmount_rdh
|
/**
* Get the amount of money that should be paid to the player when selling the region.
*
* @return The amount of money the player should get back
*/
public double getMoneyBackAmount() {
return getPrice() * (getMoneyBackPercentage() / 100.0);
}
| 3.26 |
AreaShop_BuyRegion_getPlayerName_rdh
|
/**
* Get the name of the player that owns this region.
*
* @return The name of the player that owns this region, if unavailable by UUID it will return the old cached name, if that is unavailable it will return <UNKNOWN>
*/
public String getPlayerName() {
String result = Utils.toName(getBuyer());
if ((result == null) || result.isEmpty()) {
result = getStringSetting("buy.buyerName");
if ((result == null) || result.isEmpty()) {
result = "<UNKNOWN>";
}
}
return result;
}
| 3.26 |
AreaShop_BuyRegion_disableReselling_rdh
|
/**
* Stop this region from being in resell mode.
*/
public void disableReselling() {
setSetting("buy.resellMode", null);
setSetting("buy.resellPrice", null);
}
| 3.26 |
AreaShop_BuyRegion_buy_rdh
|
/**
* Buy a region.
*
* @param offlinePlayer
* The player that wants to buy the region
* @return true if it succeeded and false if not
*/
@SuppressWarnings("deprecation")
public boolean buy(OfflinePlayer offlinePlayer) {
// Check if the player has permission
if (!plugin.hasPermission(offlinePlayer, "areashop.buy")) {
message(offlinePlayer, "buy-noPermission");return false;}
if (plugin.getEconomy() == null) {
message(offlinePlayer, "general-noEconomy");
return false;
}
if (isInResellingMode()) {
if (!plugin.hasPermission(offlinePlayer, "areashop.buyresell")) {
message(offlinePlayer, "buy-noPermissionResell");
return false;
}
} else if (!plugin.hasPermission(offlinePlayer, "areashop.buynormal")) {
message(offlinePlayer, "buy-noPermissionNoResell");return false;
}
if (getWorld() == null) {
message(offlinePlayer, "general-noWorld");
return false;
}
if (getRegion() == null) {
message(offlinePlayer, "general-noRegion");
return false;
}
if (isSold() && (!(isInResellingMode() && (!isBuyer(offlinePlayer))))) {
if (isBuyer(offlinePlayer)) {
message(offlinePlayer, "buy-yours");
} else {
message(offlinePlayer, "buy-someoneElse");
}
return false;
}
boolean isResell = isInResellingMode();
// Only relevant if the player is online
Player player = offlinePlayer.getPlayer();
if (player != null) {
// Check if the players needs to be in the region for buying
if (restrictedToRegion() && ((!player.getWorld().getName().equals(getWorldName())) || (!getRegion().contains(player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ())))) {
message(offlinePlayer, "buy-restrictedToRegion");
return false;
}
// Check if the players needs to be in the world for buying
if (restrictedToWorld() && (!player.getWorld().getName().equals(getWorldName()))) {
message(offlinePlayer, "buy-restrictedToWorld", player.getWorld().getName());
return
false;
}
}
// Check region limits
LimitResult limitResult = this.limitsAllow(RegionType.BUY, offlinePlayer);
AreaShop.debug("LimitResult: " + limitResult.toString());
if (!limitResult.actionAllowed()) {
if (limitResult.getLimitingFactor() == LimitType.TOTAL) {
message(offlinePlayer, "total-maximum", limitResult.getMaximum(), limitResult.getCurrent(),
limitResult.getLimitingGroup());
return false; }
if (limitResult.getLimitingFactor() == LimitType.BUYS) {
message(offlinePlayer, "buy-maximum", limitResult.getMaximum(), limitResult.getCurrent(), limitResult.getLimitingGroup());
return false;
} // Should not be reached, but is safe like this
return false;
}
// Check if the player has enough money
if (isResell && (!plugin.getEconomy().has(offlinePlayer, getWorldName(), getResellPrice()))) {
message(offlinePlayer, "buy-lowMoneyResell", Utils.formatCurrency(plugin.getEconomy().getBalance(offlinePlayer, getWorldName())));
return false;
}
if ((!isResell) && (!plugin.getEconomy().has(offlinePlayer,
getWorldName(), getPrice()))) {
message(offlinePlayer, "buy-lowMoney", Utils.formatCurrency(plugin.getEconomy().getBalance(offlinePlayer, getWorldName())));
return false;
}
UUID oldOwner = getBuyer();
if (isResell && (oldOwner != null)) {
// Broadcast and check event
ResellingRegionEvent event = new ResellingRegionEvent(this, offlinePlayer);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
message(offlinePlayer, "general-cancelled", event.getReason());
return false;
}
getFriendsFeature().clearFriends();
double resellPrice = getResellPrice();
// Transfer the money to the previous owner
EconomyResponse r = plugin.getEconomy().withdrawPlayer(offlinePlayer, getWorldName(), getResellPrice());
if (!r.transactionSuccess()) {
message(offlinePlayer, "buy-payError");
AreaShop.debug((((("Something went wrong with getting money from " + offlinePlayer.getName()) + " while buying ") +
getName()) + ": ") + r.errorMessage);
return false;
}
r = null;
OfflinePlayer oldOwnerPlayer = Bukkit.getOfflinePlayer(oldOwner);
String oldOwnerName = getPlayerName();
if ((oldOwnerPlayer != null) &&
(oldOwnerPlayer.getName() != null)) {
r = plugin.getEconomy().depositPlayer(oldOwnerPlayer, getWorldName(), getResellPrice());
oldOwnerName = oldOwnerPlayer.getName();
} else if (oldOwnerName != null) {r = plugin.getEconomy().depositPlayer(oldOwnerName, getWorldName(), getResellPrice());
}
if ((r == null) || (!r.transactionSuccess())) {
AreaShop.warn((((((("Something went wrong with paying '" + oldOwnerName) + "' ") +
getFormattedPrice()) + " for his resell of region ") + getName()) + " to ") + offlinePlayer.getName());
}
// Resell is done, disable that now
disableReselling();
// Set the owner
setBuyer(offlinePlayer.getUniqueId());
updateLastActiveTime();
// Update everything
handleSchematicEvent(RegionEvent.RESELL);
// Notify about updates
this.notifyAndUpdate(new ResoldRegionEvent(this, oldOwner));
// Send message to the player
message(offlinePlayer, "buy-successResale", oldOwnerName);
Player seller = Bukkit.getPlayer(oldOwner);
if (seller
!= null) {
message(seller, "buy-successSeller", resellPrice);}
} else {
// Broadcast and check event
BuyingRegionEvent event = new BuyingRegionEvent(this, offlinePlayer);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
message(offlinePlayer, "general-cancelled", event.getReason());
return false;
}
// Substract the money from the players balance
EconomyResponse r = plugin.getEconomy().withdrawPlayer(offlinePlayer, getWorldName(), getPrice());
if (!r.transactionSuccess()) {
message(offlinePlayer, "buy-payError");
return false;
}
// Optionally give money to the landlord
OfflinePlayer landlordPlayer = null;
if (getLandlord() != null) {
landlordPlayer = Bukkit.getOfflinePlayer(getLandlord());
}
String landlordName = getLandlordName();
if (landlordName != null) {
if ((landlordPlayer != null) && (landlordPlayer.getName() != null)) {
r = plugin.getEconomy().depositPlayer(landlordPlayer, getWorldName(), getPrice());
} else {
r = plugin.getEconomy().depositPlayer(landlordName, getWorldName(), getPrice());
}if ((r != null) && (!r.transactionSuccess())) {
AreaShop.warn((((((("Something went wrong with paying '" + landlordName) + "' ") + getFormattedPrice()) + " for his sell of region ") + getName()) + " to ") + offlinePlayer.getName());
}
}
// Set the owner
setBuyer(offlinePlayer.getUniqueId());
updateLastActiveTime();
// Send message to the player
message(offlinePlayer, "buy-succes");
// Update everything
handleSchematicEvent(RegionEvent.BOUGHT);
// Notify about updates
this.notifyAndUpdate(new BoughtRegionEvent(this));
}
return true;
}
| 3.26 |
AreaShop_BuyRegion_getPrice_rdh
|
/**
* Get the price of the region.
*
* @return The price of the region
*/
public double getPrice() {
return Math.max(0, Utils.evaluateToDouble(getStringSetting("buy.price"), this));
}
| 3.26 |
AreaShop_BuyRegion_isInResellingMode_rdh
|
/**
* Check if the region is being resold.
*
* @return true if the region is available for reselling, otherwise false
*/
public boolean isInResellingMode() {
return config.getBoolean("buy.resellMode");
}
| 3.26 |
AreaShop_BuyRegion_sell_rdh
|
/**
* Sell a buyed region, get part of the money back.
*
* @param giveMoneyBack
* true if the player should be given money back, otherwise false
* @param executor
* CommandSender to receive a message when the sell fails, or null
* @return true if the region has been sold, otherwise false
*/
@SuppressWarnings("deprecation")
public boolean sell(boolean giveMoneyBack, CommandSender executor) {
boolean own = (executor instanceof Player) && this.isBuyer(((Player) (executor)));
if (executor != null) {
if ((!executor.hasPermission("areashop.sell")) &&
(!own)) {
message(executor, "sell-noPermissionOther");
return false;
}
if (((!executor.hasPermission("areashop.sell")) && (!executor.hasPermission("areashop.sellown"))) && own) {
message(executor, "sell-noPermission");
return false;
}if ((((!executor.hasPermission("areashop.sell")) && executor.hasPermission("areashop.sellown")) && own) && getBooleanSetting("buy.sellDisabled")) {
message(executor,
"sell-disabled");
return false;
}
}
if (plugin.getEconomy()
==
null) {
return false;
}
// Broadcast and check event
SellingRegionEvent v18 = new SellingRegionEvent(this);
Bukkit.getPluginManager().callEvent(v18);
if (v18.isCancelled()) {
message(executor, "general-cancelled", v18.getReason());
return false;
}
disableReselling();
// Give part of the buying price back
double moneyBack = getMoneyBackAmount();
if ((moneyBack > 0) && giveMoneyBack) {
boolean noPayBack = false;
OfflinePlayer landlordPlayer = null;
if (getLandlord() != null) {
landlordPlayer = Bukkit.getOfflinePlayer(getLandlord());
}
String landlordName = getLandlordName();
EconomyResponse r;
if (landlordName != null) {
if ((landlordPlayer != null) && (landlordPlayer.getName() != null)) {
r = plugin.getEconomy().withdrawPlayer(landlordPlayer, getWorldName(), moneyBack);
} else {
r = plugin.getEconomy().withdrawPlayer(landlordName,
getWorldName(), moneyBack);
}
if
((r == null) || (!r.transactionSuccess())) {
noPayBack = true;
}
}
// Give back the money
OfflinePlayer
player = Bukkit.getOfflinePlayer(getBuyer());
if ((player != null) && (!noPayBack)) {EconomyResponse response = null;
boolean error
= false;
try {
if (player.getName() != null) {
response = plugin.getEconomy().depositPlayer(player, getWorldName(), moneyBack);
} else if (getPlayerName() != null) {
response = plugin.getEconomy().depositPlayer(getPlayerName(), getWorldName(), moneyBack);
}
} catch (Exception e) {
error = true;
}
if ((error || (response == null)) || (!response.transactionSuccess())) {
AreaShop.warn((("Something went wrong with paying back money to " + getPlayerName()) + " while selling region ") + getName());
}
}
}
// Handle schematic save/restore (while %uuid% is still available)
handleSchematicEvent(RegionEvent.SOLD);
// Send message: before actual removal of the buyer so that it is still available for variables
message(executor, "sell-sold");// Remove friends and the owner
getFriendsFeature().clearFriends();
UUID oldBuyer = getBuyer();
setBuyer(null);
removeLastActiveTime();
// Notify about updates
this.notifyAndUpdate(new SoldRegionEvent(this, oldBuyer, Math.max(moneyBack, 0)));
return true;
}
| 3.26 |
AreaShop_BuyRegion_getFormattedResellPrice_rdh
|
/**
* Get the formatted string of the resellprice (includes prefix and suffix).
*
* @return The formatted string of the resellprice
*/
public String getFormattedResellPrice() {
return Utils.formatCurrency(getResellPrice());
}
| 3.26 |
AreaShop_BuyRegion_isSold_rdh
|
/**
* Check if the region is sold.
*
* @return true if the region is sold, otherwise false
*/
public boolean isSold() {return getBuyer() != null;
}
| 3.26 |
AreaShop_BuyRegion_setBuyer_rdh
|
/**
* Set the buyer of this region.
*
* @param buyer
* The UUID of the player that should be set as buyer
*/
public void setBuyer(UUID buyer) {
if (buyer == null) {
setSetting("buy.buyer", null);
setSetting("buy.buyerName", null);
} else {
setSetting("buy.buyer", buyer.toString());
setSetting("buy.buyerName", Utils.toName(buyer));
}
}
| 3.26 |
AreaShop_BuyRegion_enableReselling_rdh
|
/**
* Set the region into resell mode with the given price.
*
* @param price
* The price this region should be put up for sale
*/
public void enableReselling(double price) {
setSetting("buy.resellMode", true);
setSetting("buy.resellPrice", price);
}
| 3.26 |
AreaShop_CommandsFeature_runEventCommands_rdh
|
/**
* Run command for a certain event.
*
* @param region
* Region to execute the events for
* @param event
* The event
* @param before
* The 'before' or 'after' commands
*/
public void runEventCommands(GeneralRegion region, GeneralRegion.RegionEvent event, boolean before) {
ConfigurationSection eventCommandProfileSection = region.getConfigurationSectionSetting("general.eventCommandProfile", "eventCommandProfiles");
if (eventCommandProfileSection == null) {
return;
}
List<String> commands =
eventCommandProfileSection.getStringList((event.getValue() + ".") + (before ? "before" : "after"));
if ((commands ==
null) || commands.isEmpty()) {
return;
}
region.runCommands(Bukkit.getConsoleSender(), commands);
}
| 3.26 |
AreaShop_WorldGuardHandler7_beta_2_buildDomain_rdh
|
/**
* Build a DefaultDomain from a RegionAccessSet.
*
* @param regionAccessSet
* RegionAccessSet to read
* @return DefaultDomain containing the entities from the RegionAccessSet
*/
private DefaultDomain buildDomain(RegionAccessSet regionAccessSet) {
DefaultDomain owners = new DefaultDomain();
for (String playerName : regionAccessSet.getPlayerNames()) {
owners.addPlayer(playerName);
}
for
(UUID uuid : regionAccessSet.getPlayerUniqueIds()) {
owners.addPlayer(uuid);
}
for (String group : regionAccessSet.getGroupNames()) {
owners.addGroup(group);
}
return owners;
}
| 3.26 |
AreaShop_WorldGuardRegionFlagsFeature_parseAccessSet_rdh
|
/**
* Build an RegionAccessSet from an input that specifies player names, player uuids and groups.
*
* @param input
* Input string defining the access set
* @return RegionAccessSet containing the entities parsed from the input
*/
public RegionAccessSet parseAccessSet(String input) {
RegionAccessSet result = new RegionAccessSet();
String[] inputParts = input.split(", ");
for (String access : inputParts) {
if ((access != null) && (!access.isEmpty())) {
// Check for groups
if (access.startsWith("g:")) {if (access.length() > 2) {
result.getGroupNames().add(access.substring(2));
}
} else if (access.startsWith("n:")) {
if (access.length() > 2) {
result.getPlayerNames().add(access.substring(2));
}
} else {
try {
result.getPlayerUniqueIds().add(UUID.fromString(access));
} catch (IllegalArgumentException e) {
AreaShop.warn(("Tried using '" + access) + "' as uuid for a region member/owner, is your flagProfiles section correct?");
}
}
}
}
return result;
}
| 3.26 |
AreaShop_WorldGuardRegionFlagsFeature_updateRegionFlags_rdh
|
/**
* Set the region flags/options to the values of a ConfigurationSection.
*
* @param region
* The region to update the flags for
* @param flags
* The flags to apply
* @return true if the flags have been set correctly, otherwise false
*/
private boolean updateRegionFlags(GeneralRegion region, ConfigurationSection flags)
{
boolean result = true;
Set<String> flagNames = flags.getKeys(false);
WorldGuardPlugin worldGuard = plugin.getWorldGuard();
// Get the region
ProtectedRegion worldguardRegion = region.getRegion();
if (worldguardRegion == null) {
AreaShop.debug(("Region '" + region.getName()) + "' does not exist, setting flags failed");
return false;
}
// Loop through all flags that are set in the config
for (String flagName : flagNames) {
String value = Message.fromString(flags.getString(flagName)).replacements(region).getPlain();
// In the config normal Bukkit color codes are used, those only need to be translated on 5.X WorldGuard versions
if (plugin.getWorldGuard().getDescription().getVersion().startsWith("5.")) {
value = translateBukkitToWorldGuardColors(value);
}
if (flagName.equalsIgnoreCase("members")) {
plugin.getWorldGuardHandler().setMembers(worldguardRegion, parseAccessSet(value));
// AreaShop.debug(" Flag " + flagName + " set: " + members.toUserFriendlyString());
} else if (flagName.equalsIgnoreCase("owners")) {
plugin.getWorldGuardHandler().setOwners(worldguardRegion, parseAccessSet(value));
// AreaShop.debug(" Flag " + flagName + " set: " + owners.toUserFriendlyString());
} else if (flagName.equalsIgnoreCase("priority")) {
try {
int priority = Integer.parseInt(value);
if (worldguardRegion.getPriority() != priority) {
worldguardRegion.setPriority(priority);
}
// AreaShop.debug(" Flag " + flagName + " set: " + value);
} catch (NumberFormatException e) {
AreaShop.warn(("The value of flag " + flagName) + " is not a number");
result = false;
}} else if (flagName.equalsIgnoreCase("parent")) {
if ((region.getWorld() == null) || (plugin.getRegionManager(region.getWorld()) == null)) {
continue;
}
ProtectedRegion parentRegion = plugin.getRegionManager(region.getWorld()).getRegion(value);
if (parentRegion != null) {
if (!parentRegion.equals(worldguardRegion.getParent())) {
try {
worldguardRegion.setParent(parentRegion);
// AreaShop.debug(" Flag " + flagName + " set: " + value);
} catch (ProtectedRegion.CircularInheritanceException e) {
AreaShop.warn("The parent set in the config is not correct (circular inheritance)");
}
}} else {
AreaShop.warn("The parent set in the config is not correct (region does not exist)");
}
} else {
// Parse all other normal flags (groups are also handled)
String
flagSetting = null;
RegionGroup groupValue = null;
Flag<?> foundFlag = plugin.getWorldGuardHandler().fuzzyMatchFlag(flagName);if (foundFlag == null) {AreaShop.warn(("Found wrong flag in flagProfiles section: " + flagName) + ", check if that is the correct WorldGuard flag");
continue;
}
RegionGroupFlag groupFlag = foundFlag.getRegionGroupFlag();
if ((value == null) || value.isEmpty()) {
if
(worldguardRegion.getFlag(foundFlag) != null) {
worldguardRegion.setFlag(foundFlag, null);
}
if ((groupFlag != null) && (worldguardRegion.getFlag(groupFlag) != null)) {
worldguardRegion.setFlag(groupFlag, null);
}
// AreaShop.debug(" Flag " + flagName + " reset (+ possible group of flag)");
} else {
if (groupFlag == null) {
flagSetting
= value;
} else {
for (String part : value.split(" ")) {
if (part.startsWith("g:")) {
if (part.length() > 2) {
try {
groupValue = plugin.getWorldGuardHandler().parseFlagGroupInput(groupFlag, part.substring(2));
} catch (InvalidFlagFormat e) {
AreaShop.warn("Found wrong group value for flag " + flagName);
}
}
} else if (flagSetting == null) {
flagSetting = part;
} else {
flagSetting += " " + part;
}
}
}
if (flagSetting != null) {
try {
setFlag(worldguardRegion, foundFlag, flagSetting);
// AreaShop.debug(" Flag " + flagName + " set: " + flagSetting);
} catch (InvalidFlagFormat e)
{
AreaShop.warn("Found wrong value for flag " + flagName);
}
}
if (groupValue != null) {
if (groupValue == groupFlag.getDefault()) {
worldguardRegion.setFlag(groupFlag, null);
// AreaShop.debug(" Group of flag " + flagName + " set to default: " + groupValue);
} else {
worldguardRegion.setFlag(groupFlag, groupValue);
// AreaShop.debug(" Group of flag " + flagName + " set: " + groupValue);
}
}
}
}
}
// Indicate that the regions needs to be saved
if (worldGuard.getDescription().getVersion().startsWith("5.")) {
plugin.getFileManager().saveIsRequiredForRegionWorld(region.getWorldName());
}
return result;
}
| 3.26 |
AreaShop_WorldGuardRegionFlagsFeature_translateBukkitToWorldGuardColors_rdh
|
/**
* Translate the color codes you put in greeting/farewell messages to the weird color codes of WorldGuard.
*
* @param message
* The message where the color codes should be translated (this message has bukkit color codes)
* @return The string with the WorldGuard color codes
*/
private String translateBukkitToWorldGuardColors(String message) {
String v22 = message;
v22 = v22.replace("&c", "&r");
v22 = v22.replace("&4", "&R");
v22 = v22.replace("&e", "&y");
v22 = v22.replace("&6", "&Y");v22 = v22.replace("&a", "&g");
v22 = v22.replace("&2",
"&G"); v22 = v22.replace("&b", "&c");
v22 = v22.replace("&3", "&C");v22 = v22.replace("&9", "&b");
v22 = v22.replace("&1", "&B");
v22 = v22.replace("&d", "&p");
v22 = v22.replace("&5", "&P");
v22 = v22.replace("&0", "&0");
v22 = v22.replace("&8", "&1");
v22 = v22.replace("&7", "&2");
v22 = v22.replace("&f", "&w");
v22 = v22.replace("&r",
"&x");
return v22;
}
| 3.26 |
AreaShop_WorldGuardRegionFlagsFeature_setFlag_rdh
|
/**
* Set a WorldGuard region flag.
*
* @param region
* The WorldGuard region to set
* @param flag
* The flag to set
* @param value
* The value to set the flag to
* @param <V>
* They type of flag to set
* @throws InvalidFlagFormat
* When the value of the flag is wrong
*/
private <V> void setFlag(ProtectedRegion region, Flag<V> flag, String value) throws InvalidFlagFormat {
V current = region.getFlag(flag);
V next = plugin.getWorldGuardHandler().parseFlagInput(flag, value);
if (!Objects.equals(current, next)) {
region.setFlag(flag, next);
}
}
| 3.26 |
AreaShop_UnrentCommand_canUse_rdh
|
/**
* Check if a person can unrent the region.
*
* @param person
* The person to check
* @param region
* The region to check for
* @return true if the person can unrent it, otherwise false
*/
public static boolean canUse(CommandSender person, GeneralRegion region) {
if (person.hasPermission("areashop.unrent")) {return true;
}
if
(person instanceof Player)
{
Player player = ((Player) (person));return region.isOwner(player) && person.hasPermission("areashop.unrentown");
}
return false;
}
| 3.26 |
framework_InterruptUpload_receiveUpload_rdh
|
/**
* return an OutputStream that simply counts lineends
*/
@Override
public OutputStream receiveUpload(final String filename, final String MIMEType) {
counter = 0;
total = 0;
return new OutputStream() {
private static final int searchedByte = '\n';
@Override
public void write(final int b) {
total++;
if (b == searchedByte) {
counter++;
}
if (sleep && ((total % 1000) == 0)) {
try {
Thread.sleep(100);
} catch (final InterruptedException e) {
e.printStackTrace();
}
}
}
};
}
| 3.26 |
framework_VCheckBoxGroup_setOptionEnabled_rdh
|
/**
* Updates the checkbox's enabled state according to the widget's enabled,
* read only and the item's enabled.
*
* @param checkBox
* the checkbox to update
* @param item
* the item for the checkbox
*/
protected void setOptionEnabled(VCheckBox checkBox, JsonObject item) {
boolean optionEnabled = !item.getBoolean(ListingJsonConstants.JSONKEY_ITEM_DISABLED);
boolean enabled = (optionEnabled && (!isReadonly())) && isEnabled();
checkBox.setEnabled(enabled);
// #9258 apply the v-disabled class when disabled for UX
checkBox.setStyleName(StyleConstants.DISABLED, (!isEnabled()) || (!optionEnabled));
}
| 3.26 |
framework_VCheckBoxGroup_getItem_rdh
|
/**
* Returns the JsonObject used to populate the CheckBox widget that contains
* given Element.
*
* @since 8.2
* @param element
* the element to search for
* @return the related JsonObject; {@code null} if not found
*/
public JsonObject getItem(Element element) {
return optionsToItems.entrySet().stream().filter(entry -> entry.getKey().getElement().isOrHasChild(element)).map(entry -> entry.getValue()).findFirst().orElse(null);
}
| 3.26 |
framework_VCheckBoxGroup_buildOptions_rdh
|
/* Build all the options */
public void buildOptions(List<JsonObject> items) {
Roles.getGroupRole().set(getElement());
int i = 0;
int widgetsToRemove = getWidget().getWidgetCount() - items.size();
if (widgetsToRemove < 0) {
widgetsToRemove = 0;
}
List<Widget> remove = new ArrayList<>(widgetsToRemove);
for (Widget widget : getWidget()) {
if (i < items.size()) {
updateItem(((VCheckBox)
(widget)), items.get(i), false);
i++;
} else {
remove.add(widget);
}
}
remove.stream().forEach(this::remove);
while (i < items.size()) {
updateItem(new VCheckBox(), items.get(i), true);
i++;}
}
| 3.26 |
framework_DragEndEvent_getComponent_rdh
|
/**
* Returns the drag source component where the dragend event occurred.
*
* @return Component which was dragged.
*/
@Override
@SuppressWarnings("unchecked")
public T getComponent() {
return ((T) (super.getComponent()));
}
| 3.26 |
framework_BeanItem_addNestedProperty_rdh
|
/**
* Adds a nested property to the item. The property must not exist in the
* item already and must of form "field1.field2" where field2 is a field in
* the object referenced to by field1. If an intermediate property returns
* null, the property will return a null value
*
* @param nestedPropertyId
* property id to add.
*/
public void addNestedProperty(String nestedPropertyId) {
addItemProperty(nestedPropertyId, new NestedMethodProperty<Object>(getBean(), nestedPropertyId));
}
| 3.26 |
framework_BeanItem_expandProperty_rdh
|
/**
* Expands nested bean properties by replacing a top-level property with
* some or all of its sub-properties. The expansion is not recursive.
*
* @param propertyId
* property id for the property whose sub-properties are to be
* expanded,
* @param subPropertyIds
* sub-properties to expand, all sub-properties are expanded if
* not specified
*/
public void expandProperty(String propertyId, String... subPropertyIds) {
Set<String> subPropertySet = new HashSet<String>(Arrays.asList(subPropertyIds));
if (0 == subPropertyIds.length) {
// Enumerate all sub-properties
Class<?> propertyType = getItemProperty(propertyId).getType();
Map<String, ?> pds = getPropertyDescriptors(propertyType);
subPropertySet.addAll(pds.keySet());
}
for (String subproperty : subPropertySet) {
String qualifiedPropertyId = (propertyId + ".") + subproperty;
addNestedProperty(qualifiedPropertyId);
}
removeItemProperty(propertyId);
}
| 3.26 |
framework_BeanItem_setBean_rdh
|
/**
* Changes the Java Bean this item is based on.
* <p>
* This will cause any existing properties to be re-mapped to the new bean.
* Any added custom properties which are not of type {@link MethodProperty}
* or {@link NestedMethodProperty} will not be updated to reflect the change
* of bean.
* <p>
* Changing the bean will fire value change events for all properties of
* type {@link MethodProperty} or {@link NestedMethodProperty}.
*
* @param bean
* The new bean to use for this item, not <code>null</code>
* @since 7.7.7
*/
public void setBean(BT bean) {
if (bean == null) {
throw new IllegalArgumentException("Bean cannot be null");
}
if (getBean().getClass() != bean.getClass()) {
throw new IllegalArgumentException((("The new bean class " + bean.getClass().getName()) + " does not match the old bean class ") + getBean().getClass());
}
// Remap properties
for (Object propertyId : getItemPropertyIds()) {Property p = getItemProperty(propertyId);if (p instanceof MethodProperty) {
MethodProperty mp = ((MethodProperty) (p));
assert mp.getInstance() == getBean();
mp.setInstance(bean);
} else if (p instanceof NestedMethodProperty) {
NestedMethodProperty nmp = ((NestedMethodProperty) (p));
assert nmp.getInstance() == getBean();
nmp.setInstance(bean);
}
}
this.bean =
bean;}
| 3.26 |
framework_BeanItem_getPropertyDescriptors_rdh
|
/**
* <p>
* Perform introspection on a Java Bean class to find its properties.
* </p>
*
* <p>
* Note : This version only supports introspectable bean properties and
* their getter and setter methods. Stand-alone <code>is</code> and
* <code>are</code> methods are not supported.
* </p>
*
* @param beanClass
* the Java Bean class to get properties for.
* @return an ordered map from property names to property descriptors
*/
static <BT> LinkedHashMap<String, VaadinPropertyDescriptor<BT>> getPropertyDescriptors(final Class<BT> beanClass) {
final LinkedHashMap<String, VaadinPropertyDescriptor<BT>> pdMap = new LinkedHashMap<String, VaadinPropertyDescriptor<BT>>();
// Try to introspect, if it fails, we just have an empty Item
try {
List<PropertyDescriptor> propertyDescriptors = BeanUtil.getBeanPropertyDescriptors(beanClass);
// Add all the bean properties as MethodProperties to this Item
// later entries on the list overwrite earlier ones
for (PropertyDescriptor pd : propertyDescriptors) {
final Method getMethod = pd.getReadMethod();
if ((getMethod != null) && (getMethod.getDeclaringClass() != Object.class)) {
VaadinPropertyDescriptor<BT> vaadinPropertyDescriptor = new MethodPropertyDescriptor<BT>(pd.getName(), pd.getPropertyType(), pd.getReadMethod(), pd.getWriteMethod());
pdMap.put(pd.getName(), vaadinPropertyDescriptor);
}
}
} catch (final IntrospectionException ignored) {
}
return pdMap;
}
| 3.26 |
framework_BeanItem_getBean_rdh
|
/**
* Gets the underlying JavaBean object.
*
* @return the bean object.
*/
public BT getBean() {
return bean;
}
| 3.26 |
framework_ConnectorInfoPanel_update_rdh
|
/**
* Update the panel to show information about a connector.
*
* @param connector
*/public void update(ServerConnector connector) {
SharedState state = connector.getState();
Set<String> ignoreProperties = new HashSet<>();
ignoreProperties.add("id");
String html = getRowHTML("Id", connector.getConnectorId());
html +=
getRowHTML("Connector", connector.getClass().getSimpleName());
if (connector instanceof ComponentConnector) {
ComponentConnector component = ((ComponentConnector) (connector));
ignoreProperties.addAll(Arrays.asList("caption", "description", "width", "height"));
AbstractComponentState componentState = component.getState();
html += getRowHTML("Widget", component.getWidget().getClass().getSimpleName());
html += getRowHTML("Caption", componentState.caption);
html += getRowHTML("Description", componentState.description);
html += getRowHTML("Width", ((componentState.width + " (actual: ") + component.getWidget().getOffsetWidth()) + "px)");
html += getRowHTML("Height", ((componentState.height + " (actual: ") + component.getWidget().getOffsetHeight()) + "px)");
}
try {
JsArrayObject<Property> properties = AbstractConnector.getStateType(connector).getPropertiesAsArray();
for (int i = 0; i < properties.size(); i++) {
Property property
= properties.get(i);
String name = property.getName();
if (!ignoreProperties.contains(name)) {html
+= getRowHTML(property.getDisplayName(), property.getValue(state));
}
}
} catch
(NoDataException e) {
html
+= "<div>Could not read state, error has been logged to the console</div>";
m0().log(Level.SEVERE, "Could not read state", e);
}
clear();
add(new HTML(html));
}
| 3.26 |
framework_DragHandle_addTo_rdh
|
/**
* Adds this drag handle to an HTML element.
*
* @param elem
* an element
*/
public void
addTo(Element elem)
{
removeFromParent();
parent = elem;
parent.appendChild(element);
}
| 3.26 |
framework_DragHandle_setCallback_rdh
|
/**
* Sets the user-facing drag handle callback method. This allows code using
* the DragHandle to react to the situations where a drag handle first
* touched, when it's moved and when it's released.
*
* @param dragHandleCallback
* the callback object to use (can be null)
* @since 7.7.5
*/
public void setCallback(DragHandleCallback dragHandleCallback) {
userCallback = dragHandleCallback;
}
| 3.26 |
framework_DragHandle_removeStyleName_rdh
|
/**
* Removes existing style name from drag handle element.
*
* @param styleName
* a CSS style name
*/
public void removeStyleName(String styleName) {
element.removeClassName(styleName);
}
| 3.26 |
framework_DragHandle_addStyleName_rdh
|
/**
* Adds CSS style name to the drag handle element.
*
* @param styleName
* a CSS style name
*/public void addStyleName(String styleName) {
element.addClassName(styleName);
}
| 3.26 |
framework_DragHandle_removeFromParent_rdh
|
/**
* Removes this drag handle from whatever it was attached to.
*/
public void removeFromParent() {
if (parent != null) {parent.removeChild(element);
parent = null;
}
}
| 3.26 |
framework_BaseAlignment_buildLayout_rdh
|
/**
* Build Layout for test
*/
private void buildLayout() {
for (int i = 0;
i < components.length; i++) {
AbstractOrderedLayout layout = null;
try {
layout = ((AbstractOrderedLayout) (layoutClass.newInstance()));
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();}
layout.setMargin(false);
layout.setSpacing(false);
layout.setHeight("100px");
layout.setWidth("200px");
layout.addComponent(components[i]);
layout.setComponentAlignment(components[i], alignments[i]);
if (i < (components.length / 2)) {
l1.addComponent(layout);
} else {
l2.addComponent(layout);
}
}
}
| 3.26 |
framework_VTree_selectNode_rdh
|
/**
* Selects a node and deselect all other nodes
*
* @param node
* The node to select
*/
private void selectNode(TreeNode node, boolean deselectPrevious) {
if (deselectPrevious) {
deselectAll();
}
if (node != null) {
node.setSelected(true);
selectedIds.add(node.key);
lastSelection = node;
}
selectionHasChanged = true;
}
| 3.26 |
framework_VTree_getPreviousSibling_rdh
|
/**
* Returns the previous sibling in the tree
*
* @param node
* The node to get the sibling for
* @return The sibling node or null if the node is the first sibling
*/
private TreeNode getPreviousSibling(TreeNode node) {TreeNode parent = node.getParentNode();
List<TreeNode> children;
if (parent == null) {
children = getRootNodes();
} else {
children = parent.getChildren();
}
int
idx = children.indexOf(node);
if (idx > 0) {
return children.get(idx - 1);
}
return null;
}
/**
* Add this to the element mouse down event by using element.setPropertyJSO
* ("onselectstart",applyDisableTextSelectionIEHack()); Remove it then again
* when the mouse is depressed in the mouse up event.
*
* @return Returns the JSO preventing text selection
*/
/* -{
return function() { return false; };
}
| 3.26 |
framework_VTree_updateDropHandler_rdh
|
/**
* For internal use only. May be removed or replaced in the future.
*/
public void updateDropHandler(UIDL childUidl) {
if (f1 == null) {
f1 = new VAbstractDropHandler() {
@Override
public void dragEnter(VDragEvent drag) {
}
@Override
protected void m0(final VDragEvent drag) {
}
@Override
public void dragOver(final VDragEvent currentDrag) {
final Object oldIdOver = currentDrag.getDropDetails().get("itemIdOver");
final VerticalDropLocation oldDetail = ((VerticalDropLocation) (currentDrag.getDropDetails().get("detail")));
updateTreeRelatedDragData(currentDrag);
final VerticalDropLocation detail = ((VerticalDropLocation) (currentDrag.getDropDetails().get("detail")));
boolean nodeHasChanged = ((currentMouseOverKey != null) && (currentMouseOverKey != oldIdOver)) || ((currentMouseOverKey == null) && (oldIdOver != null));
boolean detailHasChanded = ((detail != null) && (detail != oldDetail)) || ((detail == null) && (oldDetail != null));if (nodeHasChanged || detailHasChanded) {final String newKey = currentMouseOverKey;
TreeNode treeNode = keyToNode.get(oldIdOver);
if (treeNode != null) {// clear old styles
treeNode.emphasis(null);
}
if (newKey != null) {
validate(new VAcceptCallback() {
@Override
public void m1(VDragEvent event) {
VerticalDropLocation curDetail = ((VerticalDropLocation) (event.getDropDetails().get("detail")));
if ((curDetail == detail) && newKey.equals(currentMouseOverKey)) {
m6(newKey).emphasis(detail);
}
/* Else drag is already on a different
node-detail pair, new criteria check is
going on
*/
}
}, currentDrag);
}
}
}
@Override
public void m2(VDragEvent drag) {
cleanUp();
}
private void cleanUp() {
if (currentMouseOverKey != null) {
m6(currentMouseOverKey).emphasis(null);
currentMouseOverKey = null;
}
}
@Override
public boolean drop(VDragEvent drag) {
cleanUp();
return super.drop(drag);
}
@Override
public ComponentConnector getConnector() {
return ConnectorMap.get(client).getConnector(VTree.this);
}
@Override
public ApplicationConnection getApplicationConnection() {return client;
}
};
}
f1.updateAcceptRules(childUidl);
}
| 3.26 |
framework_VTree_m7_rdh
|
/**
* Select a range between two nodes which have no relation to each other
*
* @param startNode
* The start node to start the selection from
* @param endNode
* The end node to end the selection to
*/
private void m7(TreeNode startNode, TreeNode endNode) {
TreeNode commonParent = getCommonGrandParent(startNode, endNode);
TreeNode startBranch = null;
TreeNode endBranch = null;
// Find the children of the common parent
List<TreeNode> children;
if (commonParent != null) {
children = commonParent.getChildren();
} else {
children = getRootNodes();
}
// Find the start and end branches
for (TreeNode node
: children) {
if (nodeIsInBranch(startNode, node)) {
startBranch = node;
}
if (nodeIsInBranch(endNode, node)) {
endBranch = node;
}
}
// Swap nodes if necessary
if (children.indexOf(startBranch) > children.indexOf(endBranch)) {
TreeNode temp = startBranch;
startBranch = endBranch;
endBranch = temp;
temp = startNode;
startNode = endNode;
endNode = temp;
}
// Select all children under the start node
selectAllChildren(startNode, true);
TreeNode startParent = startNode.getParentNode();
TreeNode currentNode = startNode;while ((startParent != null) && (startParent != commonParent)) {
List<TreeNode> startChildren = startParent.getChildren();
for (int i = startChildren.indexOf(currentNode) + 1; i < startChildren.size(); i++) {
selectAllChildren(startChildren.get(i), true);}
currentNode
= startParent;
startParent = startParent.getParentNode();
}
// Select nodes until the end node is reached
for (int i = children.indexOf(startBranch) + 1; i <= children.indexOf(endBranch);
i++) {
selectAllChildrenUntil(children.get(i), endNode, true, true);
}
// Ensure end node was selected
endNode.setSelected(true);
selectedIds.add(endNode.key);
selectionHasChanged = true;
}
| 3.26 |
framework_VTree_setState_rdh
|
/**
* For internal use only. May be removed or replaced in the future.
*/public void setState(boolean state, boolean notifyServer) {
if (open
== state) {return;
}
if (state) {
if ((!childrenLoaded) && notifyServer) {client.updateVariable(paintableId, "requestChildTree", true, false);
}
if (notifyServer) {
client.updateVariable(paintableId, "expand", new String[]{ key }, true);
}
addStyleName(CLASSNAME + "-expanded");Roles.getTreeitemRole().setAriaExpandedState(getElement(), ExpandedValue.TRUE);
childNodeContainer.setVisible(true);} else {
removeStyleName(CLASSNAME + "-expanded");
Roles.getTreeitemRole().setAriaExpandedState(getElement(), ExpandedValue.FALSE);
childNodeContainer.setVisible(false);
if (notifyServer) {
client.updateVariable(paintableId,
"collapse", new String[]{ key }, true);
}
}open = state;
if (!rendering) {
m9();
}
}
| 3.26 |
framework_VTree_getLastRootNode_rdh
|
/**
* Returns the last root node of the tree or null if there are no root
* nodes.
*
* @return The last root {@link TreeNode}
*/
protected TreeNode getLastRootNode() {
if (f0.getWidgetCount() == 0) {
return null;
}
return ((TreeNode) (f0.getWidget(f0.getWidgetCount() - 1)));
}
| 3.26 |
framework_VTree_isSelected_rdh
|
/**
* Is a node selected in the tree.
*
* @param treeNode
* The node to check
* @return */
public boolean isSelected(TreeNode treeNode) {
return selectedIds.contains(treeNode.key);
}
| 3.26 |
framework_VTree_setFocused_rdh
|
/**
* Is the node focused?
*
* @param focused
* True if focused, false if not
*/
public void setFocused(boolean
focused) {
if ((!this.focused) && focused) {
nodeCaptionDiv.addClassName(CLASSNAME_FOCUSED);
this.focused = focused;
if (BrowserInfo.get().isOpera()) {
nodeCaptionDiv.focus();
}
treeHasFocus = true;
} else if (this.focused && (!focused)) {
nodeCaptionDiv.removeClassName(CLASSNAME_FOCUSED);
this.focused = focused;
treeHasFocus = false;
}
}
| 3.26 |
framework_VTree_m3_rdh
|
/**
* For internal use only. May be removed or replaced in the future.
*/
public boolean m3() {
return open;
}
| 3.26 |
framework_VTree_nodeIsInBranch_rdh
|
/**
* Examines the children of the branch node and returns true if a node is in
* that branch
*
* @param node
* The node to search for
* @param branch
* The branch to search in
* @return True if found, false if not found
*/
private boolean nodeIsInBranch(TreeNode node, TreeNode branch) {
if (node == branch) {
return true;
}
for (TreeNode child : branch.getChildren()) {
if (child == node) {
return true;
}
if ((!child.isLeaf()) && child.m3()) {
if (nodeIsInBranch(node, child)) {
return true;
}
}
}
return false;
}
| 3.26 |
framework_VTree_getNextSibling_rdh
|
/**
* Gets the next sibling in the tree
*
* @param node
* The node to get the sibling for
* @return The sibling node or null if the node is the last sibling
*/
private TreeNode getNextSibling(TreeNode node) {
TreeNode parent = node.getParentNode();
List<TreeNode>
children;
if (parent == null) {
children = getRootNodes();
} else {
children = parent.getChildren();
}
int idx = children.indexOf(node);
if (idx < (children.size() - 1)) {return children.get(idx + 1);
}
return null;
}
| 3.26 |
framework_VTree_getRootNodes_rdh
|
/**
* Returns a list of all root nodes in the Tree in the order they appear in
* the tree.
*
* @return A list of all root {@link TreeNode}s.
*/
protected List<TreeNode> getRootNodes() {
List<TreeNode> rootNodes
= new ArrayList<TreeNode>();
for (int i = 0; i < f0.getWidgetCount(); i++) {
rootNodes.add(((TreeNode) (f0.getWidget(i))));
}
return rootNodes;
}
| 3.26 |
framework_VTree_doRelationSelection_rdh
|
/**
* Selects a range of items which are in direct relation with each
* other.<br/>
* NOTE: The start node <b>MUST</b> be before the end node!
*
* @param startNode
* @param endNode
*/
private void doRelationSelection(TreeNode startNode, TreeNode endNode) {
TreeNode currentNode = endNode;
while (currentNode != startNode) {
currentNode.setSelected(true);selectedIds.add(currentNode.key);
// Traverse children above the selection
List<TreeNode> subChildren = currentNode.getParentNode().getChildren();
if (subChildren.size() > 1) {
selectNodeRange(subChildren.iterator().next().key, currentNode.key);} else if (subChildren.size() == 1) {
TreeNode n = subChildren.get(0);n.setSelected(true);
selectedIds.add(n.key);
}
currentNode =
currentNode.getParentNode();
} startNode.setSelected(true);
selectedIds.add(startNode.key);
selectionHasChanged = true;
}
| 3.26 |
framework_VTree_getNavigationSelectKey_rdh
|
/**
* Get the key that selects an item in the table. By default it is the space
* bar key but by overriding this you can change the key to whatever you
* want.
*
* @return */
protected int getNavigationSelectKey() {
return CHARCODE_SPACE;
}
| 3.26 |
framework_VTree_getChildren_rdh
|
/**
* Returns the children of the node.
*
* @return A set of tree nodes
*/
public List<TreeNode> getChildren() {
List<TreeNode> nodes = new LinkedList<TreeNode>();if ((!isLeaf()) && isChildrenLoaded()) {
for (Widget w : childNodeContainer) {
TreeNode node = ((TreeNode) (w));
nodes.add(node);
}
}
return nodes;
}
| 3.26 |
framework_VTree_setHtml_rdh
|
/**
* For internal use only. May be removed or replaced in the future.
*/
public void setHtml(String html) {
nodeCaptionSpan.setInnerHTML(html);
}
| 3.26 |
framework_VTree_handleClickSelection_rdh
|
/**
* Handles mouse selection
*
* @param ctrl
* Was the ctrl-key pressed
* @param shift
* Was the shift-key pressed
* @return Returns true if event was handled, else false
*/
private boolean handleClickSelection(final boolean ctrl,
final boolean shift) {
// always when clicking an item, focus it
setFocusedNode(this, false);
if (!BrowserInfo.get().isOpera()) { /* Ensure that the tree's focus element also gains focus
(TreeNodes focus is faked using FocusElementPanel in browsers
other than Opera).
*/
focus();
}
executeEventCommand(new ScheduledCommand() {
@Override
public void execute() {
if ((multiSelectMode == MultiSelectMode.SIMPLE) || (!isMultiselect)) {
toggleSelection();
lastSelection = TreeNode.this;
} else if (multiSelectMode == MultiSelectMode.DEFAULT) {
// Handle ctrl+click
if ((isMultiselect && ctrl) && (!shift)) {
toggleSelection();
lastSelection = TreeNode.this;
// Handle shift+click
} else
if ((isMultiselect && (!ctrl)) && shift) {
deselectAll();
selectNodeRange(lastSelection.key, key);
sendSelectionToServer(); // Handle ctrl+shift click
}
else if ((isMultiselect &&
ctrl) && shift) {
selectNodeRange(lastSelection.key, key);
// Handle click
} else {
// TODO should happen only if this alone not yet
// selected,
// now sending excess server calls
deselectAll();
toggleSelection();
lastSelection = TreeNode.this;
}
}
}
});
return true;
}
| 3.26 |
framework_VTree_getNavigationEndKey_rdh
|
/**
* Get the key the moves the selection to the end of the table. By default
* this is the End key but by overriding this you can change the key to
* whatever you want.
*
* @return */
protected int getNavigationEndKey() {return KeyCodes.KEY_END;
}
| 3.26 |
framework_VTree_selectAllChildren_rdh
|
/**
* Selects all the open children to a node
*
* @param node
* The parent node
*/
private void selectAllChildren(TreeNode node, boolean includeRootNode) {
if (includeRootNode) {
node.setSelected(true);
selectedIds.add(node.key);
}
for (TreeNode child : node.getChildren()) {
if ((!child.isLeaf()) && child.m3()) {
selectAllChildren(child, true);} else
{
child.setSelected(true);
selectedIds.add(child.key);
}
}
selectionHasChanged = true;
}
| 3.26 |
framework_VTree_handleKeyNavigation_rdh
|
/**
* Handles the keyboard navigation.
*
* @param keycode
* The keycode of the pressed key
* @param ctrl
* Was ctrl pressed
* @param shift
* Was shift pressed
* @return Returns true if the key was handled, else false
*/
protected boolean handleKeyNavigation(int keycode, boolean ctrl, boolean shift) {
// Navigate down
if (keycode == getNavigationDownKey()) {
TreeNode node = null;
// If node is open and has children then move in to the children
if (((!focusedNode.isLeaf()) && focusedNode.m3()) && (!focusedNode.getChildren().isEmpty()))
{
node = focusedNode.getChildren().get(0);
} else {
// Move down to the next sibling
node = getNextSibling(focusedNode);
if (node == null) {
// Jump to the parent and try to select the next
// sibling there
TreeNode v79 = focusedNode;
while ((node == null) && (v79.getParentNode() != null)) {
node = getNextSibling(v79.getParentNode());
v79 = v79.getParentNode();
} }
}
if (node != null) {
setFocusedNode(node);
if (selectable) {
if ((!ctrl) && (!shift)) {
selectNode(node, true);
} else if (shift && isMultiselect) {
deselectAll();
selectNodeRange(lastSelection.key, node.key);
} else if (shift) {
selectNode(node, true);
}
}
showTooltipForKeyboardNavigation(node);
}
return true;
}
// Navigate up
if (keycode == getNavigationUpKey()) {
TreeNode v80 = getPreviousSibling(focusedNode);
TreeNode node = null;
if (v80 != null) {
node = getLastVisibleChildInTree(v80);
} else if (focusedNode.getParentNode() != null) {
node = focusedNode.getParentNode();
}
if (node
!= null) {
setFocusedNode(node);
if (selectable) {
if ((!ctrl) && (!shift)) {
selectNode(node, true);
} else if (shift && isMultiselect) {
deselectAll();
selectNodeRange(lastSelection.key, node.key);
} else if (shift) {
selectNode(node, true);
}
}
showTooltipForKeyboardNavigation(node);
}
return true;
}
// Navigate left (close branch)
if (keycode == getNavigationLeftKey()) {
if ((!focusedNode.isLeaf()) && focusedNode.m3()) {
focusedNode.setState(false, true);
} else if ((focusedNode.getParentNode() != null) && (focusedNode.isLeaf() || (!focusedNode.m3()))) {
if (ctrl || (!selectable)) {
setFocusedNode(focusedNode.getParentNode());} else if (shift) {
doRelationSelection(focusedNode.getParentNode(), focusedNode);
setFocusedNode(focusedNode.getParentNode());
} else {
focusAndSelectNode(focusedNode.getParentNode());
}}
showTooltipForKeyboardNavigation(focusedNode);
return true;
}
// Navigate right (open branch)
if (keycode == getNavigationRightKey()) {
if ((!focusedNode.isLeaf()) && (!focusedNode.m3())) {
focusedNode.setState(true, true);
} else if (!focusedNode.isLeaf())
{
if (ctrl || (!selectable)) {
setFocusedNode(focusedNode.getChildren().get(0));
} else if (shift)
{
setSelected(focusedNode, true);
setFocusedNode(focusedNode.getChildren().get(0));
setSelected(focusedNode, true);
} else {
focusAndSelectNode(focusedNode.getChildren().get(0));
}
}
showTooltipForKeyboardNavigation(focusedNode);
return true;
}// Selection
if (keycode == getNavigationSelectKey()) {
if (!focusedNode.isSelected()) {
selectNode(focusedNode, ((!isMultiselect) || (multiSelectMode == MULTISELECT_MODE_SIMPLE)) && selectable);
} else {
deselectNode(focusedNode);
}
return true;
}
// Home selection
if (keycode == m8()) {
TreeNode node = getFirstRootNode();
if (ctrl
|| (!selectable))
{
setFocusedNode(node);
} else if (shift) {
deselectAll();selectNodeRange(focusedNode.key, node.key);
} else {
selectNode(node, true);
}
sendSelectionToServer();
showTooltipForKeyboardNavigation(node);
return true;}
// End selection
if (keycode == getNavigationEndKey()) {
TreeNode lastNode = getLastRootNode();
TreeNode node = getLastVisibleChildInTree(lastNode);
if (ctrl || (!selectable)) {setFocusedNode(node);
} else if (shift) {
deselectAll();
selectNodeRange(focusedNode.key, node.key);
} else {
selectNode(node, true);
}
sendSelectionToServer();
showTooltipForKeyboardNavigation(node);
return true;
}
return false;
}
| 3.26 |
framework_VTree_deselectAll_rdh
|
/**
* Deselects all items in the tree.
*/
public void deselectAll() {
for (String key : selectedIds) {
TreeNode node = keyToNode.get(key);
if
(node != null) {
node.setSelected(false);
}
}
selectedIds.clear();
selectionHasChanged = true;
}
| 3.26 |
framework_VTree_deselectNode_rdh
|
/**
* Deselects a node
*
* @param node
* The node to deselect
*/private void deselectNode(TreeNode node) {
node.setSelected(false);
selectedIds.remove(node.key);
selectionHasChanged = true;
}
| 3.26 |
framework_VTree_getNavigationPageUpKey_rdh
|
/**
* Get the key the moves the selection one page up in the table. By default
* this is the Page Up key but by overriding this you can change the key to
* whatever you want.
*
* @return */
protected int getNavigationPageUpKey() {
return KeyCodes.KEY_PAGEUP;
}
| 3.26 |
framework_VTree_m8_rdh
|
/**
* Get the key the moves the selection to the beginning of the table. By
* default this is the Home key but by overriding this you can change the
* key to whatever you want.
*
* @return */
protected int m8() {
return KeyCodes.KEY_HOME;
}
| 3.26 |
framework_VTree_selectNodeRange_rdh
|
/**
* Selects a range of nodes
*
* @param startNodeKey
* The start node key
* @param endNodeKey
* The end node key
*/
private void selectNodeRange(String startNodeKey, String endNodeKey) {
TreeNode startNode = keyToNode.get(startNodeKey);
TreeNode endNode = keyToNode.get(endNodeKey);
// The nodes have the same parent
if (startNode.getParent() == endNode.getParent()) {
doSiblingSelection(startNode, endNode);
// The start node is a grandparent of the end node
} else if (startNode.isGrandParentOf(endNode)) {
doRelationSelection(startNode, endNode); // The end node is a grandparent of the start node
} else if (endNode.isGrandParentOf(startNode)) {
doRelationSelection(endNode, startNode);
} else
{
m7(startNode, endNode);
}
}
| 3.26 |
framework_VTree_isGrandParentOf_rdh
|
/**
* Travels up the hierarchy looking for this node.
*
* @param child
* The child which grandparent this is or is not
* @return True if this is a grandparent of the child node
*/public boolean isGrandParentOf(TreeNode child) {
TreeNode
currentNode = child;
boolean v41 = false;
while (currentNode != null) {
currentNode = currentNode.getParentNode();
if (currentNode == this) {
v41
= true;
break;
}
}
return v41;
}
| 3.26 |
framework_VTree_m4_rdh
|
/**
* For internal use only. May be removed or replaced in the future.
*/
public void m4(String text) {
DOM.setInnerText(nodeCaptionSpan, text);
}
| 3.26 |
framework_VTree_sendSelectionToServer_rdh
|
/**
* Sends the selection to the server
*/
private void sendSelectionToServer() {
Command command = new Command() {
@Override
public void execute() {
/* we should send selection to server immediately in 2 cases: 1)
'immediate' property of Tree is true 2) clickEventPending is
true
*/
client.updateVariable(paintableId, "selected", selectedIds.toArray(new String[selectedIds.size()]), clickEventPending || immediate);
clickEventPending = false;
selectionHasChanged = false;
}};
/* Delaying the sending of the selection in webkit to ensure the
selection is always sent when the tree has focus and after click
events have been processed. This is due to the focusing
implementation in FocusImplSafari which uses timeouts when focusing
and blurring.
*/
if (BrowserInfo.get().isWebkit()) {
Scheduler.get().scheduleDeferred(command);
} else {
command.execute();
}
}
| 3.26 |
framework_VTree_setFocusedNode_rdh
|
/**
* Focuses a node and scrolls it into view.
*
* @param node
* The node to focus
*/
public void setFocusedNode(TreeNode node) {
setFocusedNode(node, true);
}
| 3.26 |
framework_VTree_isCaptionElement_rdh
|
/**
* Checks if the given element is the caption or the icon.
*
* @param target
* The element to check
* @return true if the element is the caption or the icon
*/
public boolean isCaptionElement(Element target) {
return nodeCaptionSpan.isOrHasChild(target) || ((icon != null) && (target == icon.getElement()));
}
| 3.26 |
framework_VTree_getNavigationDownKey_rdh
|
/**
* Get the key that moves the selection head downwards. By default it is the
* down arrow key but by overriding this you can change the key to whatever
* you want.
*
* @return The keycode of the key
*/
protected int getNavigationDownKey() {return KeyCodes.KEY_DOWN;
}
| 3.26 |
framework_VTree_getFirstRootNode_rdh
|
/**
* Returns the first root node of the tree or null if there are no root
* nodes.
*
* @return The first root {@link TreeNode}
*/
protected TreeNode getFirstRootNode() {
if (f0.getWidgetCount() == 0) {
return null;
}
return ((TreeNode) (f0.getWidget(0)));
}
| 3.26 |
framework_VTree_m9_rdh
|
/**
* Tell LayoutManager that a layout is needed later for this VTree
*/
private void m9() {
// This calls LayoutManager setNeedsMeasure and layoutNow
Util.notifyParentOfSizeChange(this, false);
}
| 3.26 |
framework_VTree_doSiblingSelection_rdh
|
/**
* Selects a range of items which have the same parent.
*
* @param startNode
* The start node
* @param endNode
* The end node
*/
private void doSiblingSelection(TreeNode startNode, TreeNode endNode) {
TreeNode v65 = startNode.getParentNode();
List<TreeNode> children;
if
(v65 == null) {
// Topmost parent
children = getRootNodes();
} else {
children = v65.getChildren();
}
// Swap start and end point if needed
if (children.indexOf(startNode) > children.indexOf(endNode)) {
TreeNode temp = startNode;
startNode = endNode;
endNode = temp;
}
boolean v68 = false;
for (TreeNode node : children) {
if (node == startNode) {
v68 = true;
}
if ((v68 && (node != endNode)) && node.m3()) {
selectAllChildren(node, true);
} else if (v68 && (node != endNode)) {
node.setSelected(true);
selectedIds.add(node.key);
}
if (node == endNode) {
node.setSelected(true);
selectedIds.add(node.key);
break;
}
}
selectionHasChanged = true;
}
| 3.26 |
framework_DDUtil_getVerticalDropLocation_rdh
|
/**
* Get vertical drop location.
*
* @param element
* the drop target element
* @param offsetHeight
* the height of an element relative to the layout
* @param clientY
* the y-coordinate of the latest event that relates to this drag
* operation
* @param topBottomRatio
* the ratio that determines how big portion of the element on
* each end counts for indicating desire to drop above or below
* the element rather than on top of it
* @return the drop location
*/
public static VerticalDropLocation getVerticalDropLocation(Element element, int offsetHeight, int clientY, double topBottomRatio) {
// Event coordinates are relative to the viewport, element absolute
// position is relative to the document. Make element position relative
// to viewport by adjusting for viewport scrolling. See #6021
int
elementTop = element.getAbsoluteTop() - Window.getScrollTop();
int fromTop = clientY - elementTop;
float percentageFromTop = fromTop / ((float) (offsetHeight));
if (percentageFromTop < topBottomRatio) {
return VerticalDropLocation.TOP;
} else if (percentageFromTop
> (1 - topBottomRatio)) {
return VerticalDropLocation.BOTTOM;
} else {return VerticalDropLocation.MIDDLE;
}
}
| 3.26 |
framework_DDUtil_getHorizontalDropLocation_rdh
|
/**
* Get horizontal drop location.
*
* @param element
* the drop target element
* @param event
* the latest {@link NativeEvent} that relates to this drag
* operation
* @param leftRightRatio
* the ratio that determines how big portion of the element on
* each end counts for indicating desire to drop beside the
* element rather than on top of it
* @return the drop location
*/
public static HorizontalDropLocation getHorizontalDropLocation(Element element, NativeEvent event, double leftRightRatio) {
int clientX = WidgetUtil.getTouchOrMouseClientX(event);
// Event coordinates are relative to the viewport, element absolute
// position is relative to the document. Make element position relative
// to viewport by adjusting for viewport scrolling. See #6021
int elementLeft = element.getAbsoluteLeft() - Window.getScrollLeft();
int
offsetWidth = element.getOffsetWidth();
int fromLeft = clientX - elementLeft;
float percentageFromLeft = fromLeft / ((float) (offsetWidth));
if (percentageFromLeft < leftRightRatio) {
return HorizontalDropLocation.LEFT;
} else if (percentageFromLeft > (1 - leftRightRatio)) {
return HorizontalDropLocation.RIGHT;
} else {
return HorizontalDropLocation.CENTER;
}
}
| 3.26 |
framework_ColorChangeEvent_getColor_rdh
|
/**
* Returns the new color.
*/
public Color getColor() {
return f0;
}
| 3.26 |
framework_LegacyApplicationUIProvider_getExistingUI_rdh
|
/**
* Hack used to return existing LegacyWindow instances without regard for
* out-of-sync problems.
*
* @param event
* @return */
public UI getExistingUI(UIClassSelectionEvent event) {
UI uiInstance = getUIInstance(event);
if ((uiInstance == null) || (uiInstance.getUIId() == (-1))) {
// Not initialized -> Let go through createUIInstance to make it
// initialized
return null;
}
else {
UI.setCurrent(uiInstance);
return uiInstance;
}
}
| 3.26 |
framework_BrowserInfo_getWebkitVersion_rdh
|
/**
* Returns the WebKit version if the browser is WebKit based. The WebKit
* version returned is the major version e.g., 523.
*
* @return The WebKit version or -1 if the browser is not WebKit based
*/
public float getWebkitVersion() {
if (!browserDetails.isWebKit()) {return -1;
}
return browserDetails.getBrowserEngineVersion();
}
| 3.26 |
framework_BrowserInfo_isIOS6_rdh
|
/**
* Checks if the browser is run on iOS 6.
*
* @since 7.1.1
* @return true if the browser is run on iOS 6, false otherwise
*/
public boolean isIOS6() {
return isIOS() && (getOperatingSystemMajorVersion() == 6);
}
| 3.26 |
framework_BrowserInfo_getBrowserVersion_rdh
|
/**
* Gets the complete browser version in form of a string. The version is
* given by the browser through the user agent string and usually consists
* of dot-separated numbers. Note that the string may contain characters
* other than dots and digits.
*
* @return the complete browser version or {@code null} if unknown
* @since 8.4
*/
public String getBrowserVersion() {return browserDetails.getBrowserVersion();
}
| 3.26 |
framework_BrowserInfo_getBrowserMinorVersion_rdh
|
/**
* Returns the browser minor version e.g., 5 for Firefox 3.5.
*
* @see #getBrowserMajorVersion()
* @return The minor version of the browser, or -1 if not known/parsed.
*/
public int getBrowserMinorVersion() {
return browserDetails.getBrowserMinorVersion();
}
| 3.26 |
framework_BrowserInfo_isSafariOrIOS_rdh
|
/**
* Returns true if the browser is Safari or is a browser that is running on
* iOS and using the Safari rendering engine.
*
* @return true if the browser is using the Safari rendering engine
* @since 8.1
*/public boolean isSafariOrIOS() {
return browserDetails.isSafariOrIOS();
}
| 3.26 |
framework_BrowserInfo_getBrowserMajorVersion_rdh
|
/**
* Returns the browser major version e.g., 3 for Firefox 3.5, 4 for Chrome
* 4, 8 for Internet Explorer 8.
* <p>
* Note that Internet Explorer 8 and newer will return the document mode so
* IE8 rendering as IE7 will return 7.
* </p>
*
* @return The major version of the browser.
*/
public int getBrowserMajorVersion() {
return browserDetails.getBrowserMajorVersion();
}
| 3.26 |
framework_BrowserInfo_getCSSClass_rdh
|
/**
* Returns a string representing the browser in use, for use in CSS
* classnames. The classnames will be space separated abbreviations,
* optionally with a version appended.
*
* Abbreviations: Firefox: ff Internet Explorer: ie Safari: sa Opera: op
*
* Browsers that CSS-wise behave like each other will get the same
* abbreviation (this usually depends on the rendering engine).
*
* This is quite simple at the moment, more heuristics will be added when
* needed.
*
* Examples: Internet Explorer 6: ".v-ie .v-ie6 .v-ie60", Firefox 3.0.4:
* ".v-ff .v-ff3 .v-ff30", Opera 9.60: ".v-op .v-op9 .v-op960", Opera 10.10:
* ".v-op .v-op10 .v-op1010"
*
* @return */
public String getCSSClass() { String prefix = "v-";
if (cssClass == null) {
String browserIdentifier = "";
String majorVersionClass =
"";
String minorVersionClass = "";
String browserEngineClass = "";
if (browserDetails.isFirefox()) {
browserIdentifier = BROWSER_FIREFOX;
majorVersionClass = browserIdentifier + getBrowserMajorVersion();
minorVersionClass = majorVersionClass + browserDetails.getBrowserMinorVersion();
browserEngineClass = ENGINE_GECKO;
} else if (browserDetails.isChrome()) {
// TODO update when Chrome is more stable
browserIdentifier = BROWSER_SAFARI;
majorVersionClass = "ch";
browserEngineClass = ENGINE_WEBKIT;
} else if (browserDetails.isSafari()) {
browserIdentifier = BROWSER_SAFARI;
majorVersionClass = browserIdentifier + getBrowserMajorVersion();
minorVersionClass = majorVersionClass + browserDetails.getBrowserMinorVersion();
browserEngineClass = ENGINE_WEBKIT;} else if (browserDetails.isPhantomJS()) {
// Safari needed for theme
browserIdentifier = BROWSER_SAFARI;
majorVersionClass = browserIdentifier + getBrowserMajorVersion();
minorVersionClass = majorVersionClass + browserDetails.getBrowserMinorVersion();
browserEngineClass = ENGINE_WEBKIT;
} else if (browserDetails.isIE())
{
browserIdentifier = BROWSER_IE;
majorVersionClass = browserIdentifier + getBrowserMajorVersion();minorVersionClass = majorVersionClass + browserDetails.getBrowserMinorVersion();
browserEngineClass = f0;
} else if (browserDetails.isEdge()) {
browserIdentifier = BROWSER_EDGE;
majorVersionClass = browserIdentifier + getBrowserMajorVersion();minorVersionClass = majorVersionClass + browserDetails.getBrowserMinorVersion();
browserEngineClass =
"";
} else if (browserDetails.isOpera()) {
browserIdentifier = BROWSER_OPERA;
majorVersionClass = browserIdentifier + getBrowserMajorVersion();
minorVersionClass
= majorVersionClass + browserDetails.getBrowserMinorVersion();
browserEngineClass = ENGINE_PRESTO;
}
cssClass = prefix + browserIdentifier;
if (!majorVersionClass.isEmpty()) {
cssClass = ((cssClass + " ") + prefix) + majorVersionClass;
}
if (!minorVersionClass.isEmpty()) {
cssClass = ((cssClass + " ") + prefix) + minorVersionClass;
}
if (!browserEngineClass.isEmpty()) {
cssClass = ((cssClass + " ") + prefix) + browserEngineClass;
}
String osClass = getOperatingSystemClass();
if (osClass != null)
{
cssClass = (cssClass + " ") + osClass;
}
if (isTouchDevice()) {cssClass = ((cssClass + " ") + prefix) + f1;
}
}
return cssClass;
}
| 3.26 |
framework_BrowserInfo_get_rdh
|
/**
* Singleton method to get BrowserInfo object.
*
* @return instance of BrowserInfo object
*/
public static BrowserInfo get() {
if (instance == null) {
instance = new BrowserInfo();
}
return
instance;}
| 3.26 |
framework_BrowserInfo_isTouchDevice_rdh
|
/**
*
* @return true if the browser runs on a touch based device.
*/
public boolean isTouchDevice() {
return touchDevice;
}
| 3.26 |
framework_BrowserInfo_getGeckoVersion_rdh
|
/**
* Returns the Gecko version if the browser is Gecko based. The Gecko
* version for Firefox 2 is 1.8 and 1.9 for Firefox 3.
*
* @return The Gecko version or -1 if the browser is not Gecko based
*/
public float
getGeckoVersion() {
if (!browserDetails.isGecko()) {
return -1;
}
return browserDetails.getBrowserEngineVersion();
}
| 3.26 |
framework_VDateField_setDate_rdh
|
/**
* Sets the current date for this VDateField.
*
* @param date
* The new date to use
*/
protected void setDate(Date date) {
this.date = date;
}
| 3.26 |
framework_VDateField_setCurrentLocale_rdh
|
/**
* Sets the locale String.
*
* @param currentLocale
* the new locale String.
*/
public void setCurrentLocale(String currentLocale) {
this.currentLocale = currentLocale;
}
| 3.26 |
framework_VDateField_getResolutionVariable_rdh
|
/**
* Returns a resolution variable name for the given {@code resolution}.
*
* @param resolution
* the given resolution
* @return the resolution variable name
*/
public String getResolutionVariable(R resolution) {
return resolution.name().toLowerCase(Locale.ROOT);
}
| 3.26 |
framework_VDateField_setCurrentDate_rdh
|
/**
* Set the current date using a map with date values.
* <p>
* The map contains integer representation of values per resolution. The
* method should construct a date based on the map and set it via
* {@link #setCurrentDate(Date)}
*
* @param dateValues
* a map with date values to convert into a date
*/
public void setCurrentDate(Map<R, Integer> dateValues) {
setCurrentDate(getDate(dateValues));
}
| 3.26 |
framework_VDateField_getDefaultDate_rdh
|
/**
* Sets the default date when no date is selected.
*
* @return the default date
* @since 8.1.2
*/
public Date getDefaultDate() {
return defaultDate;}
| 3.26 |
framework_VDateField_getDate_rdh
|
/**
* Returns a copy of the current date. Modifying the returned date will not
* modify the value of this VDateField. Use {@link #setDate(Date)} to change
* the current date.
* <p>
* For internal use only. May be removed or replaced in the future.
*
* @return A copy of the current date
*/
public Date getDate() {
Date current = getCurrentDate();
if (current == null) { return null;
} else {
return ((Date)
(getCurrentDate().clone()));
}
}
| 3.26 |
framework_VDateField_m0_rdh
|
/**
* Sets the resolution.
*
* @param currentResolution
* the new resolution
*/
public void m0(R currentResolution) {
this.currentResolution = currentResolution;
}
| 3.26 |
framework_VDateField_getCurrentLocale_rdh
|
/**
* Returns the current locale String.
*
* @return the locale String
*/public String getCurrentLocale() {
return currentLocale; }
| 3.26 |
framework_VDateField_getClient_rdh
|
/**
* Returns the current application connection.
*
* @return the application connection
*/
public ApplicationConnection getClient() {
return client;
}
/**
* Returns whether ISO 8601 week numbers should be shown in the date
* selector or not. ISO 8601 defines that a week always starts with a Monday
* so the week numbers are only shown if this is the case.
*
* @return {@code true} if week number should be shown, {@code false}
| 3.26 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.