rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
buf.append("<prompt>[email protected]</prompt>"); | buf.append("<prompt>" + username + "</prompt>"); | public String getChildElementXML() { StringBuffer buf = new StringBuffer(); buf.append("<query xmlns=\"" + NAMESPACE + "\">"); buf.append("<prompt>[email protected]</prompt>"); buf.append("</query>"); return buf.toString(); } |
dd.getMenuBar().updateAll(true); dd.getTreeContextMenu().updateAll(true); | public void contextChanged(Event e) { List<ActionGroup> actionGroups = dd.getActionGroups(); for (ActionGroup ag : actionGroups) { ag.update(); } } |
|
srcToEvtToMethod.remove(source); | HashMap<Integer, String> evtToMethod = srcToEvtToMethod.get(source); if (evtToMethod != null) { Set<Integer> eventTypes = evtToMethod.keySet(); for (Integer eventType : eventTypes) { source.removeListener(eventType, this); } srcToEvtToMethod.remove(source); } | public void removeMappingFor(Widget source) { srcToEvtToMethod.remove(source); } |
this.roomTitle = participantNickname + " - Started " + formatter.format(new Date()); | this.roomTitle = participantNickname; | public ChatRoomImpl(final String participantJID, String participantNickname, String title) { this.participantJID = participantJID; this.participantNickname = participantNickname; AndFilter presenceFilter = new AndFilter(new PacketTypeFilter(Presence.class), new FromContainsFilter(this.participantJID)); // Register PacketListeners AndFilter messageFilter = new AndFilter(new PacketTypeFilter(Message.class), new FromContainsFilter(participantJID)); SparkManager.getConnection().addPacketListener(this, messageFilter); SparkManager.getConnection().addPacketListener(this, presenceFilter); // The roomname will be the participantJID this.roomname = participantJID; // Use the agents username as the Tab Title this.tabTitle = title; // The name of the room will be the node of the user jid + conversation. final SimpleDateFormat formatter = new SimpleDateFormat("h:mm a"); this.roomTitle = participantNickname + " - Started " + formatter.format(new Date()); // Add RoomInfo this.getSplitPane().setRightComponent(null); getSplitPane().setDividerSize(0); roster = SparkManager.getConnection().getRoster(); presence = roster.getPresence(participantJID); StatusItem statusItem = SparkManager.getWorkspace().getStatusBar().getItemFromPresence(presence); RosterEntry entry = roster.getEntry(participantJID); if (statusItem == null) { tabIcon = SparkRes.getImageIcon(SparkRes.CLEAR_BALL_ICON); } else { String status = presence.getStatus(); if (status != null && status.indexOf("phone") != -1) { tabIcon = SparkRes.getImageIcon(SparkRes.ON_PHONE_IMAGE); } else { tabIcon = statusItem.getIcon(); } } Icon icon = SparkManager.getChatManager().getPresenceIconForContactHandler(presence); if (icon != null) { tabIcon = icon; } PacketFilter filter = new AndFilter(new PacketTypeFilter(Presence.class), new FromContainsFilter(participantJID)); SparkManager.getConnection().addPacketListener(new PacketListener() { public void processPacket(Packet packet) { presence = (Presence)packet; } }, filter); // Create toolbar buttons. ChatRoomButton infoButton = new ChatRoomButton("", SparkRes.getImageIcon(SparkRes.PROFILE_IMAGE_24x24)); infoButton.setToolTipText("View information about this user"); // Create basic toolbar. getToolBar().addChatRoomButton(infoButton); // If the user is not in the roster, then allow user to add them. if (entry == null && !StringUtils.parseResource(participantJID).equals(participantNickname)) { ChatRoomButton addToRosterButton = new ChatRoomButton("", SparkRes.getImageIcon(SparkRes.ADD_IMAGE_24x24)); addToRosterButton.setToolTipText("Add this user to your roster."); getToolBar().addChatRoomButton(addToRosterButton); addToRosterButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { RosterDialog rosterDialog = new RosterDialog(); rosterDialog.setDefaultJID(participantJID); rosterDialog.setDefaultNickname(getParticipantNickname()); rosterDialog.showRosterDialog(SparkManager.getChatManager().getChatContainer().getChatFrame()); } }); } // Show VCard. infoButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VCardManager vcard = SparkManager.getVCardManager(); vcard.viewProfile(participantJID, SparkManager.getChatManager().getChatContainer()); } }); // If this is a private chat from a group chat room, do not show toolbar. if (StringUtils.parseResource(participantJID).equals(participantNickname)) { getToolBar().setVisible(false); } typingTimer = new Timer(2000, new ActionListener() { public void actionPerformed(ActionEvent e) { long now = System.currentTimeMillis(); if (now - lastTypedCharTime > 2000) { if (!sendNotification) { // send cancel SparkManager.getMessageEventManager().sendCancelledNotification(getParticipantJID(), threadID); sendNotification = true; } } } }); typingTimer.start(); // Add message event request listener messageEventRequestListener = new ChatMessageEventRequestListener(); SparkManager.getMessageEventManager().addMessageEventRequestListener(messageEventRequestListener); lastActivity = System.currentTimeMillis(); } |
System.out.println("Return CLASS: " + returnType); System.out.println("Iterator CLASS: " + Iterator.class); | private PropertyOperator(final Class target) throws SecurityException, PropertyException { if (_debug) { _log.debug("new PropertyOperator(" + target + ")"); } Accessor acc; // introspect fields first Field[] fields = target.getFields(); for (int i = 0; i < fields.length; i++) { if (Modifier.isPublic(fields[i].getModifiers())) { if (_debug) { _log.debug("Adding field: " + fields[i]); } acc = new FieldAccessor(fields[i]); _unaryAccessors.put(acc.getName(),acc); } else if (_debug) { _log.debug("Skipped non-public field: " + fields[i]); } } // introspect methods second Method[] methods = target.getMethods(); Method meth; Class[] params; String name,propName; for (int i = 0; i < methods.length; i++) { meth = methods[i]; // don't look at non-public methods if (! Modifier.isPublic(meth.getModifiers())) { if (_debug) { _log.debug("Skipped non-public method: " + meth); } continue; } /*if (_debug) { * _log.debug("Checking " + meth); *} */ name = meth.getName(); params = meth.getParameterTypes(); int plength = params.length; // add direct accessor acc = (Accessor) _directAccessors.get(name); if (acc != null) { ((DirectAccessor) acc).addMethod(meth,params); } else { acc = new DirectAccessor(name,meth,params); _directAccessors.put(name,acc); } // check for get/set/put method if ((name.startsWith("get") || name.startsWith("set")) || name.equals("put")) { propName = name.substring(3); if ( ((plength == 0) && name.startsWith("get")) || ((plength == 1) && name.startsWith("set")) ) { // unary get/set method acc = (Accessor) _unaryAccessors.get(propName); if (acc != null) { if (acc instanceof MethodAccessor) { if (_debug) { _log.debug("Updating existing accessor: " + meth); } ((MethodAccessor) acc).addMethod(meth,params); } else if (_debug) { _log.debug("Superceded by a field: " + meth); } } else { if (_debug) { _log.debug("Adding new accessor: " + meth); } acc = new UnaryMethodAccessor(propName,meth,params); _unaryAccessors.put(propName,acc); } } else if ( (plength > 0) && ( (params[0].isInstance("string") && ((plength == 2) && name.equals("put"))) || ((plength == 1) && name.equals("get")))) { // hashtable get/put if (hashAccessor != null) { if (_debug) { _log.debug("Updating hash accessor: " + meth); } hashAccessor.addMethod(meth,params); } else { if (_debug) { _log.debug("Creating a new hash accessor: " + meth); } hashAccessor = new BinaryMethodAccessor(propName,meth,params); } } else if ((plength > 0) && (params[0].isInstance("string")) && (((plength == 1) && name.startsWith("get")) || ((plength == 2) && name.startsWith("set")))) { // binary get/set method acc = (Accessor) _binaryAccessors.get(propName); if (acc != null) { if (_debug) { _log.debug("Updating binary accessor: " + meth); } ((MethodAccessor) acc).addMethod(meth,params); } else { if (_debug) { _log.debug("Creating a new binary accessor: " + meth); } acc = new BinaryMethodAccessor(propName,meth,params); _binaryAccessors.put(propName,acc); } } } else if (name.equals("elements") || name.equals("enumeration") || name.equals("iterator") || name.equals("toArray")) { if (params.length == 0) { Class returnType = meth.getReturnType(); // iterator supercedes enumeration supercedes Object[] System.out.println("Return CLASS: " + returnType); System.out.println("Iterator CLASS: " + Iterator.class); Class iterClass = Iterator.class; boolean iterA = iterClass.isAssignableFrom(returnType); if ( iterA || (((iteratorMethod == null) || iteratorMethod.getName().equals("toArray")) && Object[].class.isAssignableFrom(returnType) || Enumeration.class.isAssignableFrom(returnType))) { if (_debug) { _log.debug("Setting iterator method: " + meth); } iteratorMethod = meth; } } } } } |
|
char ch = (char) ((String) o).charAt(0); | char ch = s.charAt(0); | public static Character toChar(Object o) throws org.webmacro.PropertyException { Character c = null; if (o == null || o == "") return null; if (o instanceof Character) return (Character) o; if (o instanceof Number) { try { c = new Character((char) ((Number) o).intValue()); } catch (Exception e) { throw new IllegalArgumentException("Not a valid char: " + o); } } else if (o instanceof String) { String s = (String) o; if (s.startsWith("\\u") && s.length() == 6) { // unicode char int i = Integer.parseInt(s.substring(2), 16); c = new Character((char) i); } else { // use the first character of the string char ch = (char) ((String) o).charAt(0); c = new Character(ch); } } else { // throw exception throw new org.webmacro.PropertyException( "$Type.toChar() is unable to convert the supplied value to a Character. The argument" + " must be a number or a String. The supplied argument was " + o + ((o == null) ? "." : " of type " + o.getClass().getName())); } return c; } |
+ o + ((o == null) ? "." : " of type " + o.getClass().getName())); | + o + " of type " + o.getClass().getName()); | public static Character toChar(Object o) throws org.webmacro.PropertyException { Character c = null; if (o == null || o == "") return null; if (o instanceof Character) return (Character) o; if (o instanceof Number) { try { c = new Character((char) ((Number) o).intValue()); } catch (Exception e) { throw new IllegalArgumentException("Not a valid char: " + o); } } else if (o instanceof String) { String s = (String) o; if (s.startsWith("\\u") && s.length() == 6) { // unicode char int i = Integer.parseInt(s.substring(2), 16); c = new Character((char) i); } else { // use the first character of the string char ch = (char) ((String) o).charAt(0); c = new Character(ch); } } else { // throw exception throw new org.webmacro.PropertyException( "$Type.toChar() is unable to convert the supplied value to a Character. The argument" + " must be a number or a String. The supplied argument was " + o + ((o == null) ? "." : " of type " + o.getClass().getName())); } return c; } |
return t; | try { return t.evaluateAsString(bc); } catch (PropertyException e) { return ""; } | public final Object build (DirectiveBuilder builder, BuildContext bc) throws BuildException { Broker broker = bc.getBroker(); _log = bc.getLog("IncludeDirective"); // build configuration key names, since they're based // on the configured name of this directive _directiveName = builder.getName(); TEMPLATE_EXTENSIONS_NAME = _directiveName + TEMPLATE_EXTENSIONS_NAME; // determine what type of file we need to deal with if (builder.getArg(PARSE_TEXT_K, bc) != null) { _type = TYPE_TEXT; } else if (builder.getArg(PARSE_TEMPLATE_K, bc) != null) { _type = TYPE_TEMPLATE; } else if (builder.getArg(PARSE_MACRO_K, bc) != null) { _type = TYPE_MACRO; } else { _type = TYPE_DYNAMIC; } // if the filename passed to us was a Macro (needs to be evaluated later) // then store it as _macFilename. Otherwise, assume it's a String // and we'll just use that string as the filename Object o = builder.getArg(PARSE_FILENAME, bc); if (o instanceof Macro) { if (_type == TYPE_TEXT || _type == TYPE_MACRO) { _log.warning("Included a 'static' file type using a dynamic filename. " + "File will be included, but any included #macro's will not at " + bc.getCurrentLocation()); } _macFilename = (Macro) o; } else { _strFilename = o.toString(); if (_strFilename == null || _strFilename.length() == 0) throw makeBuildException("Filename cannot be null or empty"); if (_type == TYPE_TEXT) { // we're a static type, need to // include the file (by returning it) now, // during build time try { return getThingToInclude(broker, _type, _strFilename); } catch (Exception e) { throw makeBuildException("Unable to include as text", e); } } else if (_type == TYPE_MACRO) { // we're a template type. ned to get the template (already parsed) // and merge its macros into our build context. // then we return the template so its contents can also be included Template t = null; try { t = getTemplate(broker, _strFilename); bc.mergeConstants(t); } catch (Exception e) { throw makeBuildException("Unable to include as macro", e); } return t; } else if (_type == TYPE_DYNAMIC) { // being dynamic means we need to guess the // file type based on the file's extension // and take care of finding the file during runtime _type = guessType(broker, _strFilename); } } // we are configured to be lazy, or we couldn't determine the filename // during the build() process (b/c it is a Macro) return this; } |
public Collection getClasses() | public SortedSet getClasses() | public Collection getClasses() { Collection classes = new TreeSet(); Iterator iter = this.children.values().iterator(); while (iter.hasNext()) { SourceFileData sourceFileData = (SourceFileData)iter.next(); classes.addAll(sourceFileData.getChildren()); } return classes; } |
Collection classes = new TreeSet(); | SortedSet classes = new TreeSet(); | public Collection getClasses() { Collection classes = new TreeSet(); Iterator iter = this.children.values().iterator(); while (iter.hasNext()) { SourceFileData sourceFileData = (SourceFileData)iter.next(); classes.addAll(sourceFileData.getChildren()); } return classes; } |
articleItem.load(new File("/Test/article/"+id+".xml")); | articleItem.load(id); | public void processAction(ActionEvent event) { if (event.getComponent().getId().equals(LIST_BUTTON_ID)) { WFUtil.invoke(LIST_ARTICLES_BEAN_ID, "list"); return; } else if (event.getComponent().getId().equals(VIEW_ARTICLE_BACK_BUTTON_ID)) { WFComponentSelector cs = (WFComponentSelector) event.getComponent().findComponent(DISPLAY_SELECTOR_ID); cs.setSelectedId(LIST_PANEL_ID, true); cs.setSelectedId(VIEW_ARTICLE_PANEL_ID, false); return; } UIComponent link = event.getComponent(); String id = WFUtil.getParameter(link, "id"); ArticleItemBean articleItem = new ArticleItemBean(); try { articleItem.load(new File("/Test/article/"+id+".xml")); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "clear");// ContentItemCase caze = new ContentItemCaseBean();// caze.setPublishedFromDate(new Date());// WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setCase", caze); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setLocaleId", "en"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setHeadline", notNull(articleItem.getHeadline())+" (id = " + id + ")"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setTeaser", notNull(articleItem.getTeaser())); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setBody", notNull(articleItem.getBody())); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setAuthor", notNull(articleItem.getAuthor())); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setComment", notNull(articleItem.getComment())); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setDescription", notNull(articleItem.getDescription())); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setStatus", // articleItem.getStatus() ContentItemCase.STATUS_PUBLISHED ); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setMainCategoryId", new Integer(3)); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setLocaleId", "sv"); //And one more time since it won't work after just setting the params once... WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setHeadline", notNull(articleItem.getHeadline())+" (id = " + id + ")"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setTeaser", notNull(articleItem.getTeaser())); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setBody", notNull(articleItem.getBody()));// WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setHeadline", "Electronic Rykjavik klar");// WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setBody", "Den frsta 24-timmarsmyndigheten fr Reykjaviks kommun igng.");// WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setLocaleId", "en"); WFComponentSelector cs = (WFComponentSelector) event.getComponent().getParent().getParent().getParent().findComponent(DISPLAY_SELECTOR_ID); cs.setSelectedId(LIST_PANEL_ID, false); cs.setSelectedId(VIEW_ARTICLE_PANEL_ID, true); } catch (XmlException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } |
WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setHeadline", notNull(articleItem.getHeadline())+" (id = " + id + ")"); | WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setHeadline", notNull(articleItem.getHeadline())); | public void processAction(ActionEvent event) { if (event.getComponent().getId().equals(LIST_BUTTON_ID)) { WFUtil.invoke(LIST_ARTICLES_BEAN_ID, "list"); return; } else if (event.getComponent().getId().equals(VIEW_ARTICLE_BACK_BUTTON_ID)) { WFComponentSelector cs = (WFComponentSelector) event.getComponent().findComponent(DISPLAY_SELECTOR_ID); cs.setSelectedId(LIST_PANEL_ID, true); cs.setSelectedId(VIEW_ARTICLE_PANEL_ID, false); return; } UIComponent link = event.getComponent(); String id = WFUtil.getParameter(link, "id"); ArticleItemBean articleItem = new ArticleItemBean(); try { articleItem.load(new File("/Test/article/"+id+".xml")); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "clear");// ContentItemCase caze = new ContentItemCaseBean();// caze.setPublishedFromDate(new Date());// WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setCase", caze); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setLocaleId", "en"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setHeadline", notNull(articleItem.getHeadline())+" (id = " + id + ")"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setTeaser", notNull(articleItem.getTeaser())); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setBody", notNull(articleItem.getBody())); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setAuthor", notNull(articleItem.getAuthor())); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setComment", notNull(articleItem.getComment())); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setDescription", notNull(articleItem.getDescription())); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setStatus", // articleItem.getStatus() ContentItemCase.STATUS_PUBLISHED ); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setMainCategoryId", new Integer(3)); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setLocaleId", "sv"); //And one more time since it won't work after just setting the params once... WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setHeadline", notNull(articleItem.getHeadline())+" (id = " + id + ")"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setTeaser", notNull(articleItem.getTeaser())); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setBody", notNull(articleItem.getBody()));// WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setHeadline", "Electronic Rykjavik klar");// WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setBody", "Den frsta 24-timmarsmyndigheten fr Reykjaviks kommun igng.");// WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setLocaleId", "en"); WFComponentSelector cs = (WFComponentSelector) event.getComponent().getParent().getParent().getParent().findComponent(DISPLAY_SELECTOR_ID); cs.setSelectedId(LIST_PANEL_ID, false); cs.setSelectedId(VIEW_ARTICLE_PANEL_ID, true); } catch (XmlException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } |
WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setAuthor", notNull(articleItem.getAuthor())); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setMainCategory", notNull(articleItem.getMainCategory())); | public void processAction(ActionEvent event) { if (event.getComponent().getId().equals(LIST_BUTTON_ID)) { WFUtil.invoke(LIST_ARTICLES_BEAN_ID, "list"); return; } else if (event.getComponent().getId().equals(VIEW_ARTICLE_BACK_BUTTON_ID)) { WFComponentSelector cs = (WFComponentSelector) event.getComponent().findComponent(DISPLAY_SELECTOR_ID); cs.setSelectedId(LIST_PANEL_ID, true); cs.setSelectedId(VIEW_ARTICLE_PANEL_ID, false); return; } UIComponent link = event.getComponent(); String id = WFUtil.getParameter(link, "id"); ArticleItemBean articleItem = new ArticleItemBean(); try { articleItem.load(new File("/Test/article/"+id+".xml")); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "clear");// ContentItemCase caze = new ContentItemCaseBean();// caze.setPublishedFromDate(new Date());// WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setCase", caze); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setLocaleId", "en"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setHeadline", notNull(articleItem.getHeadline())+" (id = " + id + ")"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setTeaser", notNull(articleItem.getTeaser())); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setBody", notNull(articleItem.getBody())); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setAuthor", notNull(articleItem.getAuthor())); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setComment", notNull(articleItem.getComment())); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setDescription", notNull(articleItem.getDescription())); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setStatus", // articleItem.getStatus() ContentItemCase.STATUS_PUBLISHED ); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setMainCategoryId", new Integer(3)); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setLocaleId", "sv"); //And one more time since it won't work after just setting the params once... WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setHeadline", notNull(articleItem.getHeadline())+" (id = " + id + ")"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setTeaser", notNull(articleItem.getTeaser())); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setBody", notNull(articleItem.getBody()));// WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setHeadline", "Electronic Rykjavik klar");// WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setBody", "Den frsta 24-timmarsmyndigheten fr Reykjaviks kommun igng.");// WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setLocaleId", "en"); WFComponentSelector cs = (WFComponentSelector) event.getComponent().getParent().getParent().getParent().findComponent(DISPLAY_SELECTOR_ID); cs.setSelectedId(LIST_PANEL_ID, false); cs.setSelectedId(VIEW_ARTICLE_PANEL_ID, true); } catch (XmlException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } |
|
for (int i = 0, size = attributes.getLength(); i < size; i++) { Attr attribute = (Attr) attributes.item(i); String uri = attribute.getNamespaceURI(); String localName = attribute.getLocalName(); if (localName == null || localName.equals("xmlns") || localName.startsWith("xmlns:")) { continue; } if (!isEmpty(uri) && uri.equals(element.getNamespaceURI())) { boolean addProperty = true; if (reservedBeanAttributeNames.contains(localName)) { PropertyDescriptor descriptor = getPropertyDescriptor(className, localName); addProperty = descriptor != null; } if (addProperty) { addAttributeProperty(definition, metadata, element, attribute); } } } | protected void addAttributeProperties(BeanDefinitionHolder definition, MappingMetaData metadata, String className, Element element) { NamedNodeMap attributes = element.getAttributes(); for (int i = 0, size = attributes.getLength(); i < size; i++) { Attr attribute = (Attr) attributes.item(i); String uri = attribute.getNamespaceURI(); String localName = attribute.getLocalName(); if (localName == null || localName.equals("xmlns") || localName.startsWith("xmlns:")) { continue; } // we could use namespaced attributes to differentiate real spring // attributes from namespace-specific attributes if (isEmpty(uri) && !localName.equals("class")) { boolean addProperty = true; if (reservedBeanAttributeNames.contains(localName)) { // should we allow the property to shine through? PropertyDescriptor descriptor = getPropertyDescriptor(className, localName); addProperty = descriptor != null; } if (addProperty) { addAttributeProperty(definition, metadata, element, attribute); } } } } |
|
String localName = attribute.getName(); | String localName = attribute.getLocalName(); | protected void addAttributeProperty(BeanDefinitionHolder definition, MappingMetaData metadata, Element element, Attr attribute) { String localName = attribute.getName(); String value = attribute.getValue(); addProperty(definition, metadata, element, localName, value); } |
Element answer = element.getOwnerDocument().createElement(getLocalName(element)); | Element answer = element.getOwnerDocument().createElementNS(element.getNamespaceURI(), element.getNodeName()); | protected Element cloneElement(Element element) { Element answer = element.getOwnerDocument().createElement(getLocalName(element)); NamedNodeMap attributes = element.getAttributes(); for (int i = 0, size = attributes.getLength(); i < size; i++) { Attr attribute = (Attr) attributes.item(i); String uri = attribute.getNamespaceURI(); answer.setAttributeNS(uri, attribute.getName(), attribute.getNodeValue()); } return answer; } |
if (log == null) log = new StringBuffer(); | protected void add(String component, String suffix) { String key = null; String name = component; int eqIdx = component.indexOf('='); if (eqIdx != -1) { key = component.substring(0, eqIdx); name = component.substring(eqIdx + 1); } Class c; try { c = Class.forName(name); } catch (ClassNotFoundException e) { _log.warning("ComponentMap: Could not locate class " + name, e); return; } if (key == null) { key = c.getName(); int start = 0; int end = key.length(); int lastDot = key.lastIndexOf('.'); if (lastDot != -1) { start = lastDot + 1; } if (key.endsWith(suffix)) { end -= suffix.length(); } key = key.substring(start, end); } Object instance = null; StringBuffer log = null; try { Constructor ctor = c.getConstructor(_ctorArgs1); Object[] args = new Object[2]; args[0] = key; args[1] = new SubSettings(_config, key); instance = ctor.newInstance(args); } catch (Exception e) { log = new StringBuffer(); log.append("Error loading component key="); log.append(key); log.append(" class="); log.append(c.toString()); log.append("\n"); log.append("Trying 2-argument constructor: "); log.append(e.toString()); log.append("\n"); } if (instance == null) { try { Constructor ctor = c.getConstructor(_ctorArgs2); Object[] args = new Object[1]; args[0] = key; instance = ctor.newInstance(args); } catch (Exception e) { log.append("Trying 1-argument constructor: "); log.append(e.toString()); log.append("\n"); } } if (instance == null) { try { instance = c.newInstance(); } catch (Exception e) { log.append("Trying 0-argument constructor: "); log.append(e.toString()); log.append("\n"); _log.warning(log.toString()); return; } } _values.put(key, instance); } |
|
names[start] + " on object " + instance + " of " | fillInName(names, start) + " on object " + instance + " of " | public Object getProperty(final Context context, final Object instance, final Object[] names, int start, int end) throws PropertyException { String prop; Object nextProp = null; Accessor acc = null; if (names[start] instanceof String) { prop = (String) names[start]; } else if (names[start] instanceof PropertyMethod) { PropertyMethod pm = (PropertyMethod) names[start]; prop = pm.getName(); acc = (Accessor) _directAccessors.get(prop); Object[] args = pm.getArguments(context); if (acc == null) { if (isMethodRestricted(instance.getClass(), prop)) throw new PropertyException.RestrictedMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } try { nextProp = acc.get(instance,args); start++; } catch (NoSuchMethodException e) { throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } } else { prop = names[start].toString(); } // unary? if (acc == null) { acc = (Accessor) _unaryAccessors.get(prop); if (acc != null) { try { nextProp = acc.get(instance); start++; } catch (NoSuchMethodException e) { acc = null; } } } // binary? if (acc == null) { acc = (Accessor) _binaryAccessors.get(prop); if ((acc != null) && ( (start+1) <= end) ) { try { nextProp = acc.get(instance, (String) names[start + 1]); start += 2; } catch (NoSuchMethodException e) { acc = null; } catch (ClassCastException e) { // names[start + 1] was not a String, just move on // this catch is more efficient than using instanceof // since 90% of the time it really will be a string acc = null; } } else { acc = null; } } // hash? if (acc == null) { acc = _hashAccessor; try { if (acc != null) { nextProp = acc.get(instance,prop); start++; } } catch (NoSuchMethodException e) { acc = null; } } if (acc == null) { // user tried to access a property of a property that doesn't exist // ex: $TestObject.FirstName.NotThere // check if object is restricted if (isMethodRestricted(instance.getClass(), "get" + prop) || isMethodRestricted(instance.getClass(), "set" + prop)) throw new PropertyException.RestrictedPropertyException( prop, fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchPropertyException( prop, fillInName(names, start), instance.getClass().getName()); } if (start <= end) { try { return _cache.getOperator(nextProp) .getProperty(context,nextProp,names,start,end); } catch (NullPointerException e) { // will we ever get here? --eric throw new PropertyException("No way to access property " + names[start] + " on object " + instance + " of " + instance.getClass() + "--possibly null?"); } } else { return nextProp; } } |
getArticleItemBean().clear(); | ArticleItemBean bean = getArticleItemBean(); if(bean!=null){ bean.clear(); } | protected void initializeContent() { setId(EDIT_ARTICLE_BLOCK_ID); if(clearOnInit){ getArticleItemBean().clear(); } // WFUtil.invoke(EDIT_ARTICLES_BEAN_ID, "setArticleLinkListener", this, ActionListener.class); add(getEditContainer()); } |
final JWindow frame = new JWindow(parent); final JContactItemField contactField = new JContactItemField(new ArrayList(contacts), frame); | window = new JWindow(parent); final JContactItemField contactField = new JContactItemField(new ArrayList(contacts)); | public void searchContacts(String contact, JFrame parent) { final Map contactMap = new HashMap(); final Set contacts = new HashSet(); final ContactList contactList = SparkManager.getWorkspace().getContactList(); Iterator groups = contactList.getContactGroups().iterator(); while (groups.hasNext()) { ContactGroup group = (ContactGroup)groups.next(); Iterator contactItems = group.getContactItems().iterator(); while (contactItems.hasNext()) { ContactItem item = (ContactItem)contactItems.next(); if (contactMap.get(item.getNickname()) == null) { contacts.add(item); contactMap.put(item.getNickname(), item); } } } final JWindow frame = new JWindow(parent); final JContactItemField contactField = new JContactItemField(new ArrayList(contacts), frame); JPanel layoutPanel = new JPanel(); layoutPanel.setLayout(new GridBagLayout()); frame.getContentPane().setLayout(new BorderLayout()); JLabel enterLabel = new JLabel(Res.getString("label.contact.to.find")); enterLabel.setFont(new Font("dialog", Font.BOLD, 10)); layoutPanel.add(enterLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0)); layoutPanel.add(contactField, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 200, 0)); layoutPanel.setBorder(BorderFactory.createBevelBorder(0)); frame.getContentPane().add(layoutPanel); frame.pack(); frame.setLocationRelativeTo(parent); frame.setVisible(true); frame.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent keyEvent) { if (keyEvent.getKeyChar() == KeyEvent.VK_ESCAPE) { frame.dispose(); } } }); contactField.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent keyEvent) { if (keyEvent.getKeyChar() == KeyEvent.VK_ENTER) { if (ModelUtil.hasLength(contactField.getText())) { ContactItem item = (ContactItem)contactMap.get(contactField.getText()); if (item != null) { SparkManager.getChatManager().activateChat(item.getFullJID(), item.getNickname()); frame.dispose(); } } } else if (keyEvent.getKeyChar() == KeyEvent.VK_ESCAPE) { frame.dispose(); } } }); contactField.setText(contact); } |
frame.getContentPane().setLayout(new BorderLayout()); | window.setLayout(new BorderLayout()); | public void searchContacts(String contact, JFrame parent) { final Map contactMap = new HashMap(); final Set contacts = new HashSet(); final ContactList contactList = SparkManager.getWorkspace().getContactList(); Iterator groups = contactList.getContactGroups().iterator(); while (groups.hasNext()) { ContactGroup group = (ContactGroup)groups.next(); Iterator contactItems = group.getContactItems().iterator(); while (contactItems.hasNext()) { ContactItem item = (ContactItem)contactItems.next(); if (contactMap.get(item.getNickname()) == null) { contacts.add(item); contactMap.put(item.getNickname(), item); } } } final JWindow frame = new JWindow(parent); final JContactItemField contactField = new JContactItemField(new ArrayList(contacts), frame); JPanel layoutPanel = new JPanel(); layoutPanel.setLayout(new GridBagLayout()); frame.getContentPane().setLayout(new BorderLayout()); JLabel enterLabel = new JLabel(Res.getString("label.contact.to.find")); enterLabel.setFont(new Font("dialog", Font.BOLD, 10)); layoutPanel.add(enterLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0)); layoutPanel.add(contactField, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 200, 0)); layoutPanel.setBorder(BorderFactory.createBevelBorder(0)); frame.getContentPane().add(layoutPanel); frame.pack(); frame.setLocationRelativeTo(parent); frame.setVisible(true); frame.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent keyEvent) { if (keyEvent.getKeyChar() == KeyEvent.VK_ESCAPE) { frame.dispose(); } } }); contactField.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent keyEvent) { if (keyEvent.getKeyChar() == KeyEvent.VK_ENTER) { if (ModelUtil.hasLength(contactField.getText())) { ContactItem item = (ContactItem)contactMap.get(contactField.getText()); if (item != null) { SparkManager.getChatManager().activateChat(item.getFullJID(), item.getNickname()); frame.dispose(); } } } else if (keyEvent.getKeyChar() == KeyEvent.VK_ESCAPE) { frame.dispose(); } } }); contactField.setText(contact); } |
frame.getContentPane().add(layoutPanel); | window.add(layoutPanel); | public void searchContacts(String contact, JFrame parent) { final Map contactMap = new HashMap(); final Set contacts = new HashSet(); final ContactList contactList = SparkManager.getWorkspace().getContactList(); Iterator groups = contactList.getContactGroups().iterator(); while (groups.hasNext()) { ContactGroup group = (ContactGroup)groups.next(); Iterator contactItems = group.getContactItems().iterator(); while (contactItems.hasNext()) { ContactItem item = (ContactItem)contactItems.next(); if (contactMap.get(item.getNickname()) == null) { contacts.add(item); contactMap.put(item.getNickname(), item); } } } final JWindow frame = new JWindow(parent); final JContactItemField contactField = new JContactItemField(new ArrayList(contacts), frame); JPanel layoutPanel = new JPanel(); layoutPanel.setLayout(new GridBagLayout()); frame.getContentPane().setLayout(new BorderLayout()); JLabel enterLabel = new JLabel(Res.getString("label.contact.to.find")); enterLabel.setFont(new Font("dialog", Font.BOLD, 10)); layoutPanel.add(enterLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0)); layoutPanel.add(contactField, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 200, 0)); layoutPanel.setBorder(BorderFactory.createBevelBorder(0)); frame.getContentPane().add(layoutPanel); frame.pack(); frame.setLocationRelativeTo(parent); frame.setVisible(true); frame.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent keyEvent) { if (keyEvent.getKeyChar() == KeyEvent.VK_ESCAPE) { frame.dispose(); } } }); contactField.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent keyEvent) { if (keyEvent.getKeyChar() == KeyEvent.VK_ENTER) { if (ModelUtil.hasLength(contactField.getText())) { ContactItem item = (ContactItem)contactMap.get(contactField.getText()); if (item != null) { SparkManager.getChatManager().activateChat(item.getFullJID(), item.getNickname()); frame.dispose(); } } } else if (keyEvent.getKeyChar() == KeyEvent.VK_ESCAPE) { frame.dispose(); } } }); contactField.setText(contact); } |
frame.pack(); | window.pack(); | public void searchContacts(String contact, JFrame parent) { final Map contactMap = new HashMap(); final Set contacts = new HashSet(); final ContactList contactList = SparkManager.getWorkspace().getContactList(); Iterator groups = contactList.getContactGroups().iterator(); while (groups.hasNext()) { ContactGroup group = (ContactGroup)groups.next(); Iterator contactItems = group.getContactItems().iterator(); while (contactItems.hasNext()) { ContactItem item = (ContactItem)contactItems.next(); if (contactMap.get(item.getNickname()) == null) { contacts.add(item); contactMap.put(item.getNickname(), item); } } } final JWindow frame = new JWindow(parent); final JContactItemField contactField = new JContactItemField(new ArrayList(contacts), frame); JPanel layoutPanel = new JPanel(); layoutPanel.setLayout(new GridBagLayout()); frame.getContentPane().setLayout(new BorderLayout()); JLabel enterLabel = new JLabel(Res.getString("label.contact.to.find")); enterLabel.setFont(new Font("dialog", Font.BOLD, 10)); layoutPanel.add(enterLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0)); layoutPanel.add(contactField, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 200, 0)); layoutPanel.setBorder(BorderFactory.createBevelBorder(0)); frame.getContentPane().add(layoutPanel); frame.pack(); frame.setLocationRelativeTo(parent); frame.setVisible(true); frame.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent keyEvent) { if (keyEvent.getKeyChar() == KeyEvent.VK_ESCAPE) { frame.dispose(); } } }); contactField.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent keyEvent) { if (keyEvent.getKeyChar() == KeyEvent.VK_ENTER) { if (ModelUtil.hasLength(contactField.getText())) { ContactItem item = (ContactItem)contactMap.get(contactField.getText()); if (item != null) { SparkManager.getChatManager().activateChat(item.getFullJID(), item.getNickname()); frame.dispose(); } } } else if (keyEvent.getKeyChar() == KeyEvent.VK_ESCAPE) { frame.dispose(); } } }); contactField.setText(contact); } |
frame.setLocationRelativeTo(parent); frame.setVisible(true); | window.setLocationRelativeTo(parent); window.setVisible(true); | public void searchContacts(String contact, JFrame parent) { final Map contactMap = new HashMap(); final Set contacts = new HashSet(); final ContactList contactList = SparkManager.getWorkspace().getContactList(); Iterator groups = contactList.getContactGroups().iterator(); while (groups.hasNext()) { ContactGroup group = (ContactGroup)groups.next(); Iterator contactItems = group.getContactItems().iterator(); while (contactItems.hasNext()) { ContactItem item = (ContactItem)contactItems.next(); if (contactMap.get(item.getNickname()) == null) { contacts.add(item); contactMap.put(item.getNickname(), item); } } } final JWindow frame = new JWindow(parent); final JContactItemField contactField = new JContactItemField(new ArrayList(contacts), frame); JPanel layoutPanel = new JPanel(); layoutPanel.setLayout(new GridBagLayout()); frame.getContentPane().setLayout(new BorderLayout()); JLabel enterLabel = new JLabel(Res.getString("label.contact.to.find")); enterLabel.setFont(new Font("dialog", Font.BOLD, 10)); layoutPanel.add(enterLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0)); layoutPanel.add(contactField, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 200, 0)); layoutPanel.setBorder(BorderFactory.createBevelBorder(0)); frame.getContentPane().add(layoutPanel); frame.pack(); frame.setLocationRelativeTo(parent); frame.setVisible(true); frame.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent keyEvent) { if (keyEvent.getKeyChar() == KeyEvent.VK_ESCAPE) { frame.dispose(); } } }); contactField.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent keyEvent) { if (keyEvent.getKeyChar() == KeyEvent.VK_ENTER) { if (ModelUtil.hasLength(contactField.getText())) { ContactItem item = (ContactItem)contactMap.get(contactField.getText()); if (item != null) { SparkManager.getChatManager().activateChat(item.getFullJID(), item.getNickname()); frame.dispose(); } } } else if (keyEvent.getKeyChar() == KeyEvent.VK_ESCAPE) { frame.dispose(); } } }); contactField.setText(contact); } |
frame.addKeyListener(new KeyAdapter() { | window.addKeyListener(new KeyAdapter() { | public void searchContacts(String contact, JFrame parent) { final Map contactMap = new HashMap(); final Set contacts = new HashSet(); final ContactList contactList = SparkManager.getWorkspace().getContactList(); Iterator groups = contactList.getContactGroups().iterator(); while (groups.hasNext()) { ContactGroup group = (ContactGroup)groups.next(); Iterator contactItems = group.getContactItems().iterator(); while (contactItems.hasNext()) { ContactItem item = (ContactItem)contactItems.next(); if (contactMap.get(item.getNickname()) == null) { contacts.add(item); contactMap.put(item.getNickname(), item); } } } final JWindow frame = new JWindow(parent); final JContactItemField contactField = new JContactItemField(new ArrayList(contacts), frame); JPanel layoutPanel = new JPanel(); layoutPanel.setLayout(new GridBagLayout()); frame.getContentPane().setLayout(new BorderLayout()); JLabel enterLabel = new JLabel(Res.getString("label.contact.to.find")); enterLabel.setFont(new Font("dialog", Font.BOLD, 10)); layoutPanel.add(enterLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0)); layoutPanel.add(contactField, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 200, 0)); layoutPanel.setBorder(BorderFactory.createBevelBorder(0)); frame.getContentPane().add(layoutPanel); frame.pack(); frame.setLocationRelativeTo(parent); frame.setVisible(true); frame.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent keyEvent) { if (keyEvent.getKeyChar() == KeyEvent.VK_ESCAPE) { frame.dispose(); } } }); contactField.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent keyEvent) { if (keyEvent.getKeyChar() == KeyEvent.VK_ENTER) { if (ModelUtil.hasLength(contactField.getText())) { ContactItem item = (ContactItem)contactMap.get(contactField.getText()); if (item != null) { SparkManager.getChatManager().activateChat(item.getFullJID(), item.getNickname()); frame.dispose(); } } } else if (keyEvent.getKeyChar() == KeyEvent.VK_ESCAPE) { frame.dispose(); } } }); contactField.setText(contact); } |
frame.dispose(); | window.dispose(); | public void searchContacts(String contact, JFrame parent) { final Map contactMap = new HashMap(); final Set contacts = new HashSet(); final ContactList contactList = SparkManager.getWorkspace().getContactList(); Iterator groups = contactList.getContactGroups().iterator(); while (groups.hasNext()) { ContactGroup group = (ContactGroup)groups.next(); Iterator contactItems = group.getContactItems().iterator(); while (contactItems.hasNext()) { ContactItem item = (ContactItem)contactItems.next(); if (contactMap.get(item.getNickname()) == null) { contacts.add(item); contactMap.put(item.getNickname(), item); } } } final JWindow frame = new JWindow(parent); final JContactItemField contactField = new JContactItemField(new ArrayList(contacts), frame); JPanel layoutPanel = new JPanel(); layoutPanel.setLayout(new GridBagLayout()); frame.getContentPane().setLayout(new BorderLayout()); JLabel enterLabel = new JLabel(Res.getString("label.contact.to.find")); enterLabel.setFont(new Font("dialog", Font.BOLD, 10)); layoutPanel.add(enterLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0)); layoutPanel.add(contactField, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 200, 0)); layoutPanel.setBorder(BorderFactory.createBevelBorder(0)); frame.getContentPane().add(layoutPanel); frame.pack(); frame.setLocationRelativeTo(parent); frame.setVisible(true); frame.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent keyEvent) { if (keyEvent.getKeyChar() == KeyEvent.VK_ESCAPE) { frame.dispose(); } } }); contactField.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent keyEvent) { if (keyEvent.getKeyChar() == KeyEvent.VK_ENTER) { if (ModelUtil.hasLength(contactField.getText())) { ContactItem item = (ContactItem)contactMap.get(contactField.getText()); if (item != null) { SparkManager.getChatManager().activateChat(item.getFullJID(), item.getNickname()); frame.dispose(); } } } else if (keyEvent.getKeyChar() == KeyEvent.VK_ESCAPE) { frame.dispose(); } } }); contactField.setText(contact); } |
frame.dispose(); | window.dispose(); | public void keyPressed(KeyEvent keyEvent) { if (keyEvent.getKeyChar() == KeyEvent.VK_ESCAPE) { frame.dispose(); } } |
frame.dispose(); | window.dispose(); | public void keyReleased(KeyEvent keyEvent) { if (keyEvent.getKeyChar() == KeyEvent.VK_ENTER) { if (ModelUtil.hasLength(contactField.getText())) { ContactItem item = (ContactItem)contactMap.get(contactField.getText()); if (item != null) { SparkManager.getChatManager().activateChat(item.getFullJID(), item.getNickname()); frame.dispose(); } } } else if (keyEvent.getKeyChar() == KeyEvent.VK_ESCAPE) { frame.dispose(); } } |
public void visitBeanFactory(ConfigurableListableBeanFactory beanRegistry) throws BeansException { | public void visitBeanFactory(ConfigurableListableBeanFactory beanRegistry, Object data) throws BeansException { | public void visitBeanFactory(ConfigurableListableBeanFactory beanRegistry) throws BeansException { String[] beanNames = beanRegistry.getBeanDefinitionNames(); for (int i = 0; i < beanNames.length; i++) { String beanName = beanNames[i]; visitBeanDefinition(beanName, beanRegistry.getBeanDefinition(beanName)); } } |
visitBeanDefinition(beanName, beanRegistry.getBeanDefinition(beanName)); | visitBeanDefinition(beanName, beanRegistry.getBeanDefinition(beanName), data); | public void visitBeanFactory(ConfigurableListableBeanFactory beanRegistry) throws BeansException { String[] beanNames = beanRegistry.getBeanDefinitionNames(); for (int i = 0; i < beanNames.length; i++) { String beanName = beanNames[i]; visitBeanDefinition(beanName, beanRegistry.getBeanDefinition(beanName)); } } |
public void visitCollection(Collection collection) throws BeansException { | public void visitCollection(Collection collection, Object data) throws BeansException { | public void visitCollection(Collection collection) throws BeansException { for (Iterator iterator = collection.iterator(); iterator.hasNext();) { visitNext(iterator.next()); } } |
visitNext(iterator.next()); | visitNext(iterator.next(), data); | public void visitCollection(Collection collection) throws BeansException { for (Iterator iterator = collection.iterator(); iterator.hasNext();) { visitNext(iterator.next()); } } |
public void visitConstructorArgumentValues(ConstructorArgumentValues constructorArgumentValues) throws BeansException { | public void visitConstructorArgumentValues(ConstructorArgumentValues constructorArgumentValues, Object data) throws BeansException { | public void visitConstructorArgumentValues(ConstructorArgumentValues constructorArgumentValues) throws BeansException { Map indexedArgumentValues = constructorArgumentValues.getIndexedArgumentValues(); for (Iterator iterator = indexedArgumentValues.values().iterator(); iterator.hasNext();) { visitConstructorArgumentValues((ConstructorArgumentValues.ValueHolder) iterator.next()); } Set genericArgumentValues = constructorArgumentValues.getGenericArgumentValues(); for (Iterator iterator = genericArgumentValues.iterator(); iterator.hasNext();) { visitConstructorArgumentValues((ConstructorArgumentValues.ValueHolder) iterator.next()); } } |
visitConstructorArgumentValues((ConstructorArgumentValues.ValueHolder) iterator.next()); | visitConstructorArgumentValue((ConstructorArgumentValues.ValueHolder) iterator.next(), data); | public void visitConstructorArgumentValues(ConstructorArgumentValues constructorArgumentValues) throws BeansException { Map indexedArgumentValues = constructorArgumentValues.getIndexedArgumentValues(); for (Iterator iterator = indexedArgumentValues.values().iterator(); iterator.hasNext();) { visitConstructorArgumentValues((ConstructorArgumentValues.ValueHolder) iterator.next()); } Set genericArgumentValues = constructorArgumentValues.getGenericArgumentValues(); for (Iterator iterator = genericArgumentValues.iterator(); iterator.hasNext();) { visitConstructorArgumentValues((ConstructorArgumentValues.ValueHolder) iterator.next()); } } |
Set genericArgumentValues = constructorArgumentValues.getGenericArgumentValues(); | List genericArgumentValues = constructorArgumentValues.getGenericArgumentValues(); | public void visitConstructorArgumentValues(ConstructorArgumentValues constructorArgumentValues) throws BeansException { Map indexedArgumentValues = constructorArgumentValues.getIndexedArgumentValues(); for (Iterator iterator = indexedArgumentValues.values().iterator(); iterator.hasNext();) { visitConstructorArgumentValues((ConstructorArgumentValues.ValueHolder) iterator.next()); } Set genericArgumentValues = constructorArgumentValues.getGenericArgumentValues(); for (Iterator iterator = genericArgumentValues.iterator(); iterator.hasNext();) { visitConstructorArgumentValues((ConstructorArgumentValues.ValueHolder) iterator.next()); } } |
public void visitMap(Map map) throws BeansException { | public void visitMap(Map map, Object data) throws BeansException { | public void visitMap(Map map) throws BeansException { for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) { Map.Entry entry = (Map.Entry) iterator.next(); visitNext(entry.getKey()); visitNext(entry.getValue()); } } |
visitNext(entry.getKey()); visitNext(entry.getValue()); | visitNext(entry.getKey(), data); visitNext(entry.getValue(), data); | public void visitMap(Map map) throws BeansException { for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) { Map.Entry entry = (Map.Entry) iterator.next(); visitNext(entry.getKey()); visitNext(entry.getValue()); } } |
public void visitMutablePropertyValues(MutablePropertyValues propertyValues) throws BeansException { | public void visitMutablePropertyValues(MutablePropertyValues propertyValues, Object data) throws BeansException { | public void visitMutablePropertyValues(MutablePropertyValues propertyValues) throws BeansException { PropertyValue[] values = propertyValues.getPropertyValues(); for (int i = 0; i < values.length; i++) { visitPropertyValue(values[i]); } } |
visitPropertyValue(values[i]); | visitPropertyValue(values[i], data); | public void visitMutablePropertyValues(MutablePropertyValues propertyValues) throws BeansException { PropertyValue[] values = propertyValues.getPropertyValues(); for (int i = 0; i < values.length; i++) { visitPropertyValue(values[i]); } } |
protected void visitNext(Object value) throws BeansException { | protected void visitNext(Object value, Object data) throws BeansException { | protected void visitNext(Object value) throws BeansException { if (value == null) { return; } if (value instanceof ConfigurableListableBeanFactory) { visitBeanFactory((ConfigurableListableBeanFactory) value); } else if (value instanceof BeanDefinition) { visitBeanDefinition((BeanDefinition) value); } else if (value instanceof ConstructorArgumentValues) { visitConstructorArgumentValues((ConstructorArgumentValues) value); } else if (value instanceof ConstructorArgumentValues.ValueHolder) { visitConstructorArgumentValues((ConstructorArgumentValues.ValueHolder) value); } else if (value instanceof MutablePropertyValues) { visitMutablePropertyValues((MutablePropertyValues) value); } else if (value instanceof PropertyValue) { visitPropertyValue((PropertyValue) value); } else if (value instanceof RuntimeBeanReference) { visitRuntimeBeanReference((RuntimeBeanReference) value); } else if (value instanceof Map) { visitMap((Map) value); } else if (value instanceof Collection) { visitCollection((Collection) value); } else { visitObject(value); } } |
visitBeanFactory((ConfigurableListableBeanFactory) value); | visitBeanFactory((ConfigurableListableBeanFactory) value, data); } else if (value instanceof BeanDefinitionHolder) { visitBeanDefinitionHolder((BeanDefinitionHolder) value, data); | protected void visitNext(Object value) throws BeansException { if (value == null) { return; } if (value instanceof ConfigurableListableBeanFactory) { visitBeanFactory((ConfigurableListableBeanFactory) value); } else if (value instanceof BeanDefinition) { visitBeanDefinition((BeanDefinition) value); } else if (value instanceof ConstructorArgumentValues) { visitConstructorArgumentValues((ConstructorArgumentValues) value); } else if (value instanceof ConstructorArgumentValues.ValueHolder) { visitConstructorArgumentValues((ConstructorArgumentValues.ValueHolder) value); } else if (value instanceof MutablePropertyValues) { visitMutablePropertyValues((MutablePropertyValues) value); } else if (value instanceof PropertyValue) { visitPropertyValue((PropertyValue) value); } else if (value instanceof RuntimeBeanReference) { visitRuntimeBeanReference((RuntimeBeanReference) value); } else if (value instanceof Map) { visitMap((Map) value); } else if (value instanceof Collection) { visitCollection((Collection) value); } else { visitObject(value); } } |
visitBeanDefinition((BeanDefinition) value); | visitBeanDefinition((BeanDefinition) value, data); | protected void visitNext(Object value) throws BeansException { if (value == null) { return; } if (value instanceof ConfigurableListableBeanFactory) { visitBeanFactory((ConfigurableListableBeanFactory) value); } else if (value instanceof BeanDefinition) { visitBeanDefinition((BeanDefinition) value); } else if (value instanceof ConstructorArgumentValues) { visitConstructorArgumentValues((ConstructorArgumentValues) value); } else if (value instanceof ConstructorArgumentValues.ValueHolder) { visitConstructorArgumentValues((ConstructorArgumentValues.ValueHolder) value); } else if (value instanceof MutablePropertyValues) { visitMutablePropertyValues((MutablePropertyValues) value); } else if (value instanceof PropertyValue) { visitPropertyValue((PropertyValue) value); } else if (value instanceof RuntimeBeanReference) { visitRuntimeBeanReference((RuntimeBeanReference) value); } else if (value instanceof Map) { visitMap((Map) value); } else if (value instanceof Collection) { visitCollection((Collection) value); } else { visitObject(value); } } |
visitConstructorArgumentValues((ConstructorArgumentValues) value); | visitConstructorArgumentValues((ConstructorArgumentValues) value, data); | protected void visitNext(Object value) throws BeansException { if (value == null) { return; } if (value instanceof ConfigurableListableBeanFactory) { visitBeanFactory((ConfigurableListableBeanFactory) value); } else if (value instanceof BeanDefinition) { visitBeanDefinition((BeanDefinition) value); } else if (value instanceof ConstructorArgumentValues) { visitConstructorArgumentValues((ConstructorArgumentValues) value); } else if (value instanceof ConstructorArgumentValues.ValueHolder) { visitConstructorArgumentValues((ConstructorArgumentValues.ValueHolder) value); } else if (value instanceof MutablePropertyValues) { visitMutablePropertyValues((MutablePropertyValues) value); } else if (value instanceof PropertyValue) { visitPropertyValue((PropertyValue) value); } else if (value instanceof RuntimeBeanReference) { visitRuntimeBeanReference((RuntimeBeanReference) value); } else if (value instanceof Map) { visitMap((Map) value); } else if (value instanceof Collection) { visitCollection((Collection) value); } else { visitObject(value); } } |
visitConstructorArgumentValues((ConstructorArgumentValues.ValueHolder) value); | visitConstructorArgumentValue((ConstructorArgumentValues.ValueHolder) value, data); | protected void visitNext(Object value) throws BeansException { if (value == null) { return; } if (value instanceof ConfigurableListableBeanFactory) { visitBeanFactory((ConfigurableListableBeanFactory) value); } else if (value instanceof BeanDefinition) { visitBeanDefinition((BeanDefinition) value); } else if (value instanceof ConstructorArgumentValues) { visitConstructorArgumentValues((ConstructorArgumentValues) value); } else if (value instanceof ConstructorArgumentValues.ValueHolder) { visitConstructorArgumentValues((ConstructorArgumentValues.ValueHolder) value); } else if (value instanceof MutablePropertyValues) { visitMutablePropertyValues((MutablePropertyValues) value); } else if (value instanceof PropertyValue) { visitPropertyValue((PropertyValue) value); } else if (value instanceof RuntimeBeanReference) { visitRuntimeBeanReference((RuntimeBeanReference) value); } else if (value instanceof Map) { visitMap((Map) value); } else if (value instanceof Collection) { visitCollection((Collection) value); } else { visitObject(value); } } |
visitMutablePropertyValues((MutablePropertyValues) value); | visitMutablePropertyValues((MutablePropertyValues) value, data); | protected void visitNext(Object value) throws BeansException { if (value == null) { return; } if (value instanceof ConfigurableListableBeanFactory) { visitBeanFactory((ConfigurableListableBeanFactory) value); } else if (value instanceof BeanDefinition) { visitBeanDefinition((BeanDefinition) value); } else if (value instanceof ConstructorArgumentValues) { visitConstructorArgumentValues((ConstructorArgumentValues) value); } else if (value instanceof ConstructorArgumentValues.ValueHolder) { visitConstructorArgumentValues((ConstructorArgumentValues.ValueHolder) value); } else if (value instanceof MutablePropertyValues) { visitMutablePropertyValues((MutablePropertyValues) value); } else if (value instanceof PropertyValue) { visitPropertyValue((PropertyValue) value); } else if (value instanceof RuntimeBeanReference) { visitRuntimeBeanReference((RuntimeBeanReference) value); } else if (value instanceof Map) { visitMap((Map) value); } else if (value instanceof Collection) { visitCollection((Collection) value); } else { visitObject(value); } } |
visitPropertyValue((PropertyValue) value); | visitPropertyValue((PropertyValue) value, data); | protected void visitNext(Object value) throws BeansException { if (value == null) { return; } if (value instanceof ConfigurableListableBeanFactory) { visitBeanFactory((ConfigurableListableBeanFactory) value); } else if (value instanceof BeanDefinition) { visitBeanDefinition((BeanDefinition) value); } else if (value instanceof ConstructorArgumentValues) { visitConstructorArgumentValues((ConstructorArgumentValues) value); } else if (value instanceof ConstructorArgumentValues.ValueHolder) { visitConstructorArgumentValues((ConstructorArgumentValues.ValueHolder) value); } else if (value instanceof MutablePropertyValues) { visitMutablePropertyValues((MutablePropertyValues) value); } else if (value instanceof PropertyValue) { visitPropertyValue((PropertyValue) value); } else if (value instanceof RuntimeBeanReference) { visitRuntimeBeanReference((RuntimeBeanReference) value); } else if (value instanceof Map) { visitMap((Map) value); } else if (value instanceof Collection) { visitCollection((Collection) value); } else { visitObject(value); } } |
visitRuntimeBeanReference((RuntimeBeanReference) value); | visitRuntimeBeanReference((RuntimeBeanReference) value, data); | protected void visitNext(Object value) throws BeansException { if (value == null) { return; } if (value instanceof ConfigurableListableBeanFactory) { visitBeanFactory((ConfigurableListableBeanFactory) value); } else if (value instanceof BeanDefinition) { visitBeanDefinition((BeanDefinition) value); } else if (value instanceof ConstructorArgumentValues) { visitConstructorArgumentValues((ConstructorArgumentValues) value); } else if (value instanceof ConstructorArgumentValues.ValueHolder) { visitConstructorArgumentValues((ConstructorArgumentValues.ValueHolder) value); } else if (value instanceof MutablePropertyValues) { visitMutablePropertyValues((MutablePropertyValues) value); } else if (value instanceof PropertyValue) { visitPropertyValue((PropertyValue) value); } else if (value instanceof RuntimeBeanReference) { visitRuntimeBeanReference((RuntimeBeanReference) value); } else if (value instanceof Map) { visitMap((Map) value); } else if (value instanceof Collection) { visitCollection((Collection) value); } else { visitObject(value); } } |
visitMap((Map) value); | visitMap((Map) value, data); | protected void visitNext(Object value) throws BeansException { if (value == null) { return; } if (value instanceof ConfigurableListableBeanFactory) { visitBeanFactory((ConfigurableListableBeanFactory) value); } else if (value instanceof BeanDefinition) { visitBeanDefinition((BeanDefinition) value); } else if (value instanceof ConstructorArgumentValues) { visitConstructorArgumentValues((ConstructorArgumentValues) value); } else if (value instanceof ConstructorArgumentValues.ValueHolder) { visitConstructorArgumentValues((ConstructorArgumentValues.ValueHolder) value); } else if (value instanceof MutablePropertyValues) { visitMutablePropertyValues((MutablePropertyValues) value); } else if (value instanceof PropertyValue) { visitPropertyValue((PropertyValue) value); } else if (value instanceof RuntimeBeanReference) { visitRuntimeBeanReference((RuntimeBeanReference) value); } else if (value instanceof Map) { visitMap((Map) value); } else if (value instanceof Collection) { visitCollection((Collection) value); } else { visitObject(value); } } |
visitCollection((Collection) value); | visitCollection((Collection) value, data); | protected void visitNext(Object value) throws BeansException { if (value == null) { return; } if (value instanceof ConfigurableListableBeanFactory) { visitBeanFactory((ConfigurableListableBeanFactory) value); } else if (value instanceof BeanDefinition) { visitBeanDefinition((BeanDefinition) value); } else if (value instanceof ConstructorArgumentValues) { visitConstructorArgumentValues((ConstructorArgumentValues) value); } else if (value instanceof ConstructorArgumentValues.ValueHolder) { visitConstructorArgumentValues((ConstructorArgumentValues.ValueHolder) value); } else if (value instanceof MutablePropertyValues) { visitMutablePropertyValues((MutablePropertyValues) value); } else if (value instanceof PropertyValue) { visitPropertyValue((PropertyValue) value); } else if (value instanceof RuntimeBeanReference) { visitRuntimeBeanReference((RuntimeBeanReference) value); } else if (value instanceof Map) { visitMap((Map) value); } else if (value instanceof Collection) { visitCollection((Collection) value); } else { visitObject(value); } } |
visitObject(value); | visitObject(value, data); | protected void visitNext(Object value) throws BeansException { if (value == null) { return; } if (value instanceof ConfigurableListableBeanFactory) { visitBeanFactory((ConfigurableListableBeanFactory) value); } else if (value instanceof BeanDefinition) { visitBeanDefinition((BeanDefinition) value); } else if (value instanceof ConstructorArgumentValues) { visitConstructorArgumentValues((ConstructorArgumentValues) value); } else if (value instanceof ConstructorArgumentValues.ValueHolder) { visitConstructorArgumentValues((ConstructorArgumentValues.ValueHolder) value); } else if (value instanceof MutablePropertyValues) { visitMutablePropertyValues((MutablePropertyValues) value); } else if (value instanceof PropertyValue) { visitPropertyValue((PropertyValue) value); } else if (value instanceof RuntimeBeanReference) { visitRuntimeBeanReference((RuntimeBeanReference) value); } else if (value instanceof Map) { visitMap((Map) value); } else if (value instanceof Collection) { visitCollection((Collection) value); } else { visitObject(value); } } |
public void visitObject(Object value) throws BeansException { | public void visitObject(Object value, Object data) throws BeansException { | public void visitObject(Object value) throws BeansException { } |
public void visitPropertyValue(PropertyValue propertyValue) throws BeansException { visitNext(propertyValue.getValue()); | public void visitPropertyValue(PropertyValue propertyValue, Object data) throws BeansException { visitNext(propertyValue.getValue(), data); | public void visitPropertyValue(PropertyValue propertyValue) throws BeansException { visitNext(propertyValue.getValue()); } |
TransportManager.registerUser(SparkManager.getConnection(), serviceName, username, password); | TransportUtils.registerUser(SparkManager.getConnection(), serviceName, username, password); | public void actionPerformed(ActionEvent e) { String username = getScreenName(); String password = getPassword(); if (!ModelUtil.hasLength(username) || !ModelUtil.hasLength(password)) { JOptionPane.showMessageDialog(this, Res.getString("message.username.password.error"), Res.getString("title.registration.error"), JOptionPane.ERROR_MESSAGE); return; } try { TransportManager.registerUser(SparkManager.getConnection(), serviceName, username, password); // Send Presence final StatusBar statusBar = SparkManager.getWorkspace().getStatusBar(); Presence presence = statusBar.getPresence(); presence.setTo(transport.getServiceName()); SparkManager.getConnection().sendPacket(presence); } catch (XMPPException e1) { e1.printStackTrace(); JOptionPane.showMessageDialog(this, Res.getString("message.registration.transport.failed"), Res.getString("title.registration.error"), JOptionPane.ERROR_MESSAGE); } dialog.dispose(); } |
new XmlMetadataGenerator(this, outputDir.getAbsolutePath(), schema), new DocumentationGenerator(this, schema), new XsdGenerator(this, schema) | new XmlMetadataGenerator(outputDir.getAbsolutePath(), schema), new DocumentationGenerator(schema), new XsdGenerator(schema), new WikiDocumentationGenerator(schema), | public void execute() throws MojoExecutionException, MojoFailureException { getLog().debug( " ======= XBeanMojo settings =======" ); getLog().debug( "namespace[" + namespace + "]" ); getLog().debug( "srcDir[" + srcDir + "]" ); getLog().debug( "schema[" + schema + "]" ); getLog().debug( "excludedClasses" + excludedClasses ); getLog().debug( "outputDir[" + outputDir + "]" ); getLog().debug( "propertyEditorPaths[" + propertyEditorPaths + "]" ); if (schema == null) { schema = new File(outputDir, project.getArtifactId() + ".xsd"); } if (propertyEditorPaths != null) { List editorSearchPath = new LinkedList(Arrays.asList(PropertyEditorManager.getEditorSearchPath())); StringTokenizer paths = new StringTokenizer(propertyEditorPaths, " ,"); editorSearchPath.addAll(Collections.list(paths)); PropertyEditorManager.setEditorSearchPath((String[]) editorSearchPath.toArray(new String[editorSearchPath.size()])); } ClassLoader oldCL = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); try { schema.getParentFile().mkdirs(); String[] excludedClasses = null; if (this.excludedClasses != null) { excludedClasses = this.excludedClasses.split(" *, *"); } MappingLoader mappingLoader = new QdoxMappingLoader(namespace, new File[] { srcDir }, excludedClasses); GeneratorPlugin[] plugins = new GeneratorPlugin[]{ new XmlMetadataGenerator(this, outputDir.getAbsolutePath(), schema), new DocumentationGenerator(this, schema), new XsdGenerator(this, schema) }; // load the mappings Set namespaces = mappingLoader.loadNamespaces(); if (namespaces.isEmpty()) { System.out.println("Warning: no namespaces found!"); } // generate the files for (Iterator iterator = namespaces.iterator(); iterator.hasNext();) { NamespaceMapping namespaceMapping = (NamespaceMapping) iterator.next(); for (int i = 0; i < plugins.length; i++) { GeneratorPlugin plugin = plugins[i]; plugin.generate(namespaceMapping); } } Resource res = new Resource(); res.setDirectory(outputDir.toString()); project.addResource(res); log("...done."); } catch (Exception e) { throw new BuildException(e); } finally { Thread.currentThread().setContextClassLoader(oldCL); } } |
} | } for (Iterator iter = generatorPlugins.iterator(); iter.hasNext();) { GeneratorPlugin plugin = (GeneratorPlugin) iter.next(); plugin.setLog(this); plugin.generate(namespaceMapping); } | public void execute() throws MojoExecutionException, MojoFailureException { getLog().debug( " ======= XBeanMojo settings =======" ); getLog().debug( "namespace[" + namespace + "]" ); getLog().debug( "srcDir[" + srcDir + "]" ); getLog().debug( "schema[" + schema + "]" ); getLog().debug( "excludedClasses" + excludedClasses ); getLog().debug( "outputDir[" + outputDir + "]" ); getLog().debug( "propertyEditorPaths[" + propertyEditorPaths + "]" ); if (schema == null) { schema = new File(outputDir, project.getArtifactId() + ".xsd"); } if (propertyEditorPaths != null) { List editorSearchPath = new LinkedList(Arrays.asList(PropertyEditorManager.getEditorSearchPath())); StringTokenizer paths = new StringTokenizer(propertyEditorPaths, " ,"); editorSearchPath.addAll(Collections.list(paths)); PropertyEditorManager.setEditorSearchPath((String[]) editorSearchPath.toArray(new String[editorSearchPath.size()])); } ClassLoader oldCL = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); try { schema.getParentFile().mkdirs(); String[] excludedClasses = null; if (this.excludedClasses != null) { excludedClasses = this.excludedClasses.split(" *, *"); } MappingLoader mappingLoader = new QdoxMappingLoader(namespace, new File[] { srcDir }, excludedClasses); GeneratorPlugin[] plugins = new GeneratorPlugin[]{ new XmlMetadataGenerator(this, outputDir.getAbsolutePath(), schema), new DocumentationGenerator(this, schema), new XsdGenerator(this, schema) }; // load the mappings Set namespaces = mappingLoader.loadNamespaces(); if (namespaces.isEmpty()) { System.out.println("Warning: no namespaces found!"); } // generate the files for (Iterator iterator = namespaces.iterator(); iterator.hasNext();) { NamespaceMapping namespaceMapping = (NamespaceMapping) iterator.next(); for (int i = 0; i < plugins.length; i++) { GeneratorPlugin plugin = plugins[i]; plugin.generate(namespaceMapping); } } Resource res = new Resource(); res.setDirectory(outputDir.toString()); project.addResource(res); log("...done."); } catch (Exception e) { throw new BuildException(e); } finally { Thread.currentThread().setContextClassLoader(oldCL); } } |
List<Element> es = (List<Element>) el.getChildren(); for (Element childElement : es) { createNoteFromElement(childElement, n); | List es = el.getChildren(); for (Object childElement : es) { createNoteFromElement((Element) childElement, n); | private Note createNoteFromElement(Element el, Note parent) { if (!el.getName().equals("note")) { throw new KoalaException("Koala Notes could not build a document from file '" + file.getName() + "': expected a note element but got a " + el.getName() + "."); } String name = el.getAttributeValue("name"); String text = el.getAttributeValue("text"); Note n = new Note(name, parent, text); List<Element> es = (List<Element>) el.getChildren(); for (Element childElement : es) { createNoteFromElement(childElement, n); } return n; } |
sb.append(_content[i].toString()); | sb.append(_content[i] == null ? "null" : _content[i].toString()); | public String toString() { StringBuffer sb = new StringBuffer(); sb.append("("); for (int i = 0; i < _content.length; i++) { if (i != 0) { sb.append(", "); } sb.append(_content[i].toString()); } sb.append(")"); return sb.toString(); } |
boolean[] la1tokens = new boolean[33]; for (int i = 0; i < 33; i++) { | boolean[] la1tokens = new boolean[35]; for (int i = 0; i < 35; i++) { | final public ParseException generateParseException() { jj_expentries.removeAllElements(); boolean[] la1tokens = new boolean[33]; for (int i = 0; i < 33; i++) { la1tokens[i] = false; } if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } for (int i = 0; i < 2; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1<<j)) != 0) { la1tokens[j] = true; } if ((jj_la1_1[i] & (1<<j)) != 0) { la1tokens[32+j] = true; } } } } for (int i = 0; i < 33; i++) { if (la1tokens[i]) { jj_expentry = new int[1]; jj_expentry[0] = i; jj_expentries.addElement(jj_expentry); } } int[][] exptokseq = new int[jj_expentries.size()][]; for (int i = 0; i < jj_expentries.size(); i++) { exptokseq[i] = (int[])jj_expentries.elementAt(i); } return new ParseException(token, exptokseq, tokenImage); } |
for (int i = 0; i < 33; i++) { | for (int i = 0; i < 35; i++) { | final public ParseException generateParseException() { jj_expentries.removeAllElements(); boolean[] la1tokens = new boolean[33]; for (int i = 0; i < 33; i++) { la1tokens[i] = false; } if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } for (int i = 0; i < 2; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1<<j)) != 0) { la1tokens[j] = true; } if ((jj_la1_1[i] & (1<<j)) != 0) { la1tokens[32+j] = true; } } } } for (int i = 0; i < 33; i++) { if (la1tokens[i]) { jj_expentry = new int[1]; jj_expentry[0] = i; jj_expentries.addElement(jj_expentry); } } int[][] exptokseq = new int[jj_expentries.size()][]; for (int i = 0; i < jj_expentries.size(); i++) { exptokseq[i] = (int[])jj_expentries.elementAt(i); } return new ParseException(token, exptokseq, tokenImage); } |
break; case LI: t = jj_consume_token(LI); builder.li(); | final public WikiPage parse(WikiPageBuilder builder) throws ParseException { Token t; label_1: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case QUOTED_BLOCK: case BOLD: case UNDERLINE: case ITALIC: case LT: case GT: case COLOR: case HEADER: case COLOR_HEADER_TERMINATE: case RULE: case EMAIL: case URL: case WIKI_TERM: case SHORT_WIKI_TERM: case WORD: case NEW_PARAGRAPH: case LINE_BREAK: case INDENT: case WHITESPACE: case ASTERISK: case UNDERSCORE: case CARET: case DOUBLE_LBRACKET: case DELIMITERS: ; break; default: jj_la1[0] = jj_gen; break label_1; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LT: t = jj_consume_token(LT); builder.lt(); break; case GT: t = jj_consume_token(GT); builder.gt(); break; case BOLD: t = jj_consume_token(BOLD); builder.bold(); break; case UNDERLINE: t = jj_consume_token(UNDERLINE); builder.underline(); break; case ITALIC: t = jj_consume_token(ITALIC); builder.italic(); break; case COLOR: t = jj_consume_token(COLOR); if (_headerName != null || _colorName != null) { builder.endColorOrHeader(); String word = t.image.substring(1); if (builder.isWikiTermReference (word)) builder.wikiTerm (word); else builder.word (word); _colorName = null; _headerName = null; } else { _colorName = t.image.substring(1); builder.color (_colorName); } break; case HEADER: t = jj_consume_token(HEADER); _headerName = t.image.substring(2); builder.header (_headerName); break; case COLOR_HEADER_TERMINATE: t = jj_consume_token(COLOR_HEADER_TERMINATE); if (_headerName == null && _colorName == null) builder.word ("^"); else { builder.endColorOrHeader (); _headerName = null; _colorName = null; } break; case RULE: t = jj_consume_token(RULE); builder.ruler(); break; case EMAIL: t = jj_consume_token(EMAIL); builder.email(t.image); break; case WIKI_TERM: t = jj_consume_token(WIKI_TERM); if (builder.isWikiTermReference (t.image)) builder.wikiTerm (t.image); else builder.word (t.image); break; case SHORT_WIKI_TERM: t = jj_consume_token(SHORT_WIKI_TERM); if (builder.isWikiTermReference (t.image)) builder.wikiTerm (t.image.substring(0, t.image.length()-1)); else builder.word (t.image); break; case WORD: t = jj_consume_token(WORD); builder.word (t.image); break; case NEW_PARAGRAPH: t = jj_consume_token(NEW_PARAGRAPH); builder.paragraph (); break; case LINE_BREAK: t = jj_consume_token(LINE_BREAK); builder.newline(); break; case INDENT: t = jj_consume_token(INDENT); builder.indent(2); break; case WHITESPACE: t = jj_consume_token(WHITESPACE); builder.space(); break; case ASTERISK: t = jj_consume_token(ASTERISK); builder.word ("*"); break; case UNDERSCORE: t = jj_consume_token(UNDERSCORE); builder.word ("_"); break; case CARET: t = jj_consume_token(CARET); builder.word ("^"); break; case DOUBLE_LBRACKET: t = jj_consume_token(DOUBLE_LBRACKET); builder.word ("[["); break; case DELIMITERS: t = jj_consume_token(DELIMITERS); builder.word (t.image); break; case URL: t = jj_consume_token(URL); builder.url (t.image); break; case QUOTED_BLOCK: t = jj_consume_token(QUOTED_BLOCK); builder.quotedBlock (t.image.substring(2, t.image.length()-2)); break; default: jj_la1[1] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } {if (true) return builder.getPage ();} throw new Error("Missing return statement in function"); } |
|
ChatPreferences chatPref = (ChatPreferences)SparkManager.getPreferenceManager().getPreferenceData(ChatPreference.NAMESPACE); chatRoom.create(chatPref.getNickname()); | LocalPreferences pref = SettingsManager.getLocalPreferences(); chatRoom.create(pref.getNickname()); | public ChatRoom createConferenceRoom(String roomName, String serviceName) { final MultiUserChat chatRoom = new MultiUserChat(SparkManager.getConnection(), roomName + "@" + serviceName); final GroupChatRoom room = new GroupChatRoom(chatRoom); try { ChatPreferences chatPref = (ChatPreferences)SparkManager.getPreferenceManager().getPreferenceData(ChatPreference.NAMESPACE); chatRoom.create(chatPref.getNickname()); // Send an empty room configuration form which indicates that we want // an instant room chatRoom.sendConfigurationForm(new Form(Form.TYPE_SUBMIT)); } catch (XMPPException e1) { Log.error("Unable to send conference room chat configuration form.", e1); return null; } getChatContainer().addChatRoom(room); return room; } |
public JContactItemField(List items) { | public JContactItemField(List items, Window parentWindow) { | public JContactItemField(List items) { setLayout(new BorderLayout()); this.items = items; add(textField, BorderLayout.CENTER); textField.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent keyEvent) { char ch = keyEvent.getKeyChar(); if (validateChar(ch)) { showPopupMenu(); } if (ch == KeyEvent.VK_ENTER) { int index = list.getSelectedIndex(); if (index >= 0) { ContactItem selection = (ContactItem)list.getSelectedValue(); textField.setText(selection.getNickname()); popup.setVisible(false); } } if (ch == KeyEvent.VK_ESCAPE) { popup.setVisible(false); } dispatchEvent(keyEvent); } public void keyPressed(KeyEvent e) { if (isArrowKey(e)) { list.dispatchEvent(e); } } }); popup = new JWindow(new JFrame()); popup.getContentPane().add(new JScrollPane(list)); list.setCellRenderer(new PopupRenderer()); } |
popup = new JWindow(new JFrame()); | list.addKeyListener(this); addKeyListener(this); popup = new JWindow(parentWindow); | public JContactItemField(List items) { setLayout(new BorderLayout()); this.items = items; add(textField, BorderLayout.CENTER); textField.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent keyEvent) { char ch = keyEvent.getKeyChar(); if (validateChar(ch)) { showPopupMenu(); } if (ch == KeyEvent.VK_ENTER) { int index = list.getSelectedIndex(); if (index >= 0) { ContactItem selection = (ContactItem)list.getSelectedValue(); textField.setText(selection.getNickname()); popup.setVisible(false); } } if (ch == KeyEvent.VK_ESCAPE) { popup.setVisible(false); } dispatchEvent(keyEvent); } public void keyPressed(KeyEvent e) { if (isArrowKey(e)) { list.dispatchEvent(e); } } }); popup = new JWindow(new JFrame()); popup.getContentPane().add(new JScrollPane(list)); list.setCellRenderer(new PopupRenderer()); } |
pref.setHideChatHistory(panel.isChatHistoryHidden()); | pref.setChatHistoryEnabled(!panel.isChatHistoryHidden()); | public void commit() { LocalPreferences pref = SettingsManager.getLocalPreferences(); pref.setTimeDisplayedInChat(panel.getShowTime()); pref.setSpellCheckerEnabled(panel.isSpellCheckerOn()); pref.setChatRoomNotifications(panel.isGroupChatNotificationsOn()); pref.setHideChatHistory(panel.isChatHistoryHidden()); SettingsManager.saveSettings(); // Do not commit if not changed. if (ModelUtil.hasLength(panel.getPassword()) && ModelUtil.hasLength(panel.getConfirmationPassword())) { try { SparkManager.getConnection().getAccountManager().changePassword(panel.getPassword()); } catch (XMPPException passwordEx) { JOptionPane.showMessageDialog(SparkManager.getMainWindow(), "Unable to change password. Please see your server admin.", "Password Change Error", JOptionPane.ERROR_MESSAGE); Log.error("Unable to change password", passwordEx); } } } |
boolean chatHistoryHidden = pref.isHideChatHistory(); | boolean chatHistoryHidden = !pref.isChatHistoryEnabled(); | public void load() { SwingWorker thread = new SwingWorker() { LocalPreferences pref; public Object construct() { pref = SettingsManager.getLocalPreferences(); return pref; } public void finished() { String nickname = pref.getDefaultNickname(); if (nickname == null) { nickname = SparkManager.getSessionManager().getUsername(); } boolean showTime = pref.isTimeDisplayedInChat(); boolean spellCheckerOn = pref.isSpellCheckerEnabled(); boolean notificationsOn = pref.isChatRoomNotificationsOn(); boolean chatHistoryHidden = pref.isHideChatHistory(); panel.setShowTime(showTime); panel.setSpellCheckerOn(spellCheckerOn); panel.setGroupChatNotificationsOn(notificationsOn); panel.setChatHistoryHidden(chatHistoryHidden); } }; thread.start(); } |
boolean chatHistoryHidden = pref.isHideChatHistory(); | boolean chatHistoryHidden = !pref.isChatHistoryEnabled(); | public void finished() { String nickname = pref.getDefaultNickname(); if (nickname == null) { nickname = SparkManager.getSessionManager().getUsername(); } boolean showTime = pref.isTimeDisplayedInChat(); boolean spellCheckerOn = pref.isSpellCheckerEnabled(); boolean notificationsOn = pref.isChatRoomNotificationsOn(); boolean chatHistoryHidden = pref.isHideChatHistory(); panel.setShowTime(showTime); panel.setSpellCheckerOn(spellCheckerOn); panel.setGroupChatNotificationsOn(notificationsOn); panel.setChatHistoryHidden(chatHistoryHidden); } |
LOG_DIRECTORY = new File(workingDir, "logs").getAbsoluteFile(); | if (!Spark.isWindows()) { LOG_DIRECTORY = new File(USER_HOME, "/Spark/logs").getAbsoluteFile(); } else { LOG_DIRECTORY = new File(workingDir, "logs").getAbsoluteFile(); } | public static void main(final String[] args) { /* * EnhancedDebuggerWindow.PERSISTED_DEBUGGER = true; * EnhancedDebuggerWindow.MAX_TABLE_ROWS = 10; * XMPPConnection.DEBUG_ENABLED = true; */ String current = System.getProperty("java.library.path"); String classPath = System.getProperty("java.class.path"); // Set UIManager properties for JTree System.setProperty("apple.laf.useScreenMenuBar", "true"); /** Update Library Path **/ StringBuffer buf = new StringBuffer(); buf.append(current); buf.append(";"); final String workingDirectory = System.getProperty("appdir"); if (workingDirectory == null) { RESOURCE_DIRECTORY = new File(USER_HOME, "/Spark/resources").getAbsoluteFile(); BIN_DIRECTORY = new File(USER_HOME, "/Spark/bin").getAbsoluteFile(); LOG_DIRECTORY = new File(USER_HOME, "/Spark/logs").getAbsoluteFile(); RESOURCE_DIRECTORY.mkdirs(); LOG_DIRECTORY.mkdirs(); if (!RESOURCE_DIRECTORY.exists() || !LOG_DIRECTORY.exists()) { JOptionPane.showMessageDialog(new JFrame(), "Unable to create directories necessary for runtime.", "Spark Error", JOptionPane.ERROR_MESSAGE); System.exit(1); } } // This is the Spark.exe or Spark.dmg installed executable. else { // This is the installed executable. File workingDir = new File(workingDirectory); RESOURCE_DIRECTORY = new File(workingDir, "resources").getAbsoluteFile(); BIN_DIRECTORY = new File(workingDir, "bin").getAbsoluteFile(); LOG_DIRECTORY = new File(workingDir, "logs").getAbsoluteFile(); LOG_DIRECTORY.mkdirs(); try { buf.append(RESOURCE_DIRECTORY.getCanonicalPath()).append(";"); } catch (IOException e) { e.printStackTrace(); } } buf.append(classPath); // Update System Properties System.setProperty("java.library.path", buf.toString()); System.setProperty("sun.java2d.noddraw", "true"); SwingUtilities.invokeLater(new Runnable() { public void run() { // Start Application new Spark(); } }); // Handle arguments if (args.length > 0) { argument = args[0]; } } |
public HTMLReport(Coverage coverage, File outputDir, File sourceDir) | public HTMLReport(CoverageReport coverage, File outputDir, File sourceDir) | public HTMLReport(Coverage coverage, File outputDir, File sourceDir) throws Exception { this.outputDir = outputDir; this.sourceDir = sourceDir; this.coverage = coverage; removeNonexistantClasses(); CopyFiles.copy(outputDir); generatePackageList(); generateClassLists(); generateOverviews(); generateSourceFiles(); } |
Block b = (Block) bb.build(new BuildContext(broker)); | bb.build(new BuildContext(broker)); | public static void parseTemplate(String name, Reader in) { try { Builder bb = parser.parseBlock(name, in); Block b = (Block) bb.build(new BuildContext(broker)); } catch (Exception e) { System.err.println("Exception parsing template " + name + "\n" + e); } } |
titleLabel.setFont(new Font("Verdana", Font.BOLD, 11)); | titleLabel.setFont(new Font("Dialog", Font.BOLD, 11)); | public SendMessage() { setLayout(new GridBagLayout()); setBackground(new Color(250, 249, 242)); add(imageLabel, new GridBagConstraints(0, 0, 1, 3, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); add(titleLabel, new GridBagConstraints(1, 0, 2, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); titleLabel.setFont(new Font("Verdana", Font.BOLD, 11)); titleLabel.setForeground(new Color(211, 174, 102)); add(fileLabel, new GridBagConstraints(1, 1, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); cancelButton.setText("Cancel"); retryButton.setText("Retry"); add(cancelButton, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); add(retryButton, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); retryButton.setVisible(false); retryButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { File file = new File(transfer.getFilePath()); transfer = transferManager.createOutgoingFileTransfer(fullJID); transfer.sendFile(file, "Sending"); } catch (XMPPException e1) { e1.printStackTrace(); } sendFile(transfer, transferManager, fullJID, nickname); } }); cancelButton.setForeground(new Color(73, 113, 196)); cancelButton.setFont(new Font("Verdana", Font.BOLD, 10)); cancelButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(73, 113, 196))); retryButton.setForeground(new Color(73, 113, 196)); retryButton.setFont(new Font("Verdana", Font.BOLD, 10)); retryButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(73, 113, 196))); setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.white)); } |
cancelButton.setText("Cancel"); retryButton.setText("Retry"); | cancelButton.setText(Res.getString("cancel")); retryButton.setText(Res.getString("retry")); | public SendMessage() { setLayout(new GridBagLayout()); setBackground(new Color(250, 249, 242)); add(imageLabel, new GridBagConstraints(0, 0, 1, 3, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); add(titleLabel, new GridBagConstraints(1, 0, 2, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); titleLabel.setFont(new Font("Verdana", Font.BOLD, 11)); titleLabel.setForeground(new Color(211, 174, 102)); add(fileLabel, new GridBagConstraints(1, 1, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); cancelButton.setText("Cancel"); retryButton.setText("Retry"); add(cancelButton, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); add(retryButton, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); retryButton.setVisible(false); retryButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { File file = new File(transfer.getFilePath()); transfer = transferManager.createOutgoingFileTransfer(fullJID); transfer.sendFile(file, "Sending"); } catch (XMPPException e1) { e1.printStackTrace(); } sendFile(transfer, transferManager, fullJID, nickname); } }); cancelButton.setForeground(new Color(73, 113, 196)); cancelButton.setFont(new Font("Verdana", Font.BOLD, 10)); cancelButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(73, 113, 196))); retryButton.setForeground(new Color(73, 113, 196)); retryButton.setFont(new Font("Verdana", Font.BOLD, 10)); retryButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(73, 113, 196))); setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.white)); } |
cancelButton.setFont(new Font("Verdana", Font.BOLD, 10)); | cancelButton.setFont(new Font("Dialog", Font.BOLD, 10)); | public SendMessage() { setLayout(new GridBagLayout()); setBackground(new Color(250, 249, 242)); add(imageLabel, new GridBagConstraints(0, 0, 1, 3, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); add(titleLabel, new GridBagConstraints(1, 0, 2, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); titleLabel.setFont(new Font("Verdana", Font.BOLD, 11)); titleLabel.setForeground(new Color(211, 174, 102)); add(fileLabel, new GridBagConstraints(1, 1, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); cancelButton.setText("Cancel"); retryButton.setText("Retry"); add(cancelButton, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); add(retryButton, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); retryButton.setVisible(false); retryButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { File file = new File(transfer.getFilePath()); transfer = transferManager.createOutgoingFileTransfer(fullJID); transfer.sendFile(file, "Sending"); } catch (XMPPException e1) { e1.printStackTrace(); } sendFile(transfer, transferManager, fullJID, nickname); } }); cancelButton.setForeground(new Color(73, 113, 196)); cancelButton.setFont(new Font("Verdana", Font.BOLD, 10)); cancelButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(73, 113, 196))); retryButton.setForeground(new Color(73, 113, 196)); retryButton.setFont(new Font("Verdana", Font.BOLD, 10)); retryButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(73, 113, 196))); setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.white)); } |
retryButton.setFont(new Font("Verdana", Font.BOLD, 10)); | retryButton.setFont(new Font("Dialog", Font.BOLD, 10)); | public SendMessage() { setLayout(new GridBagLayout()); setBackground(new Color(250, 249, 242)); add(imageLabel, new GridBagConstraints(0, 0, 1, 3, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); add(titleLabel, new GridBagConstraints(1, 0, 2, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); titleLabel.setFont(new Font("Verdana", Font.BOLD, 11)); titleLabel.setForeground(new Color(211, 174, 102)); add(fileLabel, new GridBagConstraints(1, 1, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); cancelButton.setText("Cancel"); retryButton.setText("Retry"); add(cancelButton, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); add(retryButton, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); retryButton.setVisible(false); retryButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { File file = new File(transfer.getFilePath()); transfer = transferManager.createOutgoingFileTransfer(fullJID); transfer.sendFile(file, "Sending"); } catch (XMPPException e1) { e1.printStackTrace(); } sendFile(transfer, transferManager, fullJID, nickname); } }); cancelButton.setForeground(new Color(73, 113, 196)); cancelButton.setFont(new Font("Verdana", Font.BOLD, 10)); cancelButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(73, 113, 196))); retryButton.setForeground(new Color(73, 113, 196)); retryButton.setFont(new Font("Verdana", Font.BOLD, 10)); retryButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(73, 113, 196))); setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.white)); } |
label.setToolTipText("Click to open"); | label.setToolTipText(Res.getString("message.click.to.open")); | private void makeClickable(final JLabel label) { label.setToolTipText("Click to open"); label.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { openFile(fileToSend); } public void mouseEntered(MouseEvent e) { label.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { label.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); } |
titleLabel.setText("Waiting for " + contactItem.getNickname() + " to accept file transfer."); | titleLabel.setText(Res.getString("message.transfer.waiting.on.user", contactItem.getNickname())); | public void sendFile(final OutgoingFileTransfer transfer, FileTransferManager transferManager, final String jid, final String nickname) { this.transferManager = transferManager; cancelButton.setVisible(true); retryButton.setVisible(false); this.fullJID = jid; this.nickname = nickname; this.transfer = transfer; String fileName = transfer.getFileName(); long fileSize = transfer.getFileSize(); ByteFormat format = new ByteFormat(); String text = format.format(fileSize); fileToSend = new File(transfer.getFilePath()); fileLabel.setText(fileName + " (" + text + ")"); ContactList contactList = SparkManager.getWorkspace().getContactList(); ContactItem contactItem = contactList.getContactItemByJID(jid); titleLabel.setText("Waiting for " + contactItem.getNickname() + " to accept file transfer."); if (isImage(fileName)) { try { URL imageURL = new File(transfer.getFilePath()).toURL(); ImageIcon image = new ImageIcon(imageURL); image = GraphicUtils.scaleImageIcon(image, 64, 64); imageLabel.setIcon(image); } catch (MalformedURLException e) { Log.error("Could not locate image.", e); imageLabel.setIcon(SparkRes.getImageIcon(SparkRes.DOCUMENT_INFO_32x32)); } } else { File file = new File(transfer.getFilePath()); Icon icon = GraphicUtils.getIcon(file); imageLabel.setIcon(icon); } cancelButton.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent mouseEvent) { transfer.cancel(); } }); cancelButton.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { cancelButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { cancelButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); progressBar.setMaximum((int)fileSize); progressBar.setVisible(false); progressBar.setStringPainted(true); add(progressBar, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 150, 0)); SwingWorker worker = new SwingWorker() { public Object construct() { while (true) { try { Thread.sleep(10); FileTransfer.Status status = transfer.getStatus(); if (status == Status.ERROR || status == Status.COMPLETE || status == Status.CANCLED || status == Status.REFUSED) { break; } updateBar(transfer, nickname); } catch (InterruptedException e) { Log.error("Unable to sleep thread.", e); } } return ""; } public void finished() { updateBar(transfer, nickname); } }; worker.start(); makeClickable(imageLabel); makeClickable(titleLabel); } |
if (status == Status.ERROR || status == Status.COMPLETE || status == Status.CANCLED || status == Status.REFUSED) { | if (status == Status.error || status == Status.complete || status == Status.cancelled || status == Status.refused) { | public void sendFile(final OutgoingFileTransfer transfer, FileTransferManager transferManager, final String jid, final String nickname) { this.transferManager = transferManager; cancelButton.setVisible(true); retryButton.setVisible(false); this.fullJID = jid; this.nickname = nickname; this.transfer = transfer; String fileName = transfer.getFileName(); long fileSize = transfer.getFileSize(); ByteFormat format = new ByteFormat(); String text = format.format(fileSize); fileToSend = new File(transfer.getFilePath()); fileLabel.setText(fileName + " (" + text + ")"); ContactList contactList = SparkManager.getWorkspace().getContactList(); ContactItem contactItem = contactList.getContactItemByJID(jid); titleLabel.setText("Waiting for " + contactItem.getNickname() + " to accept file transfer."); if (isImage(fileName)) { try { URL imageURL = new File(transfer.getFilePath()).toURL(); ImageIcon image = new ImageIcon(imageURL); image = GraphicUtils.scaleImageIcon(image, 64, 64); imageLabel.setIcon(image); } catch (MalformedURLException e) { Log.error("Could not locate image.", e); imageLabel.setIcon(SparkRes.getImageIcon(SparkRes.DOCUMENT_INFO_32x32)); } } else { File file = new File(transfer.getFilePath()); Icon icon = GraphicUtils.getIcon(file); imageLabel.setIcon(icon); } cancelButton.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent mouseEvent) { transfer.cancel(); } }); cancelButton.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { cancelButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { cancelButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); progressBar.setMaximum((int)fileSize); progressBar.setVisible(false); progressBar.setStringPainted(true); add(progressBar, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 150, 0)); SwingWorker worker = new SwingWorker() { public Object construct() { while (true) { try { Thread.sleep(10); FileTransfer.Status status = transfer.getStatus(); if (status == Status.ERROR || status == Status.COMPLETE || status == Status.CANCLED || status == Status.REFUSED) { break; } updateBar(transfer, nickname); } catch (InterruptedException e) { Log.error("Unable to sleep thread.", e); } } return ""; } public void finished() { updateBar(transfer, nickname); } }; worker.start(); makeClickable(imageLabel); makeClickable(titleLabel); } |
if (status == Status.ERROR || status == Status.COMPLETE || status == Status.CANCLED || status == Status.REFUSED) { | if (status == Status.error || status == Status.complete || status == Status.cancelled || status == Status.refused) { | public Object construct() { while (true) { try { Thread.sleep(10); FileTransfer.Status status = transfer.getStatus(); if (status == Status.ERROR || status == Status.COMPLETE || status == Status.CANCLED || status == Status.REFUSED) { break; } updateBar(transfer, nickname); } catch (InterruptedException e) { Log.error("Unable to sleep thread.", e); } } return ""; } |
if (status == Status.NEGOTIATING_STREAM) { titleLabel.setText("Negotiating file transfer with " + nickname + ". Please wait..."); | if (status == Status.negotiating_stream) { titleLabel.setText(Res.getString("message.negotiation.file.transfer", nickname)); | private void updateBar(final OutgoingFileTransfer transfer, String nickname) { FileTransfer.Status status = transfer.getStatus(); if (status == Status.NEGOTIATING_STREAM) { titleLabel.setText("Negotiating file transfer with " + nickname + ". Please wait..."); } else if (status == Status.ERROR) { if (transfer.getException() != null) { Log.error("Error occured during file transfer.", transfer.getException()); } progressBar.setVisible(false); titleLabel.setText("You were unable to send the file to " + nickname); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } else if (status == Status.IN_PROGRESS) { titleLabel.setText("Sending a file to " + nickname); showAlert(false); if (!progressBar.isVisible()) { progressBar.setVisible(true); } progressBar.setValue((int)transfer.getBytesSent()); ByteFormat format = new ByteFormat(); String bytesSent = format.format(transfer.getBytesSent()); progressBar.setString(bytesSent + " sent"); } else if (status == Status.COMPLETE) { progressBar.setVisible(false); titleLabel.setText("You have sent a file to " + nickname + "."); cancelButton.setVisible(false); showAlert(true); } else if (status == Status.CANCLED) { progressBar.setVisible(false); titleLabel.setText("You have cancelled the file transfer."); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } else if (status == Status.REFUSED) { progressBar.setVisible(false); titleLabel.setText(nickname + " did not accept the file transfer."); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } } |
else if (status == Status.ERROR) { | else if (status == Status.error) { | private void updateBar(final OutgoingFileTransfer transfer, String nickname) { FileTransfer.Status status = transfer.getStatus(); if (status == Status.NEGOTIATING_STREAM) { titleLabel.setText("Negotiating file transfer with " + nickname + ". Please wait..."); } else if (status == Status.ERROR) { if (transfer.getException() != null) { Log.error("Error occured during file transfer.", transfer.getException()); } progressBar.setVisible(false); titleLabel.setText("You were unable to send the file to " + nickname); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } else if (status == Status.IN_PROGRESS) { titleLabel.setText("Sending a file to " + nickname); showAlert(false); if (!progressBar.isVisible()) { progressBar.setVisible(true); } progressBar.setValue((int)transfer.getBytesSent()); ByteFormat format = new ByteFormat(); String bytesSent = format.format(transfer.getBytesSent()); progressBar.setString(bytesSent + " sent"); } else if (status == Status.COMPLETE) { progressBar.setVisible(false); titleLabel.setText("You have sent a file to " + nickname + "."); cancelButton.setVisible(false); showAlert(true); } else if (status == Status.CANCLED) { progressBar.setVisible(false); titleLabel.setText("You have cancelled the file transfer."); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } else if (status == Status.REFUSED) { progressBar.setVisible(false); titleLabel.setText(nickname + " did not accept the file transfer."); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } } |
titleLabel.setText("You were unable to send the file to " + nickname); | titleLabel.setText(Res.getString("message.unable.to.send.file", nickname)); | private void updateBar(final OutgoingFileTransfer transfer, String nickname) { FileTransfer.Status status = transfer.getStatus(); if (status == Status.NEGOTIATING_STREAM) { titleLabel.setText("Negotiating file transfer with " + nickname + ". Please wait..."); } else if (status == Status.ERROR) { if (transfer.getException() != null) { Log.error("Error occured during file transfer.", transfer.getException()); } progressBar.setVisible(false); titleLabel.setText("You were unable to send the file to " + nickname); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } else if (status == Status.IN_PROGRESS) { titleLabel.setText("Sending a file to " + nickname); showAlert(false); if (!progressBar.isVisible()) { progressBar.setVisible(true); } progressBar.setValue((int)transfer.getBytesSent()); ByteFormat format = new ByteFormat(); String bytesSent = format.format(transfer.getBytesSent()); progressBar.setString(bytesSent + " sent"); } else if (status == Status.COMPLETE) { progressBar.setVisible(false); titleLabel.setText("You have sent a file to " + nickname + "."); cancelButton.setVisible(false); showAlert(true); } else if (status == Status.CANCLED) { progressBar.setVisible(false); titleLabel.setText("You have cancelled the file transfer."); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } else if (status == Status.REFUSED) { progressBar.setVisible(false); titleLabel.setText(nickname + " did not accept the file transfer."); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } } |
else if (status == Status.IN_PROGRESS) { titleLabel.setText("Sending a file to " + nickname); | else if (status == Status.in_progress) { titleLabel.setText(Res.getString("message.sending.file.to", nickname)); | private void updateBar(final OutgoingFileTransfer transfer, String nickname) { FileTransfer.Status status = transfer.getStatus(); if (status == Status.NEGOTIATING_STREAM) { titleLabel.setText("Negotiating file transfer with " + nickname + ". Please wait..."); } else if (status == Status.ERROR) { if (transfer.getException() != null) { Log.error("Error occured during file transfer.", transfer.getException()); } progressBar.setVisible(false); titleLabel.setText("You were unable to send the file to " + nickname); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } else if (status == Status.IN_PROGRESS) { titleLabel.setText("Sending a file to " + nickname); showAlert(false); if (!progressBar.isVisible()) { progressBar.setVisible(true); } progressBar.setValue((int)transfer.getBytesSent()); ByteFormat format = new ByteFormat(); String bytesSent = format.format(transfer.getBytesSent()); progressBar.setString(bytesSent + " sent"); } else if (status == Status.COMPLETE) { progressBar.setVisible(false); titleLabel.setText("You have sent a file to " + nickname + "."); cancelButton.setVisible(false); showAlert(true); } else if (status == Status.CANCLED) { progressBar.setVisible(false); titleLabel.setText("You have cancelled the file transfer."); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } else if (status == Status.REFUSED) { progressBar.setVisible(false); titleLabel.setText(nickname + " did not accept the file transfer."); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } } |
else if (status == Status.COMPLETE) { | else if (status == Status.complete) { | private void updateBar(final OutgoingFileTransfer transfer, String nickname) { FileTransfer.Status status = transfer.getStatus(); if (status == Status.NEGOTIATING_STREAM) { titleLabel.setText("Negotiating file transfer with " + nickname + ". Please wait..."); } else if (status == Status.ERROR) { if (transfer.getException() != null) { Log.error("Error occured during file transfer.", transfer.getException()); } progressBar.setVisible(false); titleLabel.setText("You were unable to send the file to " + nickname); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } else if (status == Status.IN_PROGRESS) { titleLabel.setText("Sending a file to " + nickname); showAlert(false); if (!progressBar.isVisible()) { progressBar.setVisible(true); } progressBar.setValue((int)transfer.getBytesSent()); ByteFormat format = new ByteFormat(); String bytesSent = format.format(transfer.getBytesSent()); progressBar.setString(bytesSent + " sent"); } else if (status == Status.COMPLETE) { progressBar.setVisible(false); titleLabel.setText("You have sent a file to " + nickname + "."); cancelButton.setVisible(false); showAlert(true); } else if (status == Status.CANCLED) { progressBar.setVisible(false); titleLabel.setText("You have cancelled the file transfer."); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } else if (status == Status.REFUSED) { progressBar.setVisible(false); titleLabel.setText(nickname + " did not accept the file transfer."); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } } |
titleLabel.setText("You have sent a file to " + nickname + "."); | titleLabel.setText(Res.getString("message.you.have.sent", nickname)); | private void updateBar(final OutgoingFileTransfer transfer, String nickname) { FileTransfer.Status status = transfer.getStatus(); if (status == Status.NEGOTIATING_STREAM) { titleLabel.setText("Negotiating file transfer with " + nickname + ". Please wait..."); } else if (status == Status.ERROR) { if (transfer.getException() != null) { Log.error("Error occured during file transfer.", transfer.getException()); } progressBar.setVisible(false); titleLabel.setText("You were unable to send the file to " + nickname); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } else if (status == Status.IN_PROGRESS) { titleLabel.setText("Sending a file to " + nickname); showAlert(false); if (!progressBar.isVisible()) { progressBar.setVisible(true); } progressBar.setValue((int)transfer.getBytesSent()); ByteFormat format = new ByteFormat(); String bytesSent = format.format(transfer.getBytesSent()); progressBar.setString(bytesSent + " sent"); } else if (status == Status.COMPLETE) { progressBar.setVisible(false); titleLabel.setText("You have sent a file to " + nickname + "."); cancelButton.setVisible(false); showAlert(true); } else if (status == Status.CANCLED) { progressBar.setVisible(false); titleLabel.setText("You have cancelled the file transfer."); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } else if (status == Status.REFUSED) { progressBar.setVisible(false); titleLabel.setText(nickname + " did not accept the file transfer."); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } } |
else if (status == Status.CANCLED) { | else if (status == Status.cancelled) { | private void updateBar(final OutgoingFileTransfer transfer, String nickname) { FileTransfer.Status status = transfer.getStatus(); if (status == Status.NEGOTIATING_STREAM) { titleLabel.setText("Negotiating file transfer with " + nickname + ". Please wait..."); } else if (status == Status.ERROR) { if (transfer.getException() != null) { Log.error("Error occured during file transfer.", transfer.getException()); } progressBar.setVisible(false); titleLabel.setText("You were unable to send the file to " + nickname); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } else if (status == Status.IN_PROGRESS) { titleLabel.setText("Sending a file to " + nickname); showAlert(false); if (!progressBar.isVisible()) { progressBar.setVisible(true); } progressBar.setValue((int)transfer.getBytesSent()); ByteFormat format = new ByteFormat(); String bytesSent = format.format(transfer.getBytesSent()); progressBar.setString(bytesSent + " sent"); } else if (status == Status.COMPLETE) { progressBar.setVisible(false); titleLabel.setText("You have sent a file to " + nickname + "."); cancelButton.setVisible(false); showAlert(true); } else if (status == Status.CANCLED) { progressBar.setVisible(false); titleLabel.setText("You have cancelled the file transfer."); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } else if (status == Status.REFUSED) { progressBar.setVisible(false); titleLabel.setText(nickname + " did not accept the file transfer."); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } } |
titleLabel.setText("You have cancelled the file transfer."); | titleLabel.setText(Res.getString("message.file.transfer.canceled")); | private void updateBar(final OutgoingFileTransfer transfer, String nickname) { FileTransfer.Status status = transfer.getStatus(); if (status == Status.NEGOTIATING_STREAM) { titleLabel.setText("Negotiating file transfer with " + nickname + ". Please wait..."); } else if (status == Status.ERROR) { if (transfer.getException() != null) { Log.error("Error occured during file transfer.", transfer.getException()); } progressBar.setVisible(false); titleLabel.setText("You were unable to send the file to " + nickname); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } else if (status == Status.IN_PROGRESS) { titleLabel.setText("Sending a file to " + nickname); showAlert(false); if (!progressBar.isVisible()) { progressBar.setVisible(true); } progressBar.setValue((int)transfer.getBytesSent()); ByteFormat format = new ByteFormat(); String bytesSent = format.format(transfer.getBytesSent()); progressBar.setString(bytesSent + " sent"); } else if (status == Status.COMPLETE) { progressBar.setVisible(false); titleLabel.setText("You have sent a file to " + nickname + "."); cancelButton.setVisible(false); showAlert(true); } else if (status == Status.CANCLED) { progressBar.setVisible(false); titleLabel.setText("You have cancelled the file transfer."); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } else if (status == Status.REFUSED) { progressBar.setVisible(false); titleLabel.setText(nickname + " did not accept the file transfer."); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } } |
else if (status == Status.REFUSED) { | else if (status == Status.refused) { | private void updateBar(final OutgoingFileTransfer transfer, String nickname) { FileTransfer.Status status = transfer.getStatus(); if (status == Status.NEGOTIATING_STREAM) { titleLabel.setText("Negotiating file transfer with " + nickname + ". Please wait..."); } else if (status == Status.ERROR) { if (transfer.getException() != null) { Log.error("Error occured during file transfer.", transfer.getException()); } progressBar.setVisible(false); titleLabel.setText("You were unable to send the file to " + nickname); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } else if (status == Status.IN_PROGRESS) { titleLabel.setText("Sending a file to " + nickname); showAlert(false); if (!progressBar.isVisible()) { progressBar.setVisible(true); } progressBar.setValue((int)transfer.getBytesSent()); ByteFormat format = new ByteFormat(); String bytesSent = format.format(transfer.getBytesSent()); progressBar.setString(bytesSent + " sent"); } else if (status == Status.COMPLETE) { progressBar.setVisible(false); titleLabel.setText("You have sent a file to " + nickname + "."); cancelButton.setVisible(false); showAlert(true); } else if (status == Status.CANCLED) { progressBar.setVisible(false); titleLabel.setText("You have cancelled the file transfer."); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } else if (status == Status.REFUSED) { progressBar.setVisible(false); titleLabel.setText(nickname + " did not accept the file transfer."); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } } |
titleLabel.setText(nickname + " did not accept the file transfer."); | titleLabel.setText(Res.getString("message.file.transfer.rejected", nickname)); | private void updateBar(final OutgoingFileTransfer transfer, String nickname) { FileTransfer.Status status = transfer.getStatus(); if (status == Status.NEGOTIATING_STREAM) { titleLabel.setText("Negotiating file transfer with " + nickname + ". Please wait..."); } else if (status == Status.ERROR) { if (transfer.getException() != null) { Log.error("Error occured during file transfer.", transfer.getException()); } progressBar.setVisible(false); titleLabel.setText("You were unable to send the file to " + nickname); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } else if (status == Status.IN_PROGRESS) { titleLabel.setText("Sending a file to " + nickname); showAlert(false); if (!progressBar.isVisible()) { progressBar.setVisible(true); } progressBar.setValue((int)transfer.getBytesSent()); ByteFormat format = new ByteFormat(); String bytesSent = format.format(transfer.getBytesSent()); progressBar.setString(bytesSent + " sent"); } else if (status == Status.COMPLETE) { progressBar.setVisible(false); titleLabel.setText("You have sent a file to " + nickname + "."); cancelButton.setVisible(false); showAlert(true); } else if (status == Status.CANCLED) { progressBar.setVisible(false); titleLabel.setText("You have cancelled the file transfer."); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } else if (status == Status.REFUSED) { progressBar.setVisible(false); titleLabel.setText(nickname + " did not accept the file transfer."); cancelButton.setVisible(false); retryButton.setVisible(true); showAlert(true); } } |
context = new Context(null); | context = wm.getContext(); | public static void main(String arg[]) { Log.traceExceptions(true); Log.setLevel(Log.ALL); Log.setTarget(System.err); if (arg.length != 0) { System.out.println("Enabling log types"); Log.enableTypes(arg); } // Build a context WebMacro wm = null; Context context = null; try { wm = new WM(); context = new Context(null); Object names[] = { "prop" }; context.setProperty(names, "Example property"); } catch (Exception e) { e.printStackTrace(); } try { context.put("helloworld", "Hello World"); context.put("hello", "Hello"); context.put("file", "include.txt"); TestObject[] fruits = { new TestObject("apple",false), new TestObject("lemon",true), new TestObject("pear",false), new TestObject("orange",true), new TestObject("watermelon",false), new TestObject("peach",false), new TestObject("lime",true) }; SelectList sl = new SelectList(fruits, 3); context.put("sl-fruits", sl); context.put("fruits", fruits); context.put("flipper", new TestObject("flip",false)); System.out.println("- - - - - - - - - - - - - - - - - - - -"); System.out.println("Context contains: helloWorld, hello, file, TestObject[] fruits, SelectList sl(fruits, 3), TestObject flipper"); System.out.println("- - - - - - - - - - - - - - - - - - - -"); Template t1 = new StreamTemplate(wm.getBroker(), new InputStreamReader(System.in)); t1.parse(); Writer w = new OutputStreamWriter(System.out); System.out.println("*** RESULT ***"); t1.write(w,context); w.close(); System.out.println("*** DONE ***"); //System.out.println(result); } catch (Exception e) { e.printStackTrace(); } } |
private void ensureLocalCapacity(int size) { if (count < 0 || buffer[count] != null) { count++; offset[count] = localPos; length[count] = 0; if (count >= buffer.length) { increaseCapacity(); } } if ((localPos + size) >= local.length) { char[] tmpLocal = new char[local.length * 2 + size]; | private void ensureLocalCapacity(int len) { if ((localPos + len) >= local.length) { char[] tmpLocal = new char[local.length * 2 + len]; | private void ensureLocalCapacity(int size) { if (count < 0 || buffer[count] != null) { count++; offset[count] = localPos; length[count] = 0; if (count >= buffer.length) { increaseCapacity(); } } if ((localPos + size) >= local.length) { char[] tmpLocal = new char[local.length * 2 + size]; System.arraycopy(local,0,tmpLocal,0,local.length); local = tmpLocal; } } |
for (int i = 0; i < arg.length; i++) { qw.write(arg[i],1,arg[i].length() - 2); qw.write(' '); qw.write(cary,7,6); } System.out.println("Count: " + qw.count); System.out.println("- - - - Output - - - -"); System.out.println(qw.toString()); qw.reset(); } | for (int l = 0; l < 20; l++) { for (int i = 0; i < arg.length; i++) { qw.write(new String(arg[i])); qw.write(new String(arg[i]),0,arg[i].length()); qw.write(' '); qw.write(cary,7,6); } System.out.println("\ncount: " + qw.count); System.out.println("buffer: " + qw.buffer.length); System.out.println("local: " + qw.local.length); System.out.println("offset: " + qw.offset.length); System.out.println("length: " + qw.length.length); System.out.println("- - - - Output - - - -"); PrintWriter pw = new PrintWriter(System.err); qw.writeTo(pw); pw.flush(); qw.reset(); } } | public static void main(String arg[]) throws Exception { QueueWriter qw = new QueueWriter(3); char cary[] = "Hello, brave new world".toCharArray(); for (int j = 0; j < 2; j++) { for (int i = 0; i < arg.length; i++) { qw.write(arg[i],1,arg[i].length() - 2); // qw.write(arg[i]); qw.write(' '); qw.write(cary,7,6); } System.out.println("Count: " + qw.count); System.out.println("- - - - Output - - - -"); System.out.println(qw.toString()); qw.reset(); } } |
boolean moderated = wc.getForm ("MODERATED").equals ("true"); | boolean moderated = wc.getForm ("MODERATED") != null && wc.getForm("MODERATED").equals ("true"); | protected WikiPage createNewPage (WikiSystem wiki, WebContext wc, WikiUser user) throws Exception { // get the page elements from the request String editor = user.getIdentifier(); String text = wc.getForm ("TEXT"); boolean moderated = wc.getForm ("MODERATED").equals ("true"); String keywords = wc.getForm ("RELATED_TITLES"); String pageName = wc.getForm ("save"); // create the page System.err.println ("pageName: " + pageName); WikiPage newPage = wiki.createPage (pageName, editor, text); newPage.setRelatedTitles (keywordsToStringArray(keywords)); newPage.setIsModerated(moderated); System.err.println ("pageName: " + newPage.getTitle()); // make sure to save the page wiki.savePage (newPage); return newPage; } |
if (jid.indexOf("@") == -1) { jid = jid + "@" + item.getTransport().getServiceName(); String nickname = nicknameField.getText(); String group = (String)groupBox.getSelectedItem(); addEntry(jid, nickname, group); | try { jid = Gateway.getJID(transport.getServiceName(), jid); | private void addEntry() { Transport transport = null; AccountItem item = null; if (publicBox.isSelected()) { item = (AccountItem)accounts.getSelectedItem(); transport = item.getTransport(); } if (transport == null) { String jid = jidField.getText(); if (jid.indexOf("@") == -1) { jid = jid + "@" + SparkManager.getConnection().getServiceName(); } String nickname = nicknameField.getText(); String group = (String)groupBox.getSelectedItem(); jid = UserManager.escapeJID(jid); // Add as a new entry addEntry(jid, nickname, group); } else { String jid = jidField.getText(); if (jid.indexOf("@") == -1) { jid = jid + "@" + item.getTransport().getServiceName(); String nickname = nicknameField.getText(); String group = (String)groupBox.getSelectedItem(); addEntry(jid, nickname, group); } } } |
catch (XMPPException e) { Log.error(e); } String nickname = nicknameField.getText(); String group = (String)groupBox.getSelectedItem(); addEntry(jid, nickname, group); | private void addEntry() { Transport transport = null; AccountItem item = null; if (publicBox.isSelected()) { item = (AccountItem)accounts.getSelectedItem(); transport = item.getTransport(); } if (transport == null) { String jid = jidField.getText(); if (jid.indexOf("@") == -1) { jid = jid + "@" + SparkManager.getConnection().getServiceName(); } String nickname = nicknameField.getText(); String group = (String)groupBox.getSelectedItem(); jid = UserManager.escapeJID(jid); // Add as a new entry addEntry(jid, nickname, group); } else { String jid = jidField.getText(); if (jid.indexOf("@") == -1) { jid = jid + "@" + item.getTransport().getServiceName(); String nickname = nicknameField.getText(); String group = (String)groupBox.getSelectedItem(); addEntry(jid, nickname, group); } } } |
|
Log.error("Unable to find status item for status - " + text); | public void showPopup(MouseEvent e) { final JPopupMenu popup = new JPopupMenu(); List custom = CustomMessages.load(); if (custom == null) { custom = new ArrayList(); } // Build menu from StatusList for(final StatusItem statusItem : statusList){ final Action statusAction = new AbstractAction() { public void actionPerformed(ActionEvent actionEvent) { final String text = statusItem.getText(); final StatusItem si = getStatusItem(text); if (si == null) { // Custom status return; } SwingWorker worker = new SwingWorker() { public Object construct() { SparkManager.getSessionManager().changePresence(si.getPresence()); return "ok"; } public void finished() { setStatus(text); } }; worker.start(); } }; statusAction.putValue(Action.NAME, statusItem.getText()); statusAction.putValue(Action.SMALL_ICON, statusItem.getIcon()); // Has Children boolean hasChildren = false; Iterator customItemIterator = custom.iterator(); while (customItemIterator.hasNext()) { final CustomStatusItem cItem = (CustomStatusItem)customItemIterator.next(); String type = cItem.getType(); if (type.equals(statusItem.getText())) { hasChildren = true; } } if (!hasChildren) { // Add as Menu Item popup.add(statusAction); } else { final JMenu mainStatusItem = new JMenu(statusAction); popup.add(mainStatusItem); // Add Custom Messages customItemIterator = custom.iterator(); while (customItemIterator.hasNext()) { final CustomStatusItem customItem = (CustomStatusItem)customItemIterator.next(); String type = customItem.getType(); if (type.equals(statusItem.getText())) { // Add Child Menu Action action = new AbstractAction() { public void actionPerformed(ActionEvent actionEvent) { final String text = mainStatusItem.getText(); final StatusItem si = getStatusItem(text); if (si == null) { // Custom status return; } SwingWorker worker = new SwingWorker() { public Object construct() { Presence oldPresence = si.getPresence(); Presence presence = copyPresence(oldPresence); presence.setStatus(customItem.getStatus()); presence.setPriority(customItem.getPriority()); SparkManager.getSessionManager().changePresence(presence); return "ok"; } public void finished() { String status = customItem.getType() + " - " + customItem.getStatus(); setStatus(status); } }; worker.start(); } }; action.putValue(Action.NAME, customItem.getStatus()); action.putValue(Action.SMALL_ICON, statusItem.getIcon()); mainStatusItem.add(action); } } // If menu has children, allow it to still be clickable. mainStatusItem.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent mouseEvent) { statusAction.actionPerformed(null); popup.setVisible(false); } }); } } // Add change message final JMenuItem changeStatusMenu = new JMenuItem(Res.getString("menuitem.set.status.message"), SparkRes.getImageIcon(SparkRes.BLANK_IMAGE)); popup.addSeparator(); popup.add(changeStatusMenu); changeStatusMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { CustomMessages.addCustomMessage(); } }); Action editMessagesAction = new AbstractAction() { public void actionPerformed(ActionEvent actionEvent) { CustomMessages.editCustomMessages(); } }; editMessagesAction.putValue(Action.NAME, Res.getString("menuitem.edit.status.message")); popup.add(editMessagesAction); popup.show(statusPanel, 0, statusPanel.getHeight()); } |
|
Log.error("Unable to find status item for status - " + text); | public void actionPerformed(ActionEvent actionEvent) { final String text = statusItem.getText(); final StatusItem si = getStatusItem(text); if (si == null) { // Custom status return; } SwingWorker worker = new SwingWorker() { public Object construct() { SparkManager.getSessionManager().changePresence(si.getPresence()); return "ok"; } public void finished() { setStatus(text); } }; worker.start(); } |
|
Log.error("Unable to find status item for status - " + text); | public void actionPerformed(ActionEvent actionEvent) { final String text = mainStatusItem.getText(); final StatusItem si = getStatusItem(text); if (si == null) { // Custom status return; } SwingWorker worker = new SwingWorker() { public Object construct() { Presence oldPresence = si.getPresence(); Presence presence = copyPresence(oldPresence); presence.setStatus(customItem.getStatus()); presence.setPriority(customItem.getPriority()); SparkManager.getSessionManager().changePresence(presence); return "ok"; } public void finished() { String status = customItem.getType() + " - " + customItem.getStatus(); setStatus(status); } }; worker.start(); } |
|
return start + ((int) (1000000.0 * java.lang.Math.random()) % end); | return start + (int) (end *java.lang.Math.random()/(Integer.MAX_VALUE+1.0)); | public static final int random(int start, int end) { return start + ((int) (1000000.0 * java.lang.Math.random()) % end); } |
URL groovyJar = new URL("http: systemClassPath.addJarToPath(groovyJar); try { systemClassLoader.loadClass("groovy.lang.GroovyShell"); } catch (ClassNotFoundException e) { fail("Class already exists"); } | public void testAddJarToPath() throws Exception { SystemClassPath systemClassPath = new SystemClassPath(); ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader(); try { systemClassLoader.loadClass("groovy.lang.GroovyShell"); fail("Class already exists"); } catch (ClassNotFoundException e) { // this should fail } URL groovyJar = new URL("http://www.ibiblio.org/maven/groovy/jars/groovy-SNAPSHOT.jar"); systemClassPath.addJarToPath(groovyJar); try { systemClassLoader.loadClass("groovy.lang.GroovyShell"); } catch (ClassNotFoundException e) { // this should fail pass fail("Class already exists"); } } |
|
r = load(query); if (r != null) { _cache.put(query,r); | synchronized(_writeLocks[ query.hashCode() % _writeLocks.length]) { | public Object get(final String query) throws NotFoundException { TimedReference r; try { r = (TimedReference) _cache.get(query); } catch (NullPointerException e) { throw new NotFoundException(this + " is not initialized", e); } Object o = null; if (r != null) { o = r.get(); } if (o == null) { r = load(query); if (r != null) { _cache.put(query,r); o = r.get(); try { _log.debug("cached: " + query + " for " + r.getTimeout()); _tl.scheduleTime( new Runnable() { public void run() { _cache.remove(query); _log.debug("cache expired: " + query); } }, r.getTimeout()); } catch (Exception e) { _log.error("CachingProvider caught an exception", e); } } } return o; } |
try { _log.debug("cached: " + query + " for " + r.getTimeout()); _tl.scheduleTime( new Runnable() { public void run() { _cache.remove(query); _log.debug("cache expired: " + query); } }, r.getTimeout()); } catch (Exception e) { _log.error("CachingProvider caught an exception", e); | if (o == null) { r = load(query); if (r != null) { _cache.put(query,r); } o = r.get(); try { _log.debug("cached: " + query + " for " + r.getTimeout()); _tl.scheduleTime( new Runnable() { public void run() { _cache.remove(query); _log.debug("cache expired: " + query); } }, r.getTimeout()); } catch (Exception e) { _log.error("CachingProvider caught an exception", e); } | public Object get(final String query) throws NotFoundException { TimedReference r; try { r = (TimedReference) _cache.get(query); } catch (NullPointerException e) { throw new NotFoundException(this + " is not initialized", e); } Object o = null; if (r != null) { o = r.get(); } if (o == null) { r = load(query); if (r != null) { _cache.put(query,r); o = r.get(); try { _log.debug("cached: " + query + " for " + r.getTimeout()); _tl.scheduleTime( new Runnable() { public void run() { _cache.remove(query); _log.debug("cache expired: " + query); } }, r.getTimeout()); } catch (Exception e) { _log.error("CachingProvider caught an exception", e); } } } return o; } |