code
stringlengths
73
34.1k
label
stringclasses
1 value
private CumulativeTravels getCumulativeTravels( BudgetSummaryDto budgetSummaryData) { CumulativeTravels cumulativeTravels = CumulativeTravels.Factory .newInstance(); if (budgetSummaryData.getCumDomesticTravel() != null) { cumulativeTravels .setCumulativeDomesticTravelCosts(budgetSummaryData .g...
java
private OtherPersonnel getOtherPersonnel(BudgetPeriodDto periodInfo) { OtherPersonnel otherPersonnel = OtherPersonnel.Factory.newInstance(); int OtherpersonalCount = 0; List<OtherPersonnelDataType> otherPersonnelList = new ArrayList<>(); OtherPersonnelDataType otherPersonnelDataTypeArray[] = new OtherPersonnelD...
java
private Equipment getEquipment(BudgetPeriodDto periodInfo) { Equipment equipment = Equipment.Factory.newInstance(); NarrativeContract extraEquipmentNarr = null; if (periodInfo != null && periodInfo.getEquipment() != null && periodInfo.getEquipment().size() > 0) { // Evaluating Equipments. List<Equipment...
java
private Travel getTravel(BudgetPeriodDto periodInfo) { Travel travel = Travel.Factory.newInstance(); if (periodInfo != null) { if (periodInfo.getDomesticTravelCost() != null) { travel.setDomesticTravelCost(periodInfo.getDomesticTravelCost() .bigDecimalValue()); } if (periodInfo.getForeignTravelC...
java
private ParticipantTraineeSupportCosts getParticipantTraineeSupportCosts( BudgetPeriodDto periodInfo) { ParticipantTraineeSupportCosts traineeSupportCosts = ParticipantTraineeSupportCosts.Factory .newInstance(); if (periodInfo != null) { traineeSupportCosts.setTuitionFeeHealthInsurance(periodInfo .ge...
java
public static Window showXML(Document document, BaseUIComponent parent) { Map<String, Object> args = Collections.singletonMap("document", document); boolean modal = parent == null; Window dialog = PopupDialog.show(XMLConstants.VIEW_DIALOG, args, modal, modal, modal, null); if (p...
java
public static Window showCWF(BaseComponent root, String... excludedProperties) { Window window = showXML(CWF2XML.toDocument(root, excludedProperties)); window.setTitle("CWF Markup"); return window; }
java
public static void setAttribute(String key, Object value) { assertInitialized(); getAppFramework().setAttribute(key, value); }
java
@Override public void afterInitialized(BaseComponent comp) { super.afterInitialized(comp); PluginContainer container = comp.getAncestor(PluginContainer.class, true); plugin = (ElementPlugin) ElementUI.getAssociatedElement(container); }
java
public void attachController(BaseComponent comp, IAutoWired controller) { plugin.tryRegisterListener(controller, true); comp.wireController(controller); }
java
@Override protected IAbortable removeThread(IAbortable thread) { super.removeThread(thread); if (!hasActiveThreads()) { showBusy(null); } return thread; }
java
public static void bindActionListeners(IActionTarget target, List<ActionListener> actionListeners) { if (actionListeners != null) { for (ActionListener actionListener : actionListeners) { actionListener.bind(target); } } }
java
public static void unbindActionListeners(IActionTarget target, List<ActionListener> actionListeners) { if (actionListeners != null) { for (ActionListener listener : actionListeners) { listener.unbind(target); } } }
java
@Override public void eventCallback(String eventName, Object eventData) { for (IActionTarget target : new ArrayList<>(targets)) { try { target.doAction(action); } catch (Throwable t) { } } }
java
private void bind(IActionTarget target) { if (targets.isEmpty()) { getEventManager().subscribe(eventName, this); } targets.add(target); }
java
private void unbind(IActionTarget target) { if (targets.remove(target) && targets.isEmpty()) { getEventManager().unsubscribe(eventName, this); } }
java
private synchronized LinkedHashSet<IMessageCallback> getCallbacks(String channel, boolean autoCreate, boolean clone) { LinkedHashSet<IMessageCallback> result = callbacks.get(channel); if (result == null && autoCreate) { callbacks.put(channel, result = new LinkedHashSet<>()); ...
java
@Override public void onMessage(String channel, Message message) { if (MessageUtil.isMessageExcluded(message, RecipientType.CONSUMER, nodeId)) { return; } if (updateDelivered(message)) { LinkedHashSet<IMessageCallback> callbacks = getCallbacks(channel, false,...
java
private boolean updateDelivered(Message message) { if (consumers.size() <= 1) { return true; } String pubid = (String) message.getMetadata("cwf.pub.event"); return deliveredMessageCache.putIfAbsent(pubid, "") == null; }
java
protected void dispatchMessages(String channel, Message message, Set<IMessageCallback> callbacks) { for (IMessageCallback callback : callbacks) { try { callback.onMessage(channel, message); } catch (Exception e) { } } }
java
private void updateStyle() { CaptionStyle cs = captionStyle == null ? CaptionStyle.HIDDEN : captionStyle; String background = null; switch (cs) { case FRAME: break; case TITLE: break; case LEFT...
java
static List<TaskGroupInformation> getPath(TaskGroupFactoryMakerService imf, TaskSystemInformation def, String locale) throws TaskSystemException { Set<TaskGroupInformation> specs = imf.list(locale); Map<String, List<TaskGroupInformation>> byInput = byInput(specs); return getPathSpecifications(def.getInputType()....
java
public void addToolbarComponent(BaseComponent component, String action) { BaseComponent ref = toolbar.getFirstChild(); if (component instanceof Toolbar) { BaseComponent child; while ((child = component.getFirstChild()) != null) { toolbar.addC...
java
protected String extractAttribute(String name, String line) { int i = line.indexOf(name + "=\""); i = i == -1 ? i : i + name.length() + 2; int j = i == -1 ? -1 : line.indexOf("\"", i); return j == -1 ? null : line.substring(i, j); }
java
protected void write(OutputStream outputStream, String data, boolean terminate, int level) { try { if (data != null) { if (level > 0) { outputStream.write(StringUtils.repeat(" ", level).getBytes(CS_UTF8)); } output...
java
public synchronized void closeAll() { for (Window window : windows) { try { window.removeEventListener("close", this); window.destroy(); } catch (Throwable e) { } } windows.clear(); resetPositio...
java
@SuppressWarnings("deprecation") @Override public void eventCallback(String eventName, Object eventData) { try { PopupData popupData = null; if (eventData instanceof PopupData) { popupData = (PopupData) eventData; } else { ...
java
private synchronized Window getPopupWindow() throws Exception { if (popupDefinition == null) { popupDefinition = PageParser.getInstance().parse(RESOURCE_PREFIX + "popupWindow.fsp"); } Window window = (Window) popupDefinition.materialize(null); windows.add(window); ...
java
@SuppressWarnings("unchecked") @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (clazz.isInstance(bean)) { register((V) bean); } return bean; }
java
@SuppressWarnings("unchecked") @Override public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException { if (clazz.isInstance(bean)) { unregister((V) bean); } }
java
public void loadChoices(Iterable<String> choices) { clear(); if (choices != null) { for (String choice : choices) { addChoice(choice, false); } } checkSelection(true); }
java
public Dateitem addChoice(DateRange range, boolean isCustom) { Dateitem item; if (isCustom) { item = findMatchingItem(range); if (item != null) { return item; } } item = new Dateitem(); item.setLab...
java
public Dateitem findMatchingItem(DateRange range) { for (BaseComponent item : getChildren()) { if (range.equals(item.getData())) { return (Dateitem) item; } } return null; }
java
public Dateitem findMatchingItem(String label) { for (BaseComponent child : getChildren()) { Dateitem item = (Dateitem) child; if (label.equalsIgnoreCase(item.getLabel())) { return item; } } return null; }
java
private void checkSelection(boolean suppressEvent) { Dateitem selectedItem = getSelectedItem(); if (selectedItem == null) { selectedItem = lastSelectedItem; setSelectedItem(selectedItem); } else if (selectedItem != customItem && lastSelectedItem != selectedItem) ...
java
private void updateSelection() { Dateitem selectedItem = getSelectedItem(); if (selectedItem == null) { addStyle("color", "gray"); } else { addStyle("color", "inherit"); } setFocus(false); }
java
@EventHandler("change") private void onChange(ChangeEvent event) { // When the custom range item is selected, triggers the display of the date range dialog. if (event.getRelatedTarget() == customItem) { event.stopPropagation(); DateRangeDialog.show((range) -> { ...
java
private String getAttribute(BeanDefinition beanDefinition, String attributeName) { String value = null; while (beanDefinition != null) { value = (String) beanDefinition.getAttribute(attributeName); if (value != null) { break; } ...
java
public static String getValue(String propertyName, String instanceName) { return getPropertyService().getValue(propertyName, instanceName); }
java
public static List<String> getValues(String propertyName, String instanceName) { return getPropertyService().getValues(propertyName, instanceName); }
java
public static void saveValue(String propertyName, String instanceName, boolean asGlobal, String value) { getPropertyService().saveValue(propertyName, instanceName, asGlobal, value); }
java
public static void saveValues(String propertyName, String instanceName, boolean asGlobal, List<String> value) { getPropertyService().saveValues(propertyName, instanceName, asGlobal, value); }
java
public static List<String> getInstances(String propertyName, boolean asGlobal) { return getPropertyService().getInstances(propertyName, asGlobal); }
java
private void sendRequest(String methodName, Object... params) { sendRequest(new InvocationRequest(methodName, params), true); }
java
private void sendRequest(InvocationRequest helpRequest, boolean startRemoteViewer) { this.helpRequest = helpRequest; if (helpRequest != null) { if (remoteViewerActive()) { remoteQueue.sendRequest(helpRequest); this.helpRequest = null; } el...
java
public void setRemoteQueue(InvocationRequestQueue remoteQueue) { this.remoteQueue = remoteQueue; InvocationRequest deferredRequest = helpRequest; sendRequest(loadRequest, false); sendRequest(deferredRequest, false); }
java
public static Class<? extends IHelpSet> register(Class<? extends IHelpSet> clazz, String formats) { for (String type : formats.split("\\,")) { instance.map.put(type, clazz); } return clazz; }
java
public static IHelpSet create(HelpModule module) { try { Class<? extends IHelpSet> clazz = instance.map.get(module.getFormat()); if (clazz == null) { throw new Exception("Unsupported help format: " + module.getFormat()); } ...
java
public BaseRedisQueue<ID, DATA> setRedisHashName(String redisHashName) { _redisHashName = redisHashName; this.redisHashName = _redisHashName.getBytes(QueueUtils.UTF8); return this; }
java
public BaseRedisQueue<ID, DATA> setRedisListName(String redisListName) { _redisListName = redisListName; this.redisListName = _redisListName.getBytes(QueueUtils.UTF8); return this; }
java
public BaseRedisQueue<ID, DATA> setRedisSortedSetName(String redisSortedSetName) { _redisSortedSetName = redisSortedSetName; this.redisSortedSetName = _redisSortedSetName.getBytes(QueueUtils.UTF8); return this; }
java
public void addEntry(String placeholder, String... params) { ConfigEntry entry = entries.get(placeholder); String line = entry.template; for (int i = 0; i < params.length; i++) { line = line.replace("{" + i + "}", StringUtils.defaultString(params[i])); } entry.buffe...
java
protected void createFile(File stagingDirectory) throws MojoExecutionException { File targetDirectory = newSubdirectory(stagingDirectory, "META-INF"); File newEntry = new File(targetDirectory, filename); try (FileOutputStream out = new FileOutputStream(newEntry); PrintStream ps = new PrintStrea...
java
private File newSubdirectory(File parentDirectory, String path) { File dir = new File(parentDirectory, path); if (!dir.exists()) { dir.mkdirs(); } return dir; }
java
@Override public void destroy() { shell.unregisterPlugin(this); executeAction(PluginAction.UNLOAD, false); CommandUtil.dissociateAll(container); if (pluginEventListeners1 != null) { pluginEventListeners1.clear(); pluginEventListeners1 = null; } ...
java
@Override public Object getPropertyValue(PropertyInfo propInfo) throws Exception { Object obj = registeredProperties == null ? null : registeredProperties.get(propInfo.getId()); if (obj instanceof PropertyProxy) { Object value = ((PropertyProxy) obj).getValue(); return value...
java
@Override public void setPropertyValue(PropertyInfo propInfo, Object value) throws Exception { String propId = propInfo.getId(); Object obj = registeredProperties == null ? null : registeredProperties.get(propId); if (obj == null) { obj = new PropertyProxy(propInfo, value); ...
java
@Override protected void updateVisibility(boolean visible, boolean activated) { super.updateVisibility(visible, activated); if (registeredComponents != null) { for (BaseUIComponent component : registeredComponents) { if (!visible) { component.setAttri...
java
@Override public void setDefinition(PluginDefinition definition) { super.setDefinition(definition); if (definition != null) { container.addClass("cwf-plugin-" + definition.getId()); shell.registerPlugin(this); } }
java
public void setBusy(String message) { busyMessage = message = StrUtil.formatMessage(message); if (busyDisabled) { busyPending = true; } else if (message != null) { disableActions(true); ClientUtil.busy(container, message); busyPending = !isVisible...
java
private void executeAction(PluginAction action, boolean async, Object data) { if (hasListeners() || action == PluginAction.LOAD) { PluginEvent event = new PluginEvent(this, action, data); if (async) { EventUtil.post(event); } else { onAction(e...
java
@EventHandler("action") private void onAction(PluginEvent event) { PluginException exception = null; PluginAction action = event.getAction(); boolean debug = log.isDebugEnabled(); if (pluginEventListeners1 != null) { for (IPluginEvent listener : new ArrayList<>(pluginEve...
java
@EventHandler("command") private void onCommand(CommandEvent event) { if (isEnabled()) { for (BaseComponent child : container.getChildren()) { EventUtil.send(event, child); if (event.isStopped()) { break; } } ...
java
private PluginException createChainedException(String action, Throwable newException, PluginException previousException) { String msg = action + " event generated an error."; log.error(msg, newException); PluginException wrapper = new PluginExce...
java
public void load() { PluginDefinition definition = getDefinition(); if (!initialized && definition != null) { BaseComponent top; try { initialized = true; top = container.getFirstChild(); if (top == null) { to...
java
public void addToolbarComponent(BaseComponent component) { if (tbarContainer == null) { tbarContainer = new ToolbarContainer(); shell.addToolbarComponent(tbarContainer); registerComponent(tbarContainer); } tbarContainer.addChild(component); }
java
public void registerId(String id, BaseComponent component) { if (!StringUtils.isEmpty(id) && !container.hasAttribute(id)) { container.setAttribute(id, component); } }
java
public void registerListener(IPluginEvent listener) { if (pluginEventListeners1 == null) { pluginEventListeners1 = new ArrayList<>(); } if (!pluginEventListeners1.contains(listener)) { pluginEventListeners1.add(listener); } }
java
public void registerListener(IPluginEventListener listener) { if (pluginEventListeners2 == null) { pluginEventListeners2 = new ArrayList<>(); } if (!pluginEventListeners2.contains(listener)) { pluginEventListeners2.add(listener); listener.onPluginEvent(new Pl...
java
public void unregisterListener(IPluginEventListener listener) { if (pluginEventListeners2 != null && pluginEventListeners2.contains(listener)) { pluginEventListeners2.remove(listener); listener.onPluginEvent(new PluginEvent(this, PluginAction.UNSUBSCRIBE)); } }
java
public boolean tryRegisterListener(Object object, boolean register) { boolean success = false; if (object instanceof IPluginEvent) { if (register) { registerListener((IPluginEvent) object); } else { unregisterListener((IPluginEvent) object); ...
java
public void tryRegisterController(Object object) { if (object instanceof IPluginController) { if (pluginControllers == null) { pluginControllers = new ArrayList<>(); } pluginControllers.add((IPluginController) object); } }
java
public void registerProperties(Object instance, String... propertyNames) { for (String propertyName : propertyNames) { registerProperty(instance, propertyName, true); } }
java
public void registerProperty(Object instance, String propertyName, boolean override) { if (registeredProperties == null) { registeredProperties = new HashMap<>(); } if (instance == null) { registeredProperties.remove(propertyName); } else { Object old...
java
public void registerBean(String beanId, boolean isRequired) { if (beanId == null || beanId.isEmpty()) { return; } Object bean = SpringUtil.getBean(beanId); if (bean == null && isRequired) { throw new PluginException("Required bean resouce not found: " + beanId);...
java
@Override public void setPropertyValue(PropertyInfo propInfo, Object value) { setPropertyValue(propInfo.getId(), value); }
java
public ElementBase realize(ElementBase parent) { if (!deleted && real == null) { real = getDefinition().createElement(parent, null, false); } else if (deleted && real != null) { real.remove(true); real = null; } return real; }
java
private void syncProperties(boolean fromReal) { PluginDefinition def = getDefinition(); for (PropertyInfo propInfo : def.getProperties()) { if (fromReal) { syncProperty(propInfo, real, this); } else { syncProperty(propInfo, this, real); ...
java
@Override public String execute(@SuppressWarnings("rawtypes") Map parameters, String body, RenderContext renderContext) throws MacroException { try { return body; } catch (Exception e) { return getErrorView("greenpepper.info.macroid", e.getMessage...
java
@Override public String execute(Map<String, String> parameters, String body, ConversionContext context) throws MacroExecutionException { try { String xhtmlRendered = gpUtil.getWikiStyleRenderer().convertWikiToXHtml(context.getPageContext(), body); LO...
java
private void saveLastFetchedId(byte[] lastFetchedId) { if (lastFetchedId != null) { rocksDbWrapper.put(cfNameMetadata, writeOptions, keyLastFetchedId, lastFetchedId); } }
java
public static HelpViewBase createView(HelpViewer viewer, HelpViewType viewType) { Class<? extends HelpViewBase> viewClass = viewType == null ? null : getViewClass(viewType); if (viewClass == null) { return null; } try { return viewClass.getConstr...
java
private static Class<? extends HelpViewBase> getViewClass(HelpViewType viewType) { switch (viewType) { case TOC: return HelpViewContents.class; case KEYWORD: return HelpViewIndex.class; case INDEX: retu...
java
private static int computeCapacity(final int expectedSize) { if (expectedSize == 0) { return 1; } final int capacity = (int) InternalFastMath.ceil(expectedSize / LOAD_FACTOR); final int powerOfTwo = Integer.highestOneBit(capacity); if (powerOfTwo == capacity) { ...
java
public boolean contains(final long key) { final int hash = hashOf(key); int index = hash & mask; if (contains(key, index)) { return true; } if (states[index] == FREE) { return false; } int j = index; for (int perturb = perturb(h...
java
private static int findInsertionIndex(final long[] keys, final byte[] states, final long key, final int mask) { final int hash = hashOf(key); int index = hash & mask; if (states[index] == FREE) { return index; } else if (states[index]...
java
public void clear() { final int capacity = keys.length; Arrays.fill(keys, 0); Arrays.fill(values, 0); Arrays.fill(states, FREE); size = 0; mask = capacity - 1; count = 0; }
java
private static void swap(long[] values, int[] index, int i, int j) { if (i != j) { swap(values, i, j); swap(index, i, j); numSwaps ++; } }
java
public static IntTuple getArgmax(float[][] array, float delta) { float maxValue = Float.NEGATIVE_INFINITY; int maxX = -1; int maxY = -1; float numMax = 1; for (int x=0; x<array.length; x++) { for (int y=0; y<array[x].length; y++) { float diff = Primiti...
java
public static int count(float[] array, float val) { int count = 0; for (int i=0; i<array.length; i++) { if (array[i] == val) { count++; } } return count; }
java
public static Collection<OrderedPair> sampleOrderedPairs(int minI, int maxI, int minJ, int maxJ, double prop) { int numI = maxI - minI; int numJ = maxJ - minJ; // Count the max number possible: long maxPairs = numI * numJ; Collection<OrderedPair> sample...
java
public static Collection<UnorderedPair> sampleUnorderedPairs(int minI, int maxI, int minJ, int maxJ, double prop) { int numI = maxI - minI; int numJ = maxJ - minJ; // Count the max number possible: long maxPairs = PairSampler.countUnorderedPairs(minI, maxI, minJ, maxJ);...
java
public void setActive(boolean active) { refreshListener.setActive(active); addListener.setActive(active); removeListener.setActive(active); eventManager.fireRemoteEvent(active ? addListener.eventName : removeListener.eventName, self); if (active) { refresh();...
java
public void init() { if (manifests == null) { manifests = new ArrayList<>(); try { primaryManifest = addToList(applicationContext.getResource(MANIFEST_PATH)); Resource[] resources = applicationContext.getResources("classpath*:/" + MANIFEST_PAT...
java
public Manifest findByPath(String path) { for (Manifest manifest : this) { String mpath = ((ManifestEx) manifest).path; if (path.startsWith(mpath)) { return manifest; } } return null; }
java
private Manifest addToList(Resource resource) { try { if (resource != null && resource.exists()) { Manifest manifest = new ManifestEx(resource); manifests.add(manifest); return manifest; } } catch (Exception e) { log.deb...
java
protected void putToQueue(IQueueMessage<ID, DATA> msg) throws QueueException.QueueIsFull { if (!queue.offer(msg)) { throw new QueueException.QueueIsFull(getBoundary()); } }
java
protected String getType(String script) { int i = script.indexOf(':'); return i < 0 ? "" : script.substring(0, i); }
java
@Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { propertyProvider = new PropertyProvider(applicationContext); conversionService = DefaultConversionService.getSharedInstance(); wireParams(this); afterInitialized(); }
java
void initConfigs(String propertiesAbsoluteClassPath) { this.propertiesAbsoluteClassPath = propertiesAbsoluteClassPath; this.propertiesFilePath = ResourceUtil.getAbsolutePath(propertiesAbsoluteClassPath); loadConfigs(); }
java