List of usage examples for java.util HashMap size
int size
To view the source code for java.util HashMap size.
Click Source Link
From source file:com.thoughtworks.go.server.service.RulesService.java
public boolean validateSecretConfigReferences(ScmMaterial scmMaterial) { List<CaseInsensitiveString> pipelines = goConfigService.pipelinesWithMaterial(scmMaterial.getFingerprint()); HashMap<CaseInsensitiveString, StringBuilder> pipelinesWithErrors = new HashMap<>(); pipelines.forEach(pipelineName -> { MaterialConfig materialConfig = goConfigService.findPipelineByName(pipelineName).materialConfigs() .getByMaterialFingerPrint(scmMaterial.getFingerprint()); PipelineConfigs group = goConfigService.findGroupByPipeline(pipelineName); ScmMaterialConfig scmMaterialConfig = (ScmMaterialConfig) materialConfig; SecretParams secretParams = SecretParams.parse(scmMaterialConfig.getPassword()); secretParams.forEach(secretParam -> { String secretConfigId = secretParam.getSecretConfigId(); SecretConfig secretConfig = goConfigService.getSecretConfigById(secretConfigId); if (secretConfig == null) { addError(pipelinesWithErrors, pipelineName, format("Pipeline '%s' is referring to none-existent secret config '%s'.", pipelineName, secretConfigId)); } else if (!secretConfig.canRefer(group.getClass(), group.getGroup())) { addError(pipelinesWithErrors, pipelineName, format( "Pipeline '%s' does not have permission to refer to secrets using secret config '%s'", pipelineName, secretConfigId)); }//from w ww . j a v a 2s . c o m }); }); StringBuilder errorMessage = new StringBuilder(); if (!pipelinesWithErrors.isEmpty()) { errorMessage.append(StringUtils.join(pipelinesWithErrors.values(), '\n').trim()); LOGGER.error("[Material Update] Failure: {}", errorMessage.toString()); } if (pipelines.size() == pipelinesWithErrors.size()) { throw new RulesViolationException(errorMessage.toString()); } return true; }
From source file:com.piusvelte.sonet.core.SonetCreatePost.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); if (itemId == R.id.menu_post_accounts) chooseAccounts();/*from w ww . j a v a 2 s . c o m*/ else if (itemId == R.id.menu_post_photo) { boolean supported = false; Iterator<Integer> services = mAccountsService.values().iterator(); while (services.hasNext() && ((supported = sPhotoSupported.contains(services.next())) == false)) ; if (supported) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select Picture"), PHOTO); } else unsupportedToast(sPhotoSupported); // } else if (itemId == R.id.menu_post_tags) { // if (mAccountsService.size() == 1) { // if (sTaggingSupported.contains(mAccountsService.values().iterator().next())) // selectFriends(mAccountsService.keySet().iterator().next()); // else // unsupportedToast(sTaggingSupported); // } else { // // dialog to select an account // Iterator<Long> accountIds = mAccountsService.keySet().iterator(); // HashMap<Long, String> accountEntries = new HashMap<Long, String>(); // while (accountIds.hasNext()) { // Long accountId = accountIds.next(); // Cursor account = this.getContentResolver().query(Accounts.getContentUri(this), new String[]{Accounts._ID, ACCOUNTS_QUERY}, Accounts._ID + "=?", new String[]{Long.toString(accountId)}, null); // if (account.moveToFirst() && sTaggingSupported.contains(mAccountsService.get(accountId))) // accountEntries.put(account.getLong(0), account.getString(1)); // } // int size = accountEntries.size(); // if (size != 0) { // final long[] accountIndexes = new long[size]; // final String[] accounts = new String[size]; // int i = 0; // Iterator<Map.Entry<Long, String>> entries = accountEntries.entrySet().iterator(); // while (entries.hasNext()) { // Map.Entry<Long, String> entry = entries.next(); // accountIndexes[i] = entry.getKey(); // accounts[i++] = entry.getValue(); // } // mDialog = (new AlertDialog.Builder(this)) // .setTitle(R.string.accounts) // .setSingleChoiceItems(accounts, -1, new DialogInterface.OnClickListener() { // @Override // public void onClick(DialogInterface dialog, int which) { // selectFriends(accountIndexes[which]); // dialog.dismiss(); // } // }) // .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { // @Override // public void onClick(DialogInterface dialog, int which) { // dialog.dismiss(); // } // }) // .create(); // mDialog.show(); // } else // unsupportedToast(sTaggingSupported); // } } else if (itemId == R.id.menu_post_location) { LocationManager locationManager = (LocationManager) SonetCreatePost.this .getSystemService(Context.LOCATION_SERVICE); Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); if (location != null) { mLat = Double.toString(location.getLatitude()); mLong = Double.toString(location.getLongitude()); if (mAccountsService.size() == 1) { if (sLocationSupported.contains(mAccountsService.values().iterator().next())) setLocation(mAccountsService.keySet().iterator().next()); else unsupportedToast(sLocationSupported); } else { // dialog to select an account Iterator<Long> accountIds = mAccountsService.keySet().iterator(); HashMap<Long, String> accountEntries = new HashMap<Long, String>(); while (accountIds.hasNext()) { Long accountId = accountIds.next(); Cursor account = this.getContentResolver().query(Accounts.getContentUri(this), new String[] { Accounts._ID, ACCOUNTS_QUERY }, Accounts._ID + "=?", new String[] { Long.toString(accountId) }, null); if (account.moveToFirst() && sLocationSupported.contains(mAccountsService.get(accountId))) accountEntries.put(account.getLong(account.getColumnIndex(Accounts._ID)), account.getString(account.getColumnIndex(Accounts.USERNAME))); } int size = accountEntries.size(); if (size != 0) { final long[] accountIndexes = new long[size]; final String[] accounts = new String[size]; int i = 0; Iterator<Map.Entry<Long, String>> entries = accountEntries.entrySet().iterator(); while (entries.hasNext()) { Map.Entry<Long, String> entry = entries.next(); accountIndexes[i] = entry.getKey(); accounts[i++] = entry.getValue(); } mDialog = (new AlertDialog.Builder(this)).setTitle(R.string.accounts) .setSingleChoiceItems(accounts, -1, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { setLocation(accountIndexes[which]); dialog.dismiss(); } }) .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create(); mDialog.show(); } else unsupportedToast(sLocationSupported); } } else (Toast.makeText(this, getString(R.string.location_unavailable), Toast.LENGTH_LONG)).show(); } return super.onOptionsItemSelected(item); }
From source file:it.classhidra.core.controller.bsController.java
public static Vector getActionStreams_(String id_action) { Vector _streams_orig = (Vector) getAction_config().get_streams_apply_to_actions().get("*"); //Modifica 20100521 Warning /*/*from www . ja v a2s.c om*/ try{ _streams = (Vector)util_cloner.clone(_streams_orig); }catch(Exception e){ } */ Vector _streams4action = (Vector) getAction_config().get_streams_apply_to_actions().get(id_action); if (_streams4action == null) return (_streams_orig == null) ? new Vector() : _streams_orig; else { Vector _streams = new Vector(); if (_streams_orig != null) _streams.addAll(_streams_orig); Vector _4add = new Vector(); HashMap _4remove = new HashMap(); for (int i = 0; i < _streams4action.size(); i++) { info_stream currentis = (info_stream) _streams4action.get(i); if (currentis.get_apply_to_action() != null) { info_apply_to_action currentiata = (info_apply_to_action) currentis.get_apply_to_action() .get(id_action); if (currentiata.getExcluded() != null && currentiata.getExcluded().equalsIgnoreCase("true")) _4remove.put(currentis.getName(), currentis.getName()); else _4add.add(currentis); } } _streams.addAll(_4add); if (_4remove.size() > 0) { int i = 0; while (i < _streams.size()) { info_stream currentis = (info_stream) _streams.get(i); if (_4remove.get(currentis.getName()) != null) _streams.remove(i); else i++; } } _streams = new util_sort().sort(_streams, "int_order", "A"); return _streams; } }
From source file:com.google.gwt.emultest.java.util.HashMapTest.java
public void testKeysConflict() { HashMap<Object, String> hashMap = new HashMap<Object, String>(); hashMap.put(STRING_ZERO_KEY, STRING_ZERO_VALUE); hashMap.put(INTEGER_ZERO_KEY, INTEGER_ZERO_VALUE); hashMap.put(ODD_ZERO_KEY, ODD_ZERO_VALUE); assertEquals(hashMap.get(INTEGER_ZERO_KEY), INTEGER_ZERO_VALUE); assertEquals(hashMap.get(ODD_ZERO_KEY), ODD_ZERO_VALUE); assertEquals(hashMap.get(STRING_ZERO_KEY), STRING_ZERO_VALUE); hashMap.remove(INTEGER_ZERO_KEY);//from w w w.ja va 2 s . co m assertEquals(hashMap.get(ODD_ZERO_KEY), ODD_ZERO_VALUE); assertEquals(hashMap.get(STRING_ZERO_KEY), STRING_ZERO_VALUE); assertEquals(hashMap.get(INTEGER_ZERO_KEY), null); hashMap.remove(ODD_ZERO_KEY); assertEquals(hashMap.get(INTEGER_ZERO_KEY), null); assertEquals(hashMap.get(ODD_ZERO_KEY), null); assertEquals(hashMap.get(STRING_ZERO_KEY), STRING_ZERO_VALUE); hashMap.remove(STRING_ZERO_KEY); assertEquals(hashMap.get(INTEGER_ZERO_KEY), null); assertEquals(hashMap.get(ODD_ZERO_KEY), null); assertEquals(hashMap.get(STRING_ZERO_KEY), null); assertEquals(hashMap.size(), 0); }
From source file:com.shafiq.myfeedle.core.MyfeedleCreatePost.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); if (itemId == R.id.menu_post_accounts) chooseAccounts();/* ww w . ja v a 2 s .com*/ else if (itemId == R.id.menu_post_photo) { boolean supported = false; Iterator<Integer> services = mAccountsService.values().iterator(); while (services.hasNext() && ((supported = sPhotoSupported.contains(services.next())) == false)) ; if (supported) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select Picture"), PHOTO); } else unsupportedToast(sPhotoSupported); // } else if (itemId == R.id.menu_post_tags) { // if (mAccountsService.size() == 1) { // if (sTaggingSupported.contains(mAccountsService.values().iterator().next())) // selectFriends(mAccountsService.keySet().iterator().next()); // else // unsupportedToast(sTaggingSupported); // } else { // // dialog to select an account // Iterator<Long> accountIds = mAccountsService.keySet().iterator(); // HashMap<Long, String> accountEntries = new HashMap<Long, String>(); // while (accountIds.hasNext()) { // Long accountId = accountIds.next(); // Cursor account = this.getContentResolver().query(Accounts.getContentUri(this), new String[]{Accounts._ID, ACCOUNTS_QUERY}, Accounts._ID + "=?", new String[]{Long.toString(accountId)}, null); // if (account.moveToFirst() && sTaggingSupported.contains(mAccountsService.get(accountId))) // accountEntries.put(account.getLong(0), account.getString(1)); // } // int size = accountEntries.size(); // if (size != 0) { // final long[] accountIndexes = new long[size]; // final String[] accounts = new String[size]; // int i = 0; // Iterator<Map.Entry<Long, String>> entries = accountEntries.entrySet().iterator(); // while (entries.hasNext()) { // Map.Entry<Long, String> entry = entries.next(); // accountIndexes[i] = entry.getKey(); // accounts[i++] = entry.getValue(); // } // mDialog = (new AlertDialog.Builder(this)) // .setTitle(R.string.accounts) // .setSingleChoiceItems(accounts, -1, new DialogInterface.OnClickListener() { // @Override // public void onClick(DialogInterface dialog, int which) { // selectFriends(accountIndexes[which]); // dialog.dismiss(); // } // }) // .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { // @Override // public void onClick(DialogInterface dialog, int which) { // dialog.dismiss(); // } // }) // .create(); // mDialog.show(); // } else // unsupportedToast(sTaggingSupported); // } } else if (itemId == R.id.menu_post_location) { LocationManager locationManager = (LocationManager) MyfeedleCreatePost.this .getSystemService(Context.LOCATION_SERVICE); Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); if (location != null) { mLat = Double.toString(location.getLatitude()); mLong = Double.toString(location.getLongitude()); if (mAccountsService.size() == 1) { if (sLocationSupported.contains(mAccountsService.values().iterator().next())) setLocation(mAccountsService.keySet().iterator().next()); else unsupportedToast(sLocationSupported); } else { // dialog to select an account Iterator<Long> accountIds = mAccountsService.keySet().iterator(); HashMap<Long, String> accountEntries = new HashMap<Long, String>(); while (accountIds.hasNext()) { Long accountId = accountIds.next(); Cursor account = this.getContentResolver().query(Accounts.getContentUri(this), new String[] { Accounts._ID, ACCOUNTS_QUERY }, Accounts._ID + "=?", new String[] { Long.toString(accountId) }, null); if (account.moveToFirst() && sLocationSupported.contains(mAccountsService.get(accountId))) accountEntries.put(account.getLong(account.getColumnIndex(Accounts._ID)), account.getString(account.getColumnIndex(Accounts.USERNAME))); } int size = accountEntries.size(); if (size != 0) { final long[] accountIndexes = new long[size]; final String[] accounts = new String[size]; int i = 0; Iterator<Map.Entry<Long, String>> entries = accountEntries.entrySet().iterator(); while (entries.hasNext()) { Map.Entry<Long, String> entry = entries.next(); accountIndexes[i] = entry.getKey(); accounts[i++] = entry.getValue(); } mDialog = (new AlertDialog.Builder(this)).setTitle(R.string.accounts) .setSingleChoiceItems(accounts, -1, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { setLocation(accountIndexes[which]); dialog.dismiss(); } }) .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create(); mDialog.show(); } else unsupportedToast(sLocationSupported); } } else (Toast.makeText(this, getString(R.string.location_unavailable), Toast.LENGTH_LONG)).show(); } return super.onOptionsItemSelected(item); }
From source file:edu.csupomona.nlp.tool.crawler.Facebook.java
/** * Get all the Posts posted on the wall of the page by the page owner. * @param page Page to be parsed * @return HashMap of Posts *///w w w . j a v a 2 s . co m public HashMap<String, Post> getPosts(Page page) { /** * /feed or /posts? * /feed includes everything posted on the wall of page * which includes other users' posts * /posts are solely posted by the owner of the page * * cursor, time or offset? * Facebook recommends cursor * offset is easy to implement but somehow couldn't get all the posts * using time stamp so far is the best choice */ HashMap<String, Post> fullPosts = new HashMap<>(); ResponseList<Post> posts = null; // start getting posts of the page for (int n = 1; n <= maxRetries_; ++n) { try { posts = fb_.getPosts(page.getId(), new Reading().since(startTime_)); } catch (FacebookException ex) { // exception & retry Logger.getLogger(Facebook.class.getName()).log(Level.SEVERE, null, ex); pause(STEP_SEC_ * n); System.out.println("Starting retry... " + n + "/" + maxRetries_); continue; } break; } // eventually failed if (posts == null) return fullPosts; // get rest of posts Paging<Post> paging; do { for (Post post : posts) if (post.getMessage() != null) { // seems getting next page of posts will in fact // ignore the starting time I used... if (post.getCreatedTime().before(startTime_)) return fullPosts; // add post to the list fullPosts.put(post.getId(), post); } // get next page paging = posts.getPaging(); // to reduce speed pause(1); // trace if (posts.size() > 0) System.out.println(posts.get(0).getCreatedTime().toString() + ": " + fullPosts.size()); // get next page if (paging != null) for (int n = 1; n <= maxRetries_; ++n) { try { posts = fb_.fetchNext(paging); } catch (FacebookException ex) { // exception & retry Logger.getLogger(Facebook.class.getName()).log(Level.SEVERE, null, ex); pause(STEP_SEC_ * n); System.out.println("Starting retry... " + n + "/" + maxRetries_); continue; } break; } } while ((paging != null) && (posts != null)); return fullPosts; }
From source file:edu.ku.brc.specify.ui.LoanReturnDlg.java
/** * @return//www . j a va 2s . c o m */ public boolean createUI() { DataProviderSessionIFace session = null; try { session = DataProviderFactory.getInstance().createSession(); loan = session.merge(loan); setTitle(getResourceString("LOANRET_TITLE")); validator.addValidationListener(new ValidationListener() { public void wasValidated(UIValidator val) { doEnableOKBtn(); } }); JPanel contentPanel = new JPanel(new BorderLayout()); JPanel mainPanel = new JPanel(); System.out.println("Num Loan Preps for Loan: " + loan.getLoanPreparations()); HashMap<Integer, Pair<CollectionObject, Vector<LoanPreparation>>> colObjHash = new HashMap<Integer, Pair<CollectionObject, Vector<LoanPreparation>>>(); for (LoanPreparation loanPrep : loan.getLoanPreparations()) { CollectionObject colObj = loanPrep.getPreparation().getCollectionObject(); System.out.println("For LoanPrep ColObj Is: " + colObj.getIdentityTitle()); Vector<LoanPreparation> list = null; Pair<CollectionObject, Vector<LoanPreparation>> pair = colObjHash.get(colObj.getId()); if (pair == null) { list = new Vector<LoanPreparation>(); colObjHash.put(colObj.getId(), new Pair<CollectionObject, Vector<LoanPreparation>>(colObj, list)); } else { list = pair.second; } list.add(loanPrep); } int colObjCnt = colObjHash.size(); String rowDef = UIHelper.createDuplicateJGoodiesDef("p", "1px,p,4px", (colObjCnt * 2) - 1); PanelBuilder pbuilder = new PanelBuilder(new FormLayout("f:p:g", rowDef), mainPanel); CellConstraints cc = new CellConstraints(); ActionListener al = new ActionListener() { public void actionPerformed(ActionEvent ae) { doEnableOKBtn(); } }; ChangeListener cl = new ChangeListener() { public void stateChanged(ChangeEvent ae) { doEnableOKBtn(); } }; int i = 0; int y = 1; Vector<Pair<CollectionObject, Vector<LoanPreparation>>> pairList = new Vector<Pair<CollectionObject, Vector<LoanPreparation>>>( colObjHash.values()); Collections.sort(pairList, new Comparator<Pair<CollectionObject, Vector<LoanPreparation>>>() { @Override public int compare(Pair<CollectionObject, Vector<LoanPreparation>> o1, Pair<CollectionObject, Vector<LoanPreparation>> o2) { return o1.first.getIdentityTitle().compareTo(o2.first.getIdentityTitle()); } }); for (Pair<CollectionObject, Vector<LoanPreparation>> pair : pairList) { CollectionObject co = pair.first; if (i > 0) { pbuilder.addSeparator("", cc.xy(1, y)); y += 2; } ColObjPanel panel = new ColObjPanel(session, this, co, colObjHash.get(co.getId()).second); colObjPanels.add(panel); panel.addActionListener(al, cl); pbuilder.add(panel, cc.xy(1, y)); y += 2; i++; } JButton selectAllBtn = createButton(getResourceString("SELECTALL")); okBtn = createButton(getResourceString("SAVE")); JButton cancel = createButton(getResourceString("CANCEL")); PanelBuilder pb = new PanelBuilder(new FormLayout("p,2px,p,2px,p,2px,p,2px,p,2px,p", "p")); dateClosed = new ValFormattedTextFieldSingle("Date", false, false, 10); dateClosed.setNew(true); dateClosed.setValue(null, ""); dateClosed.setRequired(true); validator.hookupTextField(dateClosed, "2", true, UIValidator.Type.Changed, "", false); summaryLabel = createLabel(""); pb.add(summaryLabel, cc.xy(1, 1)); pb.add(createI18NLabel("LOANRET_AGENT"), cc.xy(3, 1)); pb.add(agentCBX = createAgentCombobox(), cc.xy(5, 1)); pb.add(createI18NLabel("ON"), cc.xy(7, 1)); pb.add(dateClosed, cc.xy(9, 1)); contentPanel.add(pb.getPanel(), BorderLayout.NORTH); contentPanel.add(new JScrollPane(mainPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)); JPanel p = new JPanel(new BorderLayout()); p.setBorder(BorderFactory.createEmptyBorder(5, 0, 2, 0)); p.add(ButtonBarFactory.buildOKCancelApplyBar(okBtn, cancel, selectAllBtn), BorderLayout.CENTER); contentPanel.add(p, BorderLayout.SOUTH); contentPanel.setBorder(BorderFactory.createEmptyBorder(4, 12, 2, 12)); setContentPane(contentPanel); doEnableOKBtn(); //setIconImage(IconManager.getIcon("Preparation", IconManager.IconSize.Std16).getImage()); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); doEnableOKBtn(); okBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { setVisible(false); isCancelled = false; } }); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { setVisible(false); } }); selectAllBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { selectAllItems(); } }); pack(); Dimension size = getPreferredSize(); size.width += 20; size.height = size.height > 500 ? 500 : size.height; setSize(size); return true; } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(LoanReturnDlg.class, ex); // Error Dialog ex.printStackTrace(); } finally { if (session != null) { session.close(); } } return false; }
From source file:de.tudarmstadt.tk.statistics.report.ReportGenerator.java
/** * Get a String representation of the models order, inferred from their * pairwise p-values./*w w w . java 2 s .co m*/ * * @param ordering * a HashMap mapping levels of topological order to sets of * models * @return A string representing the models order or alternatively a message * that no order could be determined. */ private String getModelOrderingRepresentation(HashMap<Integer, TreeSet<Integer>> ordering) { if (ordering != null && ordering.size() > 1) { StringBuilder orderSequence = new StringBuilder(); for (int level = 0; level < ordering.keySet().size(); level++) { TreeSet<Integer> s = ordering.get(level); if (s.size() == 0) return "These results do not allow for a strict ordering of all models."; int n = s.first(); s.remove(n); orderSequence.append(String.format("(M%d", n)); for (Integer node : ordering.get(level)) { orderSequence.append(String.format(",M%d", node)); } orderSequence.append(")"); if (level < ordering.keySet().size() - 1) { orderSequence.append("<"); } } return String.format("These results allow for the follwing ordering of model performances: %s. ", orderSequence.toString()); } else { return "These results do not allow for a strict ordering of all models. "; } }
From source file:com.concursive.connect.web.modules.calendar.utils.CalendarView.java
/** * Constructs the calendar and returns a String object with the HTML * * @return The HTML value/* w w w . j a v a 2s. c o m*/ */ public String getHtml(String contextPath) { StringBuffer html = new StringBuffer(); //Begin the whole table html.append("<table class='calendarContainer'>" + "<tr><td>"); //Space at top to match if (headerSpace) { html.append("<table width=\"100%\" align=\"center\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">" + "<tr><td> </td></tr>" + "</table>"); } String monthArrowPrev = ""; String monthArrowNext = ""; //If popup, then use small formats of each class String tableWidth = "100%"; String pre = ""; if (popup) { pre = "small"; tableWidth = "155"; } else if (frontPageView) { tableWidth = "auto"; } //Display Calendar html.append("<table height=\"100%\" width='" + tableWidth + "' " + borderSize + cellSpacing + cellPadding + " class='" + pre + "calendar' id='calendarTable'>" + "<tr height=\"4%\">"); //Display Previous Month Arrow if (popup) { monthArrowPrev = "<INPUT TYPE=\"IMAGE\" NAME=\"prev\" ALIGN=\"MIDDLE\" SRC=\"" + contextPath + "/images/calendar/prev_arrow.png\">"; monthArrowNext = "<INPUT TYPE=\"IMAGE\" NAME=\"next\" ALIGN=\"MIDDLE\" SRC=\"" + contextPath + "/images/calendar/next_arrow.png\">"; if (monthArrows) { html.append("<th class='" + pre + "monthArrowPrev'>" + monthArrowPrev + "</th>"); } //Display Current Month name if (monthArrows) { html.append("<th colspan='5' "); } else { html.append("<th colspan='7' "); } html.append("class='" + pre + "monthName'"); html.append("><strong>" + StringUtils.toHtml(this.getMonthName(cal)) + " " + this.getYear(cal) + "</strong></th>"); //Display Next Month Arrow if (monthArrows) { html.append("<th class='" + pre + "monthArrowNext'>" + monthArrowNext + "</th>"); } } else { if (monthArrows) { int prevMonth = calPrev.get(Calendar.MONTH) + 1; String previousLink = calPrev.get(Calendar.YEAR) + "-" + (prevMonth < 10 ? "0" : "") + prevMonth; int nextMonth = calNext.get(Calendar.MONTH) + 1; String nextLink = calNext.get(Calendar.YEAR) + "-" + (nextMonth < 10 ? "0" : "") + nextMonth; html.append("<th colspan='8' "); html.append("class='" + pre + "monthName'"); html.append(">" + "<a href=\"javascript:goToMonth('" + previousLink + "');\"><img ALIGN=\"MIDDLE\" border=\"0\" src=\"" + contextPath + "/images/calendar/prev_arrow.png\" /></a> " + "<strong>" + StringUtils.toHtml(this.getMonthName(cal)) + " " + this.getYear(cal) + "</strong>" + " <a href=\"javascript:goToMonth('" + nextLink + "');\"><img ALIGN=\"MIDDLE\" border=\"0\" src=\"" + contextPath + "/images/calendar/next_arrow.png\" /></a>" + "</th>"); } else { html.append("<th colspan=\"8\">"); html.append(getHtmlMonthSelect()); html.append(" "); html.append(getHtmlYearSelect()); html.append(" "); Calendar tmp = Calendar.getInstance(locale); tmp.set(Calendar.HOUR, 0); tmp.set(Calendar.MINUTE, 0); tmp.set(Calendar.SECOND, 0); tmp.set(Calendar.MILLISECOND, 0); if (timeZone != null) { tmp.setTimeZone(timeZone); } html.append("<a href=\"javascript:showToDaysEvents('" + (tmp.get(Calendar.MONTH) + 1) + "','" + tmp.get(Calendar.DATE) + "','" + tmp.get(Calendar.YEAR) + "');\">Today</a>"); html.append("</th>"); } } html.append("</tr>"); //Display the Days of the Week names html.append("<tr height=\"4%\">"); if (!popup) { html.append("<td width=\"4\" class=\"row1\"><font style=\"visibility:hidden\">n</font></td>"); } // Use locale... int firstDayOfWeek = cal.getFirstDayOfWeek(); for (int i = firstDayOfWeek; i < firstDayOfWeek + 7; i++) { html.append("<td width=\"14%\" class='" + pre + "weekName'>"); if (popup || frontPageView) { html.append(StringUtils.toHtml(this.getDayName(i, true))); } else { html.append(StringUtils.toHtml(this.getDayName(i, false))); } html.append("</td>"); } html.append("</tr>"); int startCellPrev = this.getStartCell(calPrev); int endCellPrev = this.getEndCell(calPrev); int startCell = this.getStartCell(cal); int endCell = this.getEndCell(cal); int thisDay = 1; String tdClass = ""; for (int cellNo = 0; cellNo < this.getNumberOfCells(); cellNo++) { boolean prevMonth = false; boolean nextMonth = false; boolean mainMonth = false; int displayDay = 0; int displayMonth = 0; int displayYear = 0; if (cellNo < startCell) { //The previous month displayMonth = calPrev.get(Calendar.MONTH) + 1; displayYear = calPrev.get(Calendar.YEAR); displayDay = (endCellPrev - startCell + 2 + cellNo - startCellPrev); prevMonth = true; } else if (cellNo > endCell) { //The next month displayMonth = calNext.get(Calendar.MONTH) + 1; displayYear = calNext.get(Calendar.YEAR); if (endCell + 1 == cellNo) { thisDay = 1; } displayDay = thisDay; nextMonth = true; thisDay++; } else { //The main month mainMonth = true; displayMonth = cal.get(Calendar.MONTH) + 1; displayYear = cal.get(Calendar.YEAR); displayDay = thisDay; thisDay++; } if (cellNo % 7 == 0) { tdClass = ""; html.append("<tr"); if (!popup) { if (calendarInfo.getCalendarView().equalsIgnoreCase("week")) { if (displayMonth == calendarInfo.getStartMonthOfWeek() && displayDay == calendarInfo.getStartDayOfWeek()) { html.append(" class=\"selectedWeek\" "); tdClass = "selectedDay"; } } } html.append(">"); } if (!popup && (cellNo % 7 == 0)) { html.append("<td valign='top' width=\"4\" class=\"weekSelector\" name=\"weekSelector\">"); String weekSelectedArrow = "<a href=\"javascript:showWeekEvents('" + displayYear + "','" + displayMonth + "','" + displayDay + "')\">" + "<img ALIGN=\"MIDDLE\" src=\"" + contextPath + "/images/control.png\" border=\"0\" onclick=\"javascript:switchTableClass(this,'selectedWeek','row');\"></a>"; html.append(weekSelectedArrow); html.append("</td>"); } html.append("<td valign='top'"); if (!smallView) { if (!frontPageView) { html.append(" height='70'"); } else { html.append(" height='35'"); } } if (!popup) { html.append(" onclick=\"javascript:showDayEvents('" + displayYear + "','" + displayMonth + "','" + displayDay + "');javascript:switchTableClass(this,'selectedDay','cell');\""); if (calendarInfo.getCalendarView().equalsIgnoreCase("day")) { tdClass = ""; if (displayMonth == calendarInfo.getMonthSelected() && displayDay == calendarInfo.getDaySelected()) { tdClass = "selectedDay"; } } } if (prevMonth) { //The previous month if (this.isCurrentDay(calPrev, displayDay)) { html.append(" id='today' class='" + ((tdClass.equalsIgnoreCase("")) ? pre + "today'" : tdClass + "'") + " name='" + pre + "today' >"); } else { html.append(" class='" + ((tdClass.equalsIgnoreCase("")) ? pre + "noday'" : tdClass + "'") + " name='" + pre + "noday' >"); } } else if (nextMonth) { if (this.isCurrentDay(calNext, displayDay)) { html.append(" id='today' class='" + ((tdClass.equalsIgnoreCase("")) ? pre + "today'" : tdClass + "'") + " name='" + pre + "today' >"); } else { html.append(" class='" + ((tdClass.equalsIgnoreCase("")) ? pre + "noday'" : tdClass + "'") + " name='" + pre + "noday' >"); } } else { //The main main if (this.isCurrentDay(cal, displayDay)) { html.append(" id='today' class='" + ((tdClass.equalsIgnoreCase("")) ? pre + "today'" : tdClass + "'") + " name='" + pre + "today' >"); } else { html.append(" class='" + ((tdClass.equalsIgnoreCase("")) ? pre + "day'" : tdClass + "'") + " name='" + pre + "day' >"); } } // end if block //Display the day in the appropriate link color if (popup) { //Popup calendar CalendarEventList highlightEvent = eventList .get(displayMonth + "/" + displayDay + "/" + displayYear); String dateColor = "" + displayDay; if (highlightEvent != null && highlightEvent.containsKey("highlight")) { dateColor = "<font color=#FF0000>" + displayDay + "</font>"; } else if (!mainMonth) { dateColor = "<font color=#888888>" + displayDay + "</font>"; } html.append("<a href=\"javascript:returnDate(" + displayDay + ", " + displayMonth + ", " + displayYear + ");\"" + ">" + dateColor + "</a>"); } else { //Event calendar String dateColor = "" + displayDay; if (!mainMonth) { dateColor = "<font color=#888888>" + displayDay + "</font>"; } html.append("<a href=\"javascript:showDayEvents('" + displayYear + "','" + displayMonth + "','" + displayDay + "');\">" + dateColor + "</a>"); if (this.isHoliday(String.valueOf(displayMonth), String.valueOf(displayDay), String.valueOf(displayYear))) { html.append(CalendarEvent.getIcon("holiday", contextPath) + "<font color=\"blue\"><br />"); } //get all events categories and respective counts. HashMap events = this.getEventList(String.valueOf(displayMonth), String.valueOf(displayDay), String.valueOf(displayYear)); if (events.size() > 0) { html.append( "<table width=\"12%\" align=\"center\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" class=\"dayIcon\">"); for (int i = 0; i < Array.getLength(CalendarEventList.EVENT_TYPES); i++) { String eventType = CalendarEventList.EVENT_TYPES[i]; if (events.containsKey(eventType)) { if (!eventType.equals(CalendarEventList.EVENT_TYPES[7])) { Object eventObj = events.get(eventType); // use reflection to call the size method on the event list object String eventSize = (String) ObjectUtils.getObject(eventObj, "sizeString"); if (!eventSize.equals("0")) { html.append("<tr><td>" + CalendarEvent.getIcon(eventType, contextPath) + "</td><td> " + eventSize + "</td></tr>"); } } } } html.append("</table>"); } //end of events display. } html.append("</td>"); if ((cellNo + 1) % 7 == 0) { html.append("</tr>"); } // end check for end of row } // end for-loop html.append("</table></td></tr>"); html.append("</table>"); //Display a link that selects today if (popup) { Calendar tmp = Calendar.getInstance(locale); tmp.set(Calendar.HOUR, 0); tmp.set(Calendar.MINUTE, 0); tmp.set(Calendar.SECOND, 0); tmp.set(Calendar.MILLISECOND, 0); if (timeZone != null) { tmp.setTimeZone(timeZone); } int displayMonth = tmp.get(Calendar.MONTH) + 1; int displayYear = tmp.get(Calendar.YEAR); int displayDay = tmp.get(Calendar.DAY_OF_MONTH); html.append("<p class=\"smallfooter\">Today: " + "<a href=\"javascript:returnDate(" + displayDay + ", " + displayMonth + ", " + displayYear + ");\"" + ">" + this.getToday() + "</p>"); html.append("<input type=\"hidden\" name=\"year\" value=\"" + cal.get(Calendar.YEAR) + "\">"); html.append("<input type=\"hidden\" name=\"month\" value=\"" + (cal.get(Calendar.MONTH) + 1) + "\">"); } html.append("<input type=\"hidden\" name=\"day\" value=\"" + (cal.get(Calendar.DATE)) + "\">"); return html.toString(); }
From source file:it.classhidra.core.controller.bsController.java
public static Vector getActionStreams(String id_action) { Vector _streams = null;//from ww w . j av a 2 s . c o m info_action iActionMapped = (info_action) getAction_config().get_actions().get(id_action); if (iActionMapped == null) return new Vector(); else if (iActionMapped.getVm_streams() != null) _streams = iActionMapped.getVm_streams(); else { _streams = new Vector(); Vector _streams_orig = (Vector) getAction_config().get_streams_apply_to_actions().get("*"); if (_streams_orig != null) _streams.addAll(_streams_orig); Vector _streams4action = (Vector) getAction_config().get_streams_apply_to_actions().get(id_action); if (_streams4action != null) { Vector _4add = new Vector(); HashMap _4remove = new HashMap(); for (int i = 0; i < _streams4action.size(); i++) { info_stream currentis = (info_stream) _streams4action.get(i); if (currentis.get_apply_to_action() != null) { info_apply_to_action currentiata = (info_apply_to_action) currentis.get_apply_to_action() .get(id_action); if (currentiata.getExcluded() != null && currentiata.getExcluded().equalsIgnoreCase("true")) _4remove.put(currentis.getName(), currentis.getName()); else _4add.add(currentis); } } _streams.addAll(_4add); if (_4remove.size() > 0) { int i = 0; while (i < _streams.size()) { info_stream currentis = (info_stream) _streams.get(i); if (_4remove.get(currentis.getName()) != null) _streams.remove(i); else i++; } } _streams = new util_sort().sort(_streams, "int_order", "A"); } iActionMapped.setVm_streams(_streams); } return _streams; }