rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
} _cache.init(b, config, "PropertyOperator"); _restrictedClasses = new HashMap(11); String restrictList = b.getSetting("RestrictedClasses"); if (restrictList != null) { StringTokenizer stok = new StringTokenizer(restrictList, ","); while (stok.hasMoreTokens()) { String className = stok.nextToken(); try { Class c = Class.forName(className); String okMethList = b.getSetting("RestrictedClasses.AllowedMethods." + className); ArrayList okMeths = null; if (okMethList != null) { okMeths = new ArrayList(20); StringTokenizer stok2 = new StringTokenizer(okMethList, ","); while (stok2.hasMoreTokens()) { okMeths.add(stok2.nextToken()); } } _restrictedClasses.put(c, okMeths); } catch (Exception e) { _log.error("Configuration error: restricted class " + className + " cannot be loaded", e); } } } } | } } } | final public void init (Broker b, Settings config) throws InitException { String cacheManager; _log = b.getLog("resource", "Object loading and caching"); cacheManager = b.getSetting("PropertyOperator.CacheManager"); if (cacheManager == null || cacheManager.equals("")) { _log.info("CachingProvider: No cache manager specified for PropertyOperator, using SimpleCacheManager"); _cache = new SimpleCacheManager(); } else { try { _cache = (CacheManager) b.classForName(cacheManager).newInstance(); } catch (Exception e) { _log.warning("Unable to load cache manager " + cacheManager + " for PropertyOperator, using SimpleCacheManager. Reason:\n" + e); _cache = new SimpleCacheManager(); } } _cache.init(b, config, "PropertyOperator"); _restrictedClasses = new HashMap(11); String restrictList = b.getSetting("RestrictedClasses"); if (restrictList != null) { StringTokenizer stok = new StringTokenizer(restrictList, ","); while (stok.hasMoreTokens()) { String className = stok.nextToken(); try { Class c = Class.forName(className); String okMethList = b.getSetting("RestrictedClasses.AllowedMethods." + className); ArrayList okMeths = null; if (okMethList != null) { okMeths = new ArrayList(20); StringTokenizer stok2 = new StringTokenizer(okMethList, ","); while (stok2.hasMoreTokens()) { okMeths.add(stok2.nextToken()); } } _restrictedClasses.put(c, okMeths); } catch (Exception e) { _log.error("Configuration error: restricted class " + className + " cannot be loaded", e); } } } } |
final JScrollPane scrollPane = new JScrollPane(pane, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); | final JScrollPane scrollPane = new JScrollPane(pane, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); | private void retrieveNotes() { final PrivateNotes privateNotes = PrivateNotes.getPrivateNotes(); String text = privateNotes.getNotes(); final JLabel titleLabel = new JLabel("Notepad"); titleLabel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.LIGHT_GRAY)); titleLabel.setFont(new Font("Dialog", Font.BOLD, 13)); titleLabel.setHorizontalAlignment(JLabel.CENTER); final Image backgroundImage = SparkRes.getImageIcon(SparkRes.STICKY_NOTE_IMAGE).getImage(); final JTextPane pane = new JTextPane(); pane.setOpaque(false); final JScrollPane scrollPane = new JScrollPane(pane, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setOpaque(false); scrollPane.getViewport().setOpaque(false); scrollPane.setBorder(null); pane.setText(text); final RolloverButton button = new RolloverButton("Save", null); final RolloverButton cancelButton = new RolloverButton("Cancel", null); final JFrame frame = new JFrame("Notes"); frame.setUndecorated(true); titleLabel.addMouseMotionListener(new DragWindowAdapter(frame)); final JPanel mainPanel = new JPanel() { public void paintComponent(Graphics g) { double scaleX = getWidth() / (double)backgroundImage.getWidth(null); double scaleY = getHeight() / (double)backgroundImage.getHeight(null); AffineTransform xform = AffineTransform.getScaleInstance(scaleX, scaleY); ((Graphics2D)g).drawImage(backgroundImage, xform, this); } }; pane.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { if (e.getKeyChar() == KeyEvent.VK_ESCAPE) { frame.dispose(); // Save it. String text = pane.getText(); privateNotes.setNotes(text); PrivateNotes.savePrivateNotes(privateNotes); } } }); mainPanel.setBackground(Color.white); mainPanel.setLayout(new GridBagLayout()); frame.setIconImage(SparkManager.getMainWindow().getIconImage()); frame.getContentPane().add(mainPanel); mainPanel.add(titleLabel, new GridBagConstraints(0, 0, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); mainPanel.add(scrollPane, new GridBagConstraints(0, 1, 3, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); mainPanel.add(button, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); mainPanel.add(cancelButton, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); frame.pack(); frame.setSize(400, 400); GraphicUtils.centerWindowOnComponent(frame, SparkManager.getMainWindow()); frame.setVisible(true); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { frame.dispose(); // Save it. String text = pane.getText(); privateNotes.setNotes(text); PrivateNotes.savePrivateNotes(privateNotes); } }); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { frame.dispose(); } }); } |
pane.setCaretPosition(0); | private void retrieveNotes() { final PrivateNotes privateNotes = PrivateNotes.getPrivateNotes(); String text = privateNotes.getNotes(); final JLabel titleLabel = new JLabel("Notepad"); titleLabel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.LIGHT_GRAY)); titleLabel.setFont(new Font("Dialog", Font.BOLD, 13)); titleLabel.setHorizontalAlignment(JLabel.CENTER); final Image backgroundImage = SparkRes.getImageIcon(SparkRes.STICKY_NOTE_IMAGE).getImage(); final JTextPane pane = new JTextPane(); pane.setOpaque(false); final JScrollPane scrollPane = new JScrollPane(pane, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setOpaque(false); scrollPane.getViewport().setOpaque(false); scrollPane.setBorder(null); pane.setText(text); final RolloverButton button = new RolloverButton("Save", null); final RolloverButton cancelButton = new RolloverButton("Cancel", null); final JFrame frame = new JFrame("Notes"); frame.setUndecorated(true); titleLabel.addMouseMotionListener(new DragWindowAdapter(frame)); final JPanel mainPanel = new JPanel() { public void paintComponent(Graphics g) { double scaleX = getWidth() / (double)backgroundImage.getWidth(null); double scaleY = getHeight() / (double)backgroundImage.getHeight(null); AffineTransform xform = AffineTransform.getScaleInstance(scaleX, scaleY); ((Graphics2D)g).drawImage(backgroundImage, xform, this); } }; pane.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { if (e.getKeyChar() == KeyEvent.VK_ESCAPE) { frame.dispose(); // Save it. String text = pane.getText(); privateNotes.setNotes(text); PrivateNotes.savePrivateNotes(privateNotes); } } }); mainPanel.setBackground(Color.white); mainPanel.setLayout(new GridBagLayout()); frame.setIconImage(SparkManager.getMainWindow().getIconImage()); frame.getContentPane().add(mainPanel); mainPanel.add(titleLabel, new GridBagConstraints(0, 0, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); mainPanel.add(scrollPane, new GridBagConstraints(0, 1, 3, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); mainPanel.add(button, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); mainPanel.add(cancelButton, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); frame.pack(); frame.setSize(400, 400); GraphicUtils.centerWindowOnComponent(frame, SparkManager.getMainWindow()); frame.setVisible(true); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { frame.dispose(); // Save it. String text = pane.getText(); privateNotes.setNotes(text); PrivateNotes.savePrivateNotes(privateNotes); } }); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { frame.dispose(); } }); } |
|
void visitCollection(Collection collection) throws BeansException; | void visitCollection(Collection collection, Object data) throws BeansException; | void visitCollection(Collection collection) throws BeansException; |
void visitConstructorArgumentValues(ConstructorArgumentValues constructorArgumentValues) throws BeansException; | void visitConstructorArgumentValues(ConstructorArgumentValues constructorArgumentValues, Object data) throws BeansException; | void visitConstructorArgumentValues(ConstructorArgumentValues constructorArgumentValues) throws BeansException; |
void visitMap(Map map) throws BeansException; | void visitMap(Map map, Object data) throws BeansException; | void visitMap(Map map) throws BeansException; |
void visitMutablePropertyValues(MutablePropertyValues propertyValues) throws BeansException; | void visitMutablePropertyValues(MutablePropertyValues propertyValues, Object data) throws BeansException; | void visitMutablePropertyValues(MutablePropertyValues propertyValues) throws BeansException; |
void visitObject(Object value) throws BeansException; | void visitObject(Object value, Object data) throws BeansException; | void visitObject(Object value) throws BeansException; |
void visitPropertyValue(PropertyValue propertyValue) throws BeansException; | void visitPropertyValue(PropertyValue propertyValue, Object data) throws BeansException; | void visitPropertyValue(PropertyValue propertyValue) throws BeansException; |
void visitRuntimeBeanReference(RuntimeBeanReference beanReference) throws BeansException; | void visitRuntimeBeanReference(RuntimeBeanReference beanReference, Object data) throws BeansException; | void visitRuntimeBeanReference(RuntimeBeanReference beanReference) throws BeansException; |
try { checkForOldSettings(); } catch (Exception e) { Log.error(e); } | public LoginDialog() { localPref = SettingsManager.getLocalPreferences(); } |
|
Iterator contactGroups = new ArrayList(getContactGroups()).iterator(); | final Iterator contactGroups = new ArrayList(getContactGroups()).iterator(); | private void removeAllUsers() { // Behind the scenes, move everyone to the offline group. Iterator contactGroups = new ArrayList(getContactGroups()).iterator(); while (contactGroups.hasNext()) { ContactGroup contactGroup = (ContactGroup)contactGroups.next(); Iterator contactItems = new ArrayList(contactGroup.getContactItems()).iterator(); while (contactItems.hasNext()) { ContactItem item = (ContactItem)contactItems.next(); contactGroup.removeContactItem(item); } } } |
final Roster roster = SparkManager.getConnection().getRoster(); RosterEntry entry = roster.getEntry(jid); if (entry != null && entry.getType() == RosterPacket.ItemType.TO) { Presence response = new Presence(Presence.Type.subscribed); response.setTo(jid); SparkManager.getConnection().sendPacket(response); return; } String message = Res.getString("message.approve.subscription", UserManager.unescapeJID(jid)); final JPanel layoutPanel = new JPanel(); layoutPanel.setBackground(Color.white); layoutPanel.setLayout(new GridBagLayout()); WrappedLabel messageLabel = new WrappedLabel(); messageLabel.setText(message); layoutPanel.add(messageLabel, new GridBagConstraints(0, 0, 5, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); RolloverButton acceptButton = new RolloverButton(); ResourceUtils.resButton(acceptButton, Res.getString("button.accept")); RolloverButton viewInfoButton = new RolloverButton(); ResourceUtils.resButton(viewInfoButton, Res.getString("button.profile")); RolloverButton denyButton = new RolloverButton(); ResourceUtils.resButton(denyButton, Res.getString("button.deny")); layoutPanel.add(acceptButton, new GridBagConstraints(2, 1, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); layoutPanel.add(viewInfoButton, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); layoutPanel.add(denyButton, new GridBagConstraints(4, 1, 1, 1, 0.0, 1.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); acceptButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SparkManager.getWorkspace().removeAlert(layoutPanel); Presence response = new Presence(Presence.Type.subscribed); response.setTo(jid); SparkManager.getConnection().sendPacket(response); int ok = JOptionPane.showConfirmDialog(getGUI(), Res.getString("message.add.user"), Res.getString("message.add.to.roster"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (ok == JOptionPane.OK_OPTION) { RosterDialog rosterDialog = new RosterDialog(); rosterDialog.setDefaultJID(UserManager.unescapeJID(jid)); rosterDialog.showRosterDialog(); } } }); denyButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SparkManager.getWorkspace().removeAlert(layoutPanel); Presence response = new Presence(Presence.Type.unsubscribe); response.setTo(jid); SparkManager.getConnection().sendPacket(response); } }); viewInfoButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SparkManager.getVCardManager().viewProfile(jid, getGUI()); } }); SparkManager.getWorkspace().addAlert(layoutPanel); SparkManager.getAlertManager().flashWindowStopOnFocus(SparkManager.getMainWindow()); | final SubscriptionDialog subscriptionDialog = new SubscriptionDialog(); subscriptionDialog.invoke(jid); | private void subscriptionRequest(final String jid) { final Roster roster = SparkManager.getConnection().getRoster(); RosterEntry entry = roster.getEntry(jid); if (entry != null && entry.getType() == RosterPacket.ItemType.TO) { Presence response = new Presence(Presence.Type.subscribed); response.setTo(jid); SparkManager.getConnection().sendPacket(response); return; } String message = Res.getString("message.approve.subscription", UserManager.unescapeJID(jid)); final JPanel layoutPanel = new JPanel(); layoutPanel.setBackground(Color.white); layoutPanel.setLayout(new GridBagLayout()); WrappedLabel messageLabel = new WrappedLabel(); messageLabel.setText(message); layoutPanel.add(messageLabel, new GridBagConstraints(0, 0, 5, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); RolloverButton acceptButton = new RolloverButton(); ResourceUtils.resButton(acceptButton, Res.getString("button.accept")); RolloverButton viewInfoButton = new RolloverButton(); ResourceUtils.resButton(viewInfoButton, Res.getString("button.profile")); RolloverButton denyButton = new RolloverButton(); ResourceUtils.resButton(denyButton, Res.getString("button.deny")); layoutPanel.add(acceptButton, new GridBagConstraints(2, 1, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); layoutPanel.add(viewInfoButton, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); layoutPanel.add(denyButton, new GridBagConstraints(4, 1, 1, 1, 0.0, 1.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); acceptButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SparkManager.getWorkspace().removeAlert(layoutPanel); Presence response = new Presence(Presence.Type.subscribed); response.setTo(jid); SparkManager.getConnection().sendPacket(response); int ok = JOptionPane.showConfirmDialog(getGUI(), Res.getString("message.add.user"), Res.getString("message.add.to.roster"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (ok == JOptionPane.OK_OPTION) { RosterDialog rosterDialog = new RosterDialog(); rosterDialog.setDefaultJID(UserManager.unescapeJID(jid)); rosterDialog.showRosterDialog(); } } }); denyButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SparkManager.getWorkspace().removeAlert(layoutPanel); // Send subscribed Presence response = new Presence(Presence.Type.unsubscribe); response.setTo(jid); SparkManager.getConnection().sendPacket(response); } }); viewInfoButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SparkManager.getVCardManager().viewProfile(jid, getGUI()); } }); // show dialog SparkManager.getWorkspace().addAlert(layoutPanel); SparkManager.getAlertManager().flashWindowStopOnFocus(SparkManager.getMainWindow()); } |
insertText(Res.getString("message.your.voice.revoked")); | insertText(Res.getString("message.your.voice.granted")); | private void setupListeners() { chat.addParticipantStatusListener(new DefaultParticipantStatusListener() { public void kicked(String participant) { String nickname = StringUtils.parseResource(participant); insertText(Res.getString("message.user.kicked.from.room", nickname)); } public void voiceGranted(String participant) { String nickname = StringUtils.parseResource(participant); insertText(Res.getString("message.user.given.voice", nickname)); } public void voiceRevoked(String participant) { String nickname = StringUtils.parseResource(participant); insertText(Res.getString("message.user.voice.revoked", nickname)); } public void banned(String participant) { String nickname = StringUtils.parseResource(participant); insertText(Res.getString("message.user.banned", nickname)); } public void membershipGranted(String participant) { String nickname = StringUtils.parseResource(participant); insertText(Res.getString("message.user.granted.membership", nickname)); } public void membershipRevoked(String participant) { String nickname = StringUtils.parseResource(participant); insertText(Res.getString("message.user.revoked.membership", nickname)); } public void moderatorGranted(String participant) { String nickname = StringUtils.parseResource(participant); insertText(Res.getString("message.user.granted.moderator", nickname)); } public void moderatorRevoked(String participant) { String nickname = StringUtils.parseResource(participant); insertText(Res.getString("message.user.revoked.moderator", nickname)); } public void ownershipGranted(String participant) { String nickname = StringUtils.parseResource(participant); insertText(Res.getString("message.user.granted.owner", nickname)); } public void ownershipRevoked(String participant) { String nickname = StringUtils.parseResource(participant); insertText(Res.getString("message.user.revoked.owner", nickname)); } public void adminGranted(String participant) { String nickname = StringUtils.parseResource(participant); insertText(Res.getString("message.user.granted.admin", nickname)); } public void adminRevoked(String participant) { String nickname = StringUtils.parseResource(participant); insertText(Res.getString("message.user.revoked.admin", nickname)); } public void nicknameChanged(String participant, String nickname) { insertText(Res.getString("message.user.nickname.changed", StringUtils.parseResource(participant), nickname)); } }); chat.addUserStatusListener(new DefaultUserStatusListener() { public void kicked(String s, String reason) { insertText(Res.getString("message.your.kicked", s)); getChatInputEditor().setEnabled(false); getSplitPane().setRightComponent(null); leaveChatRoom(); } public void voiceGranted() { insertText(Res.getString("message.your.voice.revoked")); getChatInputEditor().setEnabled(true); } public void voiceRevoked() { insertText(Res.getString("message.your.voice.revoked")); getChatInputEditor().setEnabled(false); } public void banned(String s, String reason) { insertText(Res.getString("message.your.banned")); } public void membershipGranted() { insertText(Res.getString("message.your.membership.granted")); } public void membershipRevoked() { insertText(Res.getString("message.your.membership.revoked")); } public void moderatorGranted() { insertText(Res.getString("message.your.moderator.granted")); } public void moderatorRevoked() { insertText(Res.getString("message.your.moderator.revoked")); } public void ownershipGranted() { insertText(Res.getString("message.your.ownership.granted")); } public void ownershipRevoked() { insertText(Res.getString("message.your.ownership.revoked")); } public void adminGranted() { insertText(Res.getString("message.your.admin.granted")); } public void adminRevoked() { insertText(Res.getString("message.your.revoked.granted")); } }); chat.addSubjectUpdatedListener(new SubjectListener()); } |
insertText(Res.getString("message.your.voice.revoked")); | insertText(Res.getString("message.your.voice.granted")); | public void voiceGranted() { insertText(Res.getString("message.your.voice.revoked")); getChatInputEditor().setEnabled(true); } |
StatusItem statusItem = SparkManager.getWorkspace().getStatusBar().getItemFromPresence(presence); | 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; // 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(); // Add VCard Panel final VCardPanel vcardPanel = new VCardPanel(participantJID); getToolBar().add(vcardPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); } |
|
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; } | tabIcon = SparkManager.getUserManager().getIconFromPresence(presence); | 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; // 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(); // Add VCard Panel final VCardPanel vcardPanel = new VCardPanel(participantJID); getToolBar().add(vcardPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); } |
titleLabel.setFont(new Font("Verdana", Font.BOLD, 11)); | titleLabel.setFont(new Font("Dialog", Font.BOLD, 11)); | public ReceiveMessage() { 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)); add(acceptLabel, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); add(declineLabel, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); ResourceUtils.resButton(acceptLabel, "Accept"); ResourceUtils.resButton(declineLabel, "Reject"); // Decorate Cancel Button decorateCancelButton(); acceptLabel.setForeground(new Color(73, 113, 196)); declineLabel.setForeground(new Color(73, 113, 196)); declineLabel.setFont(new Font("Verdana", Font.BOLD, 10)); acceptLabel.setFont(new Font("Verdana", Font.BOLD, 10)); acceptLabel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(73, 113, 196))); declineLabel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(73, 113, 196))); setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.white)); acceptLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { acceptLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { acceptLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); declineLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { declineLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { declineLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); } |
ResourceUtils.resButton(acceptLabel, "Accept"); ResourceUtils.resButton(declineLabel, "Reject"); | ResourceUtils.resButton(acceptLabel, Res.getString("accept")); ResourceUtils.resButton(declineLabel, Res.getString("reject")); | public ReceiveMessage() { 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)); add(acceptLabel, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); add(declineLabel, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); ResourceUtils.resButton(acceptLabel, "Accept"); ResourceUtils.resButton(declineLabel, "Reject"); // Decorate Cancel Button decorateCancelButton(); acceptLabel.setForeground(new Color(73, 113, 196)); declineLabel.setForeground(new Color(73, 113, 196)); declineLabel.setFont(new Font("Verdana", Font.BOLD, 10)); acceptLabel.setFont(new Font("Verdana", Font.BOLD, 10)); acceptLabel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(73, 113, 196))); declineLabel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(73, 113, 196))); setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.white)); acceptLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { acceptLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { acceptLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); declineLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { declineLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { declineLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); } |
declineLabel.setFont(new Font("Verdana", Font.BOLD, 10)); acceptLabel.setFont(new Font("Verdana", Font.BOLD, 10)); | declineLabel.setFont(new Font("Dialog", Font.BOLD, 10)); acceptLabel.setFont(new Font("Dialog", Font.BOLD, 10)); | public ReceiveMessage() { 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)); add(acceptLabel, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); add(declineLabel, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); ResourceUtils.resButton(acceptLabel, "Accept"); ResourceUtils.resButton(declineLabel, "Reject"); // Decorate Cancel Button decorateCancelButton(); acceptLabel.setForeground(new Color(73, 113, 196)); declineLabel.setForeground(new Color(73, 113, 196)); declineLabel.setFont(new Font("Verdana", Font.BOLD, 10)); acceptLabel.setFont(new Font("Verdana", Font.BOLD, 10)); acceptLabel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(73, 113, 196))); declineLabel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(73, 113, 196))); setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.white)); acceptLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { acceptLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { acceptLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); declineLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { declineLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { declineLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); } |
titleLabel.setText(contactItem.getNickname() + " is sending you a file."); | titleLabel.setText(Res.getString("message.user.is.sending.you.a.file", contactItem.getNickname())); | public void acceptFileTransfer(final FileTransferRequest request) { String fileName = request.getFileName(); long fileSize = request.getFileSize(); String requestor = request.getRequestor(); String bareJID = StringUtils.parseBareAddress(requestor); ByteFormat format = new ByteFormat(); String text = format.format(fileSize); fileLabel.setText(fileName + " (" + text + ")"); ContactList contactList = SparkManager.getWorkspace().getContactList(); ContactItem contactItem = contactList.getContactItemByJID(bareJID); titleLabel.setText(contactItem.getNickname() + " is sending you a file."); File tempFile = new File(Spark.getUserHome(), "Spark/tmp"); try { tempFile.mkdirs(); File file = new File(tempFile, fileName); file.delete(); BufferedWriter out = new BufferedWriter(new FileWriter(file)); out.write("a"); out.close(); imageLabel.setIcon(GraphicUtils.getIcon(file)); // Delete temp file when program exits. file.delete(); } catch (IOException e) { imageLabel.setIcon(SparkRes.getImageIcon(SparkRes.DOCUMENT_INFO_32x32)); Log.error(e); } acceptLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent mouseEvent) { acceptRequest(request); } }); declineLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent mouseEvent) { rejectRequest(request); } }); } |
titleLabel.setText("Negotiating file transfer. Please wait..."); | titleLabel.setText(Res.getString("message.negotiate.file.transfer")); | private void acceptRequest(final FileTransferRequest request) { String requestor = request.getRequestor(); String bareJID = StringUtils.parseBareAddress(requestor); ContactList contactList = SparkManager.getWorkspace().getContactList(); final ContactItem contactItem = contactList.getContactItemByJID(bareJID); setBackground(new Color(239, 245, 250)); acceptLabel.setText(""); declineLabel.setText(""); titleLabel.setText("Negotiating file transfer. Please wait..."); titleLabel.setForeground(new Color(65, 139, 179)); add(progressBar, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 150, 0)); add(cancelButton, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); cancelButton.setVisible(true); transfer = request.accept(); try { Downloads downloads = Downloads.getInstance(); final File downloadedFile = new File(downloads.getDownloadDirectory(), request.getFileName()); progressBar.setMaximum((int)request.getFileSize()); progressBar.setStringPainted(true); SwingWorker worker = new SwingWorker() { public Object construct() { try { transfer.recieveFile(downloadedFile); } catch (XMPPException e) { Log.error(e); } while (true) { try { Thread.sleep(10); } catch (InterruptedException e) { Log.error(e); } long bytesRead = transfer.getAmountWritten(); if (bytesRead == -1) { bytesRead = 0; } ByteFormat format = new ByteFormat(); String text = format.format(bytesRead); progressBar.setString(text + " received"); progressBar.setValue((int)bytesRead); FileTransfer.Status status = transfer.getStatus(); if (status == FileTransfer.Status.ERROR || status == FileTransfer.Status.COMPLETE || status == FileTransfer.Status.CANCLED || status == FileTransfer.Status.REFUSED) { break; } else if (status == FileTransfer.Status.NEGOTIATING_STREAM) { titleLabel.setText("Negotiating connection stream. Please wait..."); } else if (status == FileTransfer.Status.IN_PROGRESS) { titleLabel.setText("You are receiving a file from " + contactItem.getNickname()); } } return "ok"; } public void finished() { if (transfer.getAmountWritten() >= request.getFileSize()) { transferDone(request, transfer); imageLabel.setToolTipText("Click to open"); titleLabel.setToolTipText("Click to open"); imageLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); imageLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); invalidate(); validate(); repaint(); return; } String transferMessage = ""; if (transfer.getStatus() == FileTransfer.Status.ERROR) { if (transfer.getException() != null) { Log.error("There was an error during file transfer.", transfer.getException()); } transferMessage = "There was an error during file transfer."; } else if (transfer.getStatus() == FileTransfer.Status.REFUSED) { transferMessage = "The file transfer was refused."; } else if (transfer.getStatus() == FileTransfer.Status.CANCLED || transfer.getAmountWritten() < request.getFileSize()) { transferMessage = "The file transfer was cancelled."; } setFinishedText(transferMessage); showAlert(true); } }; worker.start(); } catch (Exception e) { Log.error(e); } } |
if (status == FileTransfer.Status.ERROR || status == FileTransfer.Status.COMPLETE || status == FileTransfer.Status.CANCLED || status == FileTransfer.Status.REFUSED) { | if (status == FileTransfer.Status.error || status == FileTransfer.Status.complete || status == FileTransfer.Status.cancelled || status == FileTransfer.Status.refused) { | private void acceptRequest(final FileTransferRequest request) { String requestor = request.getRequestor(); String bareJID = StringUtils.parseBareAddress(requestor); ContactList contactList = SparkManager.getWorkspace().getContactList(); final ContactItem contactItem = contactList.getContactItemByJID(bareJID); setBackground(new Color(239, 245, 250)); acceptLabel.setText(""); declineLabel.setText(""); titleLabel.setText("Negotiating file transfer. Please wait..."); titleLabel.setForeground(new Color(65, 139, 179)); add(progressBar, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 150, 0)); add(cancelButton, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); cancelButton.setVisible(true); transfer = request.accept(); try { Downloads downloads = Downloads.getInstance(); final File downloadedFile = new File(downloads.getDownloadDirectory(), request.getFileName()); progressBar.setMaximum((int)request.getFileSize()); progressBar.setStringPainted(true); SwingWorker worker = new SwingWorker() { public Object construct() { try { transfer.recieveFile(downloadedFile); } catch (XMPPException e) { Log.error(e); } while (true) { try { Thread.sleep(10); } catch (InterruptedException e) { Log.error(e); } long bytesRead = transfer.getAmountWritten(); if (bytesRead == -1) { bytesRead = 0; } ByteFormat format = new ByteFormat(); String text = format.format(bytesRead); progressBar.setString(text + " received"); progressBar.setValue((int)bytesRead); FileTransfer.Status status = transfer.getStatus(); if (status == FileTransfer.Status.ERROR || status == FileTransfer.Status.COMPLETE || status == FileTransfer.Status.CANCLED || status == FileTransfer.Status.REFUSED) { break; } else if (status == FileTransfer.Status.NEGOTIATING_STREAM) { titleLabel.setText("Negotiating connection stream. Please wait..."); } else if (status == FileTransfer.Status.IN_PROGRESS) { titleLabel.setText("You are receiving a file from " + contactItem.getNickname()); } } return "ok"; } public void finished() { if (transfer.getAmountWritten() >= request.getFileSize()) { transferDone(request, transfer); imageLabel.setToolTipText("Click to open"); titleLabel.setToolTipText("Click to open"); imageLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); imageLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); invalidate(); validate(); repaint(); return; } String transferMessage = ""; if (transfer.getStatus() == FileTransfer.Status.ERROR) { if (transfer.getException() != null) { Log.error("There was an error during file transfer.", transfer.getException()); } transferMessage = "There was an error during file transfer."; } else if (transfer.getStatus() == FileTransfer.Status.REFUSED) { transferMessage = "The file transfer was refused."; } else if (transfer.getStatus() == FileTransfer.Status.CANCLED || transfer.getAmountWritten() < request.getFileSize()) { transferMessage = "The file transfer was cancelled."; } setFinishedText(transferMessage); showAlert(true); } }; worker.start(); } catch (Exception e) { Log.error(e); } } |
else if (status == FileTransfer.Status.NEGOTIATING_STREAM) { titleLabel.setText("Negotiating connection stream. Please wait..."); | else if (status == FileTransfer.Status.negotiating_stream) { titleLabel.setText(Res.getString("message.negotiate.stream")); | private void acceptRequest(final FileTransferRequest request) { String requestor = request.getRequestor(); String bareJID = StringUtils.parseBareAddress(requestor); ContactList contactList = SparkManager.getWorkspace().getContactList(); final ContactItem contactItem = contactList.getContactItemByJID(bareJID); setBackground(new Color(239, 245, 250)); acceptLabel.setText(""); declineLabel.setText(""); titleLabel.setText("Negotiating file transfer. Please wait..."); titleLabel.setForeground(new Color(65, 139, 179)); add(progressBar, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 150, 0)); add(cancelButton, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); cancelButton.setVisible(true); transfer = request.accept(); try { Downloads downloads = Downloads.getInstance(); final File downloadedFile = new File(downloads.getDownloadDirectory(), request.getFileName()); progressBar.setMaximum((int)request.getFileSize()); progressBar.setStringPainted(true); SwingWorker worker = new SwingWorker() { public Object construct() { try { transfer.recieveFile(downloadedFile); } catch (XMPPException e) { Log.error(e); } while (true) { try { Thread.sleep(10); } catch (InterruptedException e) { Log.error(e); } long bytesRead = transfer.getAmountWritten(); if (bytesRead == -1) { bytesRead = 0; } ByteFormat format = new ByteFormat(); String text = format.format(bytesRead); progressBar.setString(text + " received"); progressBar.setValue((int)bytesRead); FileTransfer.Status status = transfer.getStatus(); if (status == FileTransfer.Status.ERROR || status == FileTransfer.Status.COMPLETE || status == FileTransfer.Status.CANCLED || status == FileTransfer.Status.REFUSED) { break; } else if (status == FileTransfer.Status.NEGOTIATING_STREAM) { titleLabel.setText("Negotiating connection stream. Please wait..."); } else if (status == FileTransfer.Status.IN_PROGRESS) { titleLabel.setText("You are receiving a file from " + contactItem.getNickname()); } } return "ok"; } public void finished() { if (transfer.getAmountWritten() >= request.getFileSize()) { transferDone(request, transfer); imageLabel.setToolTipText("Click to open"); titleLabel.setToolTipText("Click to open"); imageLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); imageLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); invalidate(); validate(); repaint(); return; } String transferMessage = ""; if (transfer.getStatus() == FileTransfer.Status.ERROR) { if (transfer.getException() != null) { Log.error("There was an error during file transfer.", transfer.getException()); } transferMessage = "There was an error during file transfer."; } else if (transfer.getStatus() == FileTransfer.Status.REFUSED) { transferMessage = "The file transfer was refused."; } else if (transfer.getStatus() == FileTransfer.Status.CANCLED || transfer.getAmountWritten() < request.getFileSize()) { transferMessage = "The file transfer was cancelled."; } setFinishedText(transferMessage); showAlert(true); } }; worker.start(); } catch (Exception e) { Log.error(e); } } |
else if (status == FileTransfer.Status.IN_PROGRESS) { titleLabel.setText("You are receiving a file from " + contactItem.getNickname()); | else if (status == FileTransfer.Status.in_progress) { titleLabel.setText(Res.getString("message.receiving.file", contactItem.getNickname())); | private void acceptRequest(final FileTransferRequest request) { String requestor = request.getRequestor(); String bareJID = StringUtils.parseBareAddress(requestor); ContactList contactList = SparkManager.getWorkspace().getContactList(); final ContactItem contactItem = contactList.getContactItemByJID(bareJID); setBackground(new Color(239, 245, 250)); acceptLabel.setText(""); declineLabel.setText(""); titleLabel.setText("Negotiating file transfer. Please wait..."); titleLabel.setForeground(new Color(65, 139, 179)); add(progressBar, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 150, 0)); add(cancelButton, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); cancelButton.setVisible(true); transfer = request.accept(); try { Downloads downloads = Downloads.getInstance(); final File downloadedFile = new File(downloads.getDownloadDirectory(), request.getFileName()); progressBar.setMaximum((int)request.getFileSize()); progressBar.setStringPainted(true); SwingWorker worker = new SwingWorker() { public Object construct() { try { transfer.recieveFile(downloadedFile); } catch (XMPPException e) { Log.error(e); } while (true) { try { Thread.sleep(10); } catch (InterruptedException e) { Log.error(e); } long bytesRead = transfer.getAmountWritten(); if (bytesRead == -1) { bytesRead = 0; } ByteFormat format = new ByteFormat(); String text = format.format(bytesRead); progressBar.setString(text + " received"); progressBar.setValue((int)bytesRead); FileTransfer.Status status = transfer.getStatus(); if (status == FileTransfer.Status.ERROR || status == FileTransfer.Status.COMPLETE || status == FileTransfer.Status.CANCLED || status == FileTransfer.Status.REFUSED) { break; } else if (status == FileTransfer.Status.NEGOTIATING_STREAM) { titleLabel.setText("Negotiating connection stream. Please wait..."); } else if (status == FileTransfer.Status.IN_PROGRESS) { titleLabel.setText("You are receiving a file from " + contactItem.getNickname()); } } return "ok"; } public void finished() { if (transfer.getAmountWritten() >= request.getFileSize()) { transferDone(request, transfer); imageLabel.setToolTipText("Click to open"); titleLabel.setToolTipText("Click to open"); imageLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); imageLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); invalidate(); validate(); repaint(); return; } String transferMessage = ""; if (transfer.getStatus() == FileTransfer.Status.ERROR) { if (transfer.getException() != null) { Log.error("There was an error during file transfer.", transfer.getException()); } transferMessage = "There was an error during file transfer."; } else if (transfer.getStatus() == FileTransfer.Status.REFUSED) { transferMessage = "The file transfer was refused."; } else if (transfer.getStatus() == FileTransfer.Status.CANCLED || transfer.getAmountWritten() < request.getFileSize()) { transferMessage = "The file transfer was cancelled."; } setFinishedText(transferMessage); showAlert(true); } }; worker.start(); } catch (Exception e) { Log.error(e); } } |
imageLabel.setToolTipText("Click to open"); titleLabel.setToolTipText("Click to open"); | imageLabel.setToolTipText(Res.getString("message.click.to.open")); titleLabel.setToolTipText(Res.getString("message.click.to.open")); | private void acceptRequest(final FileTransferRequest request) { String requestor = request.getRequestor(); String bareJID = StringUtils.parseBareAddress(requestor); ContactList contactList = SparkManager.getWorkspace().getContactList(); final ContactItem contactItem = contactList.getContactItemByJID(bareJID); setBackground(new Color(239, 245, 250)); acceptLabel.setText(""); declineLabel.setText(""); titleLabel.setText("Negotiating file transfer. Please wait..."); titleLabel.setForeground(new Color(65, 139, 179)); add(progressBar, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 150, 0)); add(cancelButton, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); cancelButton.setVisible(true); transfer = request.accept(); try { Downloads downloads = Downloads.getInstance(); final File downloadedFile = new File(downloads.getDownloadDirectory(), request.getFileName()); progressBar.setMaximum((int)request.getFileSize()); progressBar.setStringPainted(true); SwingWorker worker = new SwingWorker() { public Object construct() { try { transfer.recieveFile(downloadedFile); } catch (XMPPException e) { Log.error(e); } while (true) { try { Thread.sleep(10); } catch (InterruptedException e) { Log.error(e); } long bytesRead = transfer.getAmountWritten(); if (bytesRead == -1) { bytesRead = 0; } ByteFormat format = new ByteFormat(); String text = format.format(bytesRead); progressBar.setString(text + " received"); progressBar.setValue((int)bytesRead); FileTransfer.Status status = transfer.getStatus(); if (status == FileTransfer.Status.ERROR || status == FileTransfer.Status.COMPLETE || status == FileTransfer.Status.CANCLED || status == FileTransfer.Status.REFUSED) { break; } else if (status == FileTransfer.Status.NEGOTIATING_STREAM) { titleLabel.setText("Negotiating connection stream. Please wait..."); } else if (status == FileTransfer.Status.IN_PROGRESS) { titleLabel.setText("You are receiving a file from " + contactItem.getNickname()); } } return "ok"; } public void finished() { if (transfer.getAmountWritten() >= request.getFileSize()) { transferDone(request, transfer); imageLabel.setToolTipText("Click to open"); titleLabel.setToolTipText("Click to open"); imageLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); imageLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); invalidate(); validate(); repaint(); return; } String transferMessage = ""; if (transfer.getStatus() == FileTransfer.Status.ERROR) { if (transfer.getException() != null) { Log.error("There was an error during file transfer.", transfer.getException()); } transferMessage = "There was an error during file transfer."; } else if (transfer.getStatus() == FileTransfer.Status.REFUSED) { transferMessage = "The file transfer was refused."; } else if (transfer.getStatus() == FileTransfer.Status.CANCLED || transfer.getAmountWritten() < request.getFileSize()) { transferMessage = "The file transfer was cancelled."; } setFinishedText(transferMessage); showAlert(true); } }; worker.start(); } catch (Exception e) { Log.error(e); } } |
if (transfer.getStatus() == FileTransfer.Status.ERROR) { | if (transfer.getStatus() == FileTransfer.Status.error) { | private void acceptRequest(final FileTransferRequest request) { String requestor = request.getRequestor(); String bareJID = StringUtils.parseBareAddress(requestor); ContactList contactList = SparkManager.getWorkspace().getContactList(); final ContactItem contactItem = contactList.getContactItemByJID(bareJID); setBackground(new Color(239, 245, 250)); acceptLabel.setText(""); declineLabel.setText(""); titleLabel.setText("Negotiating file transfer. Please wait..."); titleLabel.setForeground(new Color(65, 139, 179)); add(progressBar, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 150, 0)); add(cancelButton, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); cancelButton.setVisible(true); transfer = request.accept(); try { Downloads downloads = Downloads.getInstance(); final File downloadedFile = new File(downloads.getDownloadDirectory(), request.getFileName()); progressBar.setMaximum((int)request.getFileSize()); progressBar.setStringPainted(true); SwingWorker worker = new SwingWorker() { public Object construct() { try { transfer.recieveFile(downloadedFile); } catch (XMPPException e) { Log.error(e); } while (true) { try { Thread.sleep(10); } catch (InterruptedException e) { Log.error(e); } long bytesRead = transfer.getAmountWritten(); if (bytesRead == -1) { bytesRead = 0; } ByteFormat format = new ByteFormat(); String text = format.format(bytesRead); progressBar.setString(text + " received"); progressBar.setValue((int)bytesRead); FileTransfer.Status status = transfer.getStatus(); if (status == FileTransfer.Status.ERROR || status == FileTransfer.Status.COMPLETE || status == FileTransfer.Status.CANCLED || status == FileTransfer.Status.REFUSED) { break; } else if (status == FileTransfer.Status.NEGOTIATING_STREAM) { titleLabel.setText("Negotiating connection stream. Please wait..."); } else if (status == FileTransfer.Status.IN_PROGRESS) { titleLabel.setText("You are receiving a file from " + contactItem.getNickname()); } } return "ok"; } public void finished() { if (transfer.getAmountWritten() >= request.getFileSize()) { transferDone(request, transfer); imageLabel.setToolTipText("Click to open"); titleLabel.setToolTipText("Click to open"); imageLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); imageLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); invalidate(); validate(); repaint(); return; } String transferMessage = ""; if (transfer.getStatus() == FileTransfer.Status.ERROR) { if (transfer.getException() != null) { Log.error("There was an error during file transfer.", transfer.getException()); } transferMessage = "There was an error during file transfer."; } else if (transfer.getStatus() == FileTransfer.Status.REFUSED) { transferMessage = "The file transfer was refused."; } else if (transfer.getStatus() == FileTransfer.Status.CANCLED || transfer.getAmountWritten() < request.getFileSize()) { transferMessage = "The file transfer was cancelled."; } setFinishedText(transferMessage); showAlert(true); } }; worker.start(); } catch (Exception e) { Log.error(e); } } |
transferMessage = "There was an error during file transfer."; | transferMessage = Res.getString("message.error.during.file.transfer"); | private void acceptRequest(final FileTransferRequest request) { String requestor = request.getRequestor(); String bareJID = StringUtils.parseBareAddress(requestor); ContactList contactList = SparkManager.getWorkspace().getContactList(); final ContactItem contactItem = contactList.getContactItemByJID(bareJID); setBackground(new Color(239, 245, 250)); acceptLabel.setText(""); declineLabel.setText(""); titleLabel.setText("Negotiating file transfer. Please wait..."); titleLabel.setForeground(new Color(65, 139, 179)); add(progressBar, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 150, 0)); add(cancelButton, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); cancelButton.setVisible(true); transfer = request.accept(); try { Downloads downloads = Downloads.getInstance(); final File downloadedFile = new File(downloads.getDownloadDirectory(), request.getFileName()); progressBar.setMaximum((int)request.getFileSize()); progressBar.setStringPainted(true); SwingWorker worker = new SwingWorker() { public Object construct() { try { transfer.recieveFile(downloadedFile); } catch (XMPPException e) { Log.error(e); } while (true) { try { Thread.sleep(10); } catch (InterruptedException e) { Log.error(e); } long bytesRead = transfer.getAmountWritten(); if (bytesRead == -1) { bytesRead = 0; } ByteFormat format = new ByteFormat(); String text = format.format(bytesRead); progressBar.setString(text + " received"); progressBar.setValue((int)bytesRead); FileTransfer.Status status = transfer.getStatus(); if (status == FileTransfer.Status.ERROR || status == FileTransfer.Status.COMPLETE || status == FileTransfer.Status.CANCLED || status == FileTransfer.Status.REFUSED) { break; } else if (status == FileTransfer.Status.NEGOTIATING_STREAM) { titleLabel.setText("Negotiating connection stream. Please wait..."); } else if (status == FileTransfer.Status.IN_PROGRESS) { titleLabel.setText("You are receiving a file from " + contactItem.getNickname()); } } return "ok"; } public void finished() { if (transfer.getAmountWritten() >= request.getFileSize()) { transferDone(request, transfer); imageLabel.setToolTipText("Click to open"); titleLabel.setToolTipText("Click to open"); imageLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); imageLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); invalidate(); validate(); repaint(); return; } String transferMessage = ""; if (transfer.getStatus() == FileTransfer.Status.ERROR) { if (transfer.getException() != null) { Log.error("There was an error during file transfer.", transfer.getException()); } transferMessage = "There was an error during file transfer."; } else if (transfer.getStatus() == FileTransfer.Status.REFUSED) { transferMessage = "The file transfer was refused."; } else if (transfer.getStatus() == FileTransfer.Status.CANCLED || transfer.getAmountWritten() < request.getFileSize()) { transferMessage = "The file transfer was cancelled."; } setFinishedText(transferMessage); showAlert(true); } }; worker.start(); } catch (Exception e) { Log.error(e); } } |
else if (transfer.getStatus() == FileTransfer.Status.REFUSED) { transferMessage = "The file transfer was refused."; | else if (transfer.getStatus() == FileTransfer.Status.refused) { transferMessage = Res.getString("message.transfer.refused"); | private void acceptRequest(final FileTransferRequest request) { String requestor = request.getRequestor(); String bareJID = StringUtils.parseBareAddress(requestor); ContactList contactList = SparkManager.getWorkspace().getContactList(); final ContactItem contactItem = contactList.getContactItemByJID(bareJID); setBackground(new Color(239, 245, 250)); acceptLabel.setText(""); declineLabel.setText(""); titleLabel.setText("Negotiating file transfer. Please wait..."); titleLabel.setForeground(new Color(65, 139, 179)); add(progressBar, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 150, 0)); add(cancelButton, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); cancelButton.setVisible(true); transfer = request.accept(); try { Downloads downloads = Downloads.getInstance(); final File downloadedFile = new File(downloads.getDownloadDirectory(), request.getFileName()); progressBar.setMaximum((int)request.getFileSize()); progressBar.setStringPainted(true); SwingWorker worker = new SwingWorker() { public Object construct() { try { transfer.recieveFile(downloadedFile); } catch (XMPPException e) { Log.error(e); } while (true) { try { Thread.sleep(10); } catch (InterruptedException e) { Log.error(e); } long bytesRead = transfer.getAmountWritten(); if (bytesRead == -1) { bytesRead = 0; } ByteFormat format = new ByteFormat(); String text = format.format(bytesRead); progressBar.setString(text + " received"); progressBar.setValue((int)bytesRead); FileTransfer.Status status = transfer.getStatus(); if (status == FileTransfer.Status.ERROR || status == FileTransfer.Status.COMPLETE || status == FileTransfer.Status.CANCLED || status == FileTransfer.Status.REFUSED) { break; } else if (status == FileTransfer.Status.NEGOTIATING_STREAM) { titleLabel.setText("Negotiating connection stream. Please wait..."); } else if (status == FileTransfer.Status.IN_PROGRESS) { titleLabel.setText("You are receiving a file from " + contactItem.getNickname()); } } return "ok"; } public void finished() { if (transfer.getAmountWritten() >= request.getFileSize()) { transferDone(request, transfer); imageLabel.setToolTipText("Click to open"); titleLabel.setToolTipText("Click to open"); imageLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); imageLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); invalidate(); validate(); repaint(); return; } String transferMessage = ""; if (transfer.getStatus() == FileTransfer.Status.ERROR) { if (transfer.getException() != null) { Log.error("There was an error during file transfer.", transfer.getException()); } transferMessage = "There was an error during file transfer."; } else if (transfer.getStatus() == FileTransfer.Status.REFUSED) { transferMessage = "The file transfer was refused."; } else if (transfer.getStatus() == FileTransfer.Status.CANCLED || transfer.getAmountWritten() < request.getFileSize()) { transferMessage = "The file transfer was cancelled."; } setFinishedText(transferMessage); showAlert(true); } }; worker.start(); } catch (Exception e) { Log.error(e); } } |
else if (transfer.getStatus() == FileTransfer.Status.CANCLED || | else if (transfer.getStatus() == FileTransfer.Status.cancelled || | private void acceptRequest(final FileTransferRequest request) { String requestor = request.getRequestor(); String bareJID = StringUtils.parseBareAddress(requestor); ContactList contactList = SparkManager.getWorkspace().getContactList(); final ContactItem contactItem = contactList.getContactItemByJID(bareJID); setBackground(new Color(239, 245, 250)); acceptLabel.setText(""); declineLabel.setText(""); titleLabel.setText("Negotiating file transfer. Please wait..."); titleLabel.setForeground(new Color(65, 139, 179)); add(progressBar, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 150, 0)); add(cancelButton, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); cancelButton.setVisible(true); transfer = request.accept(); try { Downloads downloads = Downloads.getInstance(); final File downloadedFile = new File(downloads.getDownloadDirectory(), request.getFileName()); progressBar.setMaximum((int)request.getFileSize()); progressBar.setStringPainted(true); SwingWorker worker = new SwingWorker() { public Object construct() { try { transfer.recieveFile(downloadedFile); } catch (XMPPException e) { Log.error(e); } while (true) { try { Thread.sleep(10); } catch (InterruptedException e) { Log.error(e); } long bytesRead = transfer.getAmountWritten(); if (bytesRead == -1) { bytesRead = 0; } ByteFormat format = new ByteFormat(); String text = format.format(bytesRead); progressBar.setString(text + " received"); progressBar.setValue((int)bytesRead); FileTransfer.Status status = transfer.getStatus(); if (status == FileTransfer.Status.ERROR || status == FileTransfer.Status.COMPLETE || status == FileTransfer.Status.CANCLED || status == FileTransfer.Status.REFUSED) { break; } else if (status == FileTransfer.Status.NEGOTIATING_STREAM) { titleLabel.setText("Negotiating connection stream. Please wait..."); } else if (status == FileTransfer.Status.IN_PROGRESS) { titleLabel.setText("You are receiving a file from " + contactItem.getNickname()); } } return "ok"; } public void finished() { if (transfer.getAmountWritten() >= request.getFileSize()) { transferDone(request, transfer); imageLabel.setToolTipText("Click to open"); titleLabel.setToolTipText("Click to open"); imageLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); imageLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); invalidate(); validate(); repaint(); return; } String transferMessage = ""; if (transfer.getStatus() == FileTransfer.Status.ERROR) { if (transfer.getException() != null) { Log.error("There was an error during file transfer.", transfer.getException()); } transferMessage = "There was an error during file transfer."; } else if (transfer.getStatus() == FileTransfer.Status.REFUSED) { transferMessage = "The file transfer was refused."; } else if (transfer.getStatus() == FileTransfer.Status.CANCLED || transfer.getAmountWritten() < request.getFileSize()) { transferMessage = "The file transfer was cancelled."; } setFinishedText(transferMessage); showAlert(true); } }; worker.start(); } catch (Exception e) { Log.error(e); } } |
transferMessage = "The file transfer was cancelled."; | transferMessage = Res.getString("message.transfer.cancelled"); | private void acceptRequest(final FileTransferRequest request) { String requestor = request.getRequestor(); String bareJID = StringUtils.parseBareAddress(requestor); ContactList contactList = SparkManager.getWorkspace().getContactList(); final ContactItem contactItem = contactList.getContactItemByJID(bareJID); setBackground(new Color(239, 245, 250)); acceptLabel.setText(""); declineLabel.setText(""); titleLabel.setText("Negotiating file transfer. Please wait..."); titleLabel.setForeground(new Color(65, 139, 179)); add(progressBar, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 150, 0)); add(cancelButton, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); cancelButton.setVisible(true); transfer = request.accept(); try { Downloads downloads = Downloads.getInstance(); final File downloadedFile = new File(downloads.getDownloadDirectory(), request.getFileName()); progressBar.setMaximum((int)request.getFileSize()); progressBar.setStringPainted(true); SwingWorker worker = new SwingWorker() { public Object construct() { try { transfer.recieveFile(downloadedFile); } catch (XMPPException e) { Log.error(e); } while (true) { try { Thread.sleep(10); } catch (InterruptedException e) { Log.error(e); } long bytesRead = transfer.getAmountWritten(); if (bytesRead == -1) { bytesRead = 0; } ByteFormat format = new ByteFormat(); String text = format.format(bytesRead); progressBar.setString(text + " received"); progressBar.setValue((int)bytesRead); FileTransfer.Status status = transfer.getStatus(); if (status == FileTransfer.Status.ERROR || status == FileTransfer.Status.COMPLETE || status == FileTransfer.Status.CANCLED || status == FileTransfer.Status.REFUSED) { break; } else if (status == FileTransfer.Status.NEGOTIATING_STREAM) { titleLabel.setText("Negotiating connection stream. Please wait..."); } else if (status == FileTransfer.Status.IN_PROGRESS) { titleLabel.setText("You are receiving a file from " + contactItem.getNickname()); } } return "ok"; } public void finished() { if (transfer.getAmountWritten() >= request.getFileSize()) { transferDone(request, transfer); imageLabel.setToolTipText("Click to open"); titleLabel.setToolTipText("Click to open"); imageLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); imageLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); invalidate(); validate(); repaint(); return; } String transferMessage = ""; if (transfer.getStatus() == FileTransfer.Status.ERROR) { if (transfer.getException() != null) { Log.error("There was an error during file transfer.", transfer.getException()); } transferMessage = "There was an error during file transfer."; } else if (transfer.getStatus() == FileTransfer.Status.REFUSED) { transferMessage = "The file transfer was refused."; } else if (transfer.getStatus() == FileTransfer.Status.CANCLED || transfer.getAmountWritten() < request.getFileSize()) { transferMessage = "The file transfer was cancelled."; } setFinishedText(transferMessage); showAlert(true); } }; worker.start(); } catch (Exception e) { Log.error(e); } } |
if (status == FileTransfer.Status.ERROR || status == FileTransfer.Status.COMPLETE || status == FileTransfer.Status.CANCLED || status == FileTransfer.Status.REFUSED) { | if (status == FileTransfer.Status.error || status == FileTransfer.Status.complete || status == FileTransfer.Status.cancelled || status == FileTransfer.Status.refused) { | public Object construct() { try { transfer.recieveFile(downloadedFile); } catch (XMPPException e) { Log.error(e); } while (true) { try { Thread.sleep(10); } catch (InterruptedException e) { Log.error(e); } long bytesRead = transfer.getAmountWritten(); if (bytesRead == -1) { bytesRead = 0; } ByteFormat format = new ByteFormat(); String text = format.format(bytesRead); progressBar.setString(text + " received"); progressBar.setValue((int)bytesRead); FileTransfer.Status status = transfer.getStatus(); if (status == FileTransfer.Status.ERROR || status == FileTransfer.Status.COMPLETE || status == FileTransfer.Status.CANCLED || status == FileTransfer.Status.REFUSED) { break; } else if (status == FileTransfer.Status.NEGOTIATING_STREAM) { titleLabel.setText("Negotiating connection stream. Please wait..."); } else if (status == FileTransfer.Status.IN_PROGRESS) { titleLabel.setText("You are receiving a file from " + contactItem.getNickname()); } } return "ok"; } |
else if (status == FileTransfer.Status.NEGOTIATING_STREAM) { titleLabel.setText("Negotiating connection stream. Please wait..."); | else if (status == FileTransfer.Status.negotiating_stream) { titleLabel.setText(Res.getString("message.negotiate.stream")); | public Object construct() { try { transfer.recieveFile(downloadedFile); } catch (XMPPException e) { Log.error(e); } while (true) { try { Thread.sleep(10); } catch (InterruptedException e) { Log.error(e); } long bytesRead = transfer.getAmountWritten(); if (bytesRead == -1) { bytesRead = 0; } ByteFormat format = new ByteFormat(); String text = format.format(bytesRead); progressBar.setString(text + " received"); progressBar.setValue((int)bytesRead); FileTransfer.Status status = transfer.getStatus(); if (status == FileTransfer.Status.ERROR || status == FileTransfer.Status.COMPLETE || status == FileTransfer.Status.CANCLED || status == FileTransfer.Status.REFUSED) { break; } else if (status == FileTransfer.Status.NEGOTIATING_STREAM) { titleLabel.setText("Negotiating connection stream. Please wait..."); } else if (status == FileTransfer.Status.IN_PROGRESS) { titleLabel.setText("You are receiving a file from " + contactItem.getNickname()); } } return "ok"; } |
else if (status == FileTransfer.Status.IN_PROGRESS) { titleLabel.setText("You are receiving a file from " + contactItem.getNickname()); | else if (status == FileTransfer.Status.in_progress) { titleLabel.setText(Res.getString("message.receiving.file", contactItem.getNickname())); | public Object construct() { try { transfer.recieveFile(downloadedFile); } catch (XMPPException e) { Log.error(e); } while (true) { try { Thread.sleep(10); } catch (InterruptedException e) { Log.error(e); } long bytesRead = transfer.getAmountWritten(); if (bytesRead == -1) { bytesRead = 0; } ByteFormat format = new ByteFormat(); String text = format.format(bytesRead); progressBar.setString(text + " received"); progressBar.setValue((int)bytesRead); FileTransfer.Status status = transfer.getStatus(); if (status == FileTransfer.Status.ERROR || status == FileTransfer.Status.COMPLETE || status == FileTransfer.Status.CANCLED || status == FileTransfer.Status.REFUSED) { break; } else if (status == FileTransfer.Status.NEGOTIATING_STREAM) { titleLabel.setText("Negotiating connection stream. Please wait..."); } else if (status == FileTransfer.Status.IN_PROGRESS) { titleLabel.setText("You are receiving a file from " + contactItem.getNickname()); } } return "ok"; } |
imageLabel.setToolTipText("Click to open"); titleLabel.setToolTipText("Click to open"); | imageLabel.setToolTipText(Res.getString("message.click.to.open")); titleLabel.setToolTipText(Res.getString("message.click.to.open")); | public void finished() { if (transfer.getAmountWritten() >= request.getFileSize()) { transferDone(request, transfer); imageLabel.setToolTipText("Click to open"); titleLabel.setToolTipText("Click to open"); imageLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); imageLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); invalidate(); validate(); repaint(); return; } String transferMessage = ""; if (transfer.getStatus() == FileTransfer.Status.ERROR) { if (transfer.getException() != null) { Log.error("There was an error during file transfer.", transfer.getException()); } transferMessage = "There was an error during file transfer."; } else if (transfer.getStatus() == FileTransfer.Status.REFUSED) { transferMessage = "The file transfer was refused."; } else if (transfer.getStatus() == FileTransfer.Status.CANCLED || transfer.getAmountWritten() < request.getFileSize()) { transferMessage = "The file transfer was cancelled."; } setFinishedText(transferMessage); showAlert(true); } |
if (transfer.getStatus() == FileTransfer.Status.ERROR) { | if (transfer.getStatus() == FileTransfer.Status.error) { | public void finished() { if (transfer.getAmountWritten() >= request.getFileSize()) { transferDone(request, transfer); imageLabel.setToolTipText("Click to open"); titleLabel.setToolTipText("Click to open"); imageLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); imageLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); invalidate(); validate(); repaint(); return; } String transferMessage = ""; if (transfer.getStatus() == FileTransfer.Status.ERROR) { if (transfer.getException() != null) { Log.error("There was an error during file transfer.", transfer.getException()); } transferMessage = "There was an error during file transfer."; } else if (transfer.getStatus() == FileTransfer.Status.REFUSED) { transferMessage = "The file transfer was refused."; } else if (transfer.getStatus() == FileTransfer.Status.CANCLED || transfer.getAmountWritten() < request.getFileSize()) { transferMessage = "The file transfer was cancelled."; } setFinishedText(transferMessage); showAlert(true); } |
transferMessage = "There was an error during file transfer."; | transferMessage = Res.getString("message.error.during.file.transfer"); | public void finished() { if (transfer.getAmountWritten() >= request.getFileSize()) { transferDone(request, transfer); imageLabel.setToolTipText("Click to open"); titleLabel.setToolTipText("Click to open"); imageLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); imageLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); invalidate(); validate(); repaint(); return; } String transferMessage = ""; if (transfer.getStatus() == FileTransfer.Status.ERROR) { if (transfer.getException() != null) { Log.error("There was an error during file transfer.", transfer.getException()); } transferMessage = "There was an error during file transfer."; } else if (transfer.getStatus() == FileTransfer.Status.REFUSED) { transferMessage = "The file transfer was refused."; } else if (transfer.getStatus() == FileTransfer.Status.CANCLED || transfer.getAmountWritten() < request.getFileSize()) { transferMessage = "The file transfer was cancelled."; } setFinishedText(transferMessage); showAlert(true); } |
else if (transfer.getStatus() == FileTransfer.Status.REFUSED) { transferMessage = "The file transfer was refused."; | else if (transfer.getStatus() == FileTransfer.Status.refused) { transferMessage = Res.getString("message.transfer.refused"); | public void finished() { if (transfer.getAmountWritten() >= request.getFileSize()) { transferDone(request, transfer); imageLabel.setToolTipText("Click to open"); titleLabel.setToolTipText("Click to open"); imageLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); imageLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); invalidate(); validate(); repaint(); return; } String transferMessage = ""; if (transfer.getStatus() == FileTransfer.Status.ERROR) { if (transfer.getException() != null) { Log.error("There was an error during file transfer.", transfer.getException()); } transferMessage = "There was an error during file transfer."; } else if (transfer.getStatus() == FileTransfer.Status.REFUSED) { transferMessage = "The file transfer was refused."; } else if (transfer.getStatus() == FileTransfer.Status.CANCLED || transfer.getAmountWritten() < request.getFileSize()) { transferMessage = "The file transfer was cancelled."; } setFinishedText(transferMessage); showAlert(true); } |
else if (transfer.getStatus() == FileTransfer.Status.CANCLED || | else if (transfer.getStatus() == FileTransfer.Status.cancelled || | public void finished() { if (transfer.getAmountWritten() >= request.getFileSize()) { transferDone(request, transfer); imageLabel.setToolTipText("Click to open"); titleLabel.setToolTipText("Click to open"); imageLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); imageLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); invalidate(); validate(); repaint(); return; } String transferMessage = ""; if (transfer.getStatus() == FileTransfer.Status.ERROR) { if (transfer.getException() != null) { Log.error("There was an error during file transfer.", transfer.getException()); } transferMessage = "There was an error during file transfer."; } else if (transfer.getStatus() == FileTransfer.Status.REFUSED) { transferMessage = "The file transfer was refused."; } else if (transfer.getStatus() == FileTransfer.Status.CANCLED || transfer.getAmountWritten() < request.getFileSize()) { transferMessage = "The file transfer was cancelled."; } setFinishedText(transferMessage); showAlert(true); } |
transferMessage = "The file transfer was cancelled."; | transferMessage = Res.getString("message.transfer.cancelled"); | public void finished() { if (transfer.getAmountWritten() >= request.getFileSize()) { transferDone(request, transfer); imageLabel.setToolTipText("Click to open"); titleLabel.setToolTipText("Click to open"); imageLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); imageLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { imageLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { openFile(downloadedFile); } } }); titleLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { titleLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); invalidate(); validate(); repaint(); return; } String transferMessage = ""; if (transfer.getStatus() == FileTransfer.Status.ERROR) { if (transfer.getException() != null) { Log.error("There was an error during file transfer.", transfer.getException()); } transferMessage = "There was an error during file transfer."; } else if (transfer.getStatus() == FileTransfer.Status.REFUSED) { transferMessage = "The file transfer was refused."; } else if (transfer.getStatus() == FileTransfer.Status.CANCLED || transfer.getAmountWritten() < request.getFileSize()) { transferMessage = "The file transfer was cancelled."; } setFinishedText(transferMessage); showAlert(true); } |
ResourceUtils.resButton(cancelButton, "Cancel"); | ResourceUtils.resButton(cancelButton, Res.getString("cancel")); | private void decorateCancelButton() { cancelButton.setVisible(false); ResourceUtils.resButton(cancelButton, "Cancel"); cancelButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(73, 113, 196))); cancelButton.setForeground(new Color(73, 113, 196)); cancelButton.setFont(new Font("Verdana", Font.BOLD, 10)); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { cancelTransfer(); } }); 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)); } }); } |
cancelButton.setFont(new Font("Verdana", Font.BOLD, 10)); | cancelButton.setFont(new Font("Dialog", Font.BOLD, 10)); | private void decorateCancelButton() { cancelButton.setVisible(false); ResourceUtils.resButton(cancelButton, "Cancel"); cancelButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(73, 113, 196))); cancelButton.setForeground(new Color(73, 113, 196)); cancelButton.setFont(new Font("Verdana", Font.BOLD, 10)); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { cancelTransfer(); } }); 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)); } }); } |
titleLabel.setText("You have cancelled the file transfer."); | titleLabel.setText(Res.getString("message.file.transfer.canceled")); | private void rejectRequest(FileTransferRequest request) { request.reject(); setBackground(new Color(239, 245, 250)); acceptLabel.setText(""); declineLabel.setText(""); fileLabel.setText(""); titleLabel.setText("You have cancelled the file transfer."); titleLabel.setForeground(new Color(65, 139, 179)); invalidate(); validate(); repaint(); } |
int confirm = JOptionPane.showConfirmDialog(ui, "The file already exists. Overwrite?", "File Exists", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); | int confirm = JOptionPane.showConfirmDialog(ui, Res.getString("message.file.exists.question"), Res.getString("title.file.exists"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); | private void showPopup(MouseEvent e, final File downloadedFile) { if (e.isPopupTrigger()) { final JPopupMenu popup = new JPopupMenu(); final ReceiveMessage ui = this; Action saveAsAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { final JFileChooser chooser = Downloads.getInstance().getFileChooser(); File selectedFile = chooser.getSelectedFile(); if (selectedFile != null) { selectedFile = new File(selectedFile.getParent(), downloadedFile.getName()); } else { selectedFile = downloadedFile; } chooser.setSelectedFile(selectedFile); int ok = chooser.showSaveDialog(ui); if (ok == JFileChooser.APPROVE_OPTION) { File file = chooser.getSelectedFile(); try { if (file.exists()) { int confirm = JOptionPane.showConfirmDialog(ui, "The file already exists. Overwrite?", "File Exists", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (confirm == JOptionPane.NO_OPTION) { return; } } URLFileSystem.copy(downloadedFile.toURL(), file); } catch (IOException e1) { Log.error(e1); } } } }; saveAsAction.putValue(Action.NAME, "Save As..."); popup.add(saveAsAction); popup.show(this, e.getX(), e.getY()); } } |
saveAsAction.putValue(Action.NAME, "Save As..."); | saveAsAction.putValue(Action.NAME, Res.getString("menuitem.save.as")); | private void showPopup(MouseEvent e, final File downloadedFile) { if (e.isPopupTrigger()) { final JPopupMenu popup = new JPopupMenu(); final ReceiveMessage ui = this; Action saveAsAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { final JFileChooser chooser = Downloads.getInstance().getFileChooser(); File selectedFile = chooser.getSelectedFile(); if (selectedFile != null) { selectedFile = new File(selectedFile.getParent(), downloadedFile.getName()); } else { selectedFile = downloadedFile; } chooser.setSelectedFile(selectedFile); int ok = chooser.showSaveDialog(ui); if (ok == JFileChooser.APPROVE_OPTION) { File file = chooser.getSelectedFile(); try { if (file.exists()) { int confirm = JOptionPane.showConfirmDialog(ui, "The file already exists. Overwrite?", "File Exists", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (confirm == JOptionPane.NO_OPTION) { return; } } URLFileSystem.copy(downloadedFile.toURL(), file); } catch (IOException e1) { Log.error(e1); } } } }; saveAsAction.putValue(Action.NAME, "Save As..."); popup.add(saveAsAction); popup.show(this, e.getX(), e.getY()); } } |
int confirm = JOptionPane.showConfirmDialog(ui, "The file already exists. Overwrite?", "File Exists", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); | int confirm = JOptionPane.showConfirmDialog(ui, Res.getString("message.file.exists.question"), Res.getString("title.file.exists"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); | public void actionPerformed(ActionEvent e) { final JFileChooser chooser = Downloads.getInstance().getFileChooser(); File selectedFile = chooser.getSelectedFile(); if (selectedFile != null) { selectedFile = new File(selectedFile.getParent(), downloadedFile.getName()); } else { selectedFile = downloadedFile; } chooser.setSelectedFile(selectedFile); int ok = chooser.showSaveDialog(ui); if (ok == JFileChooser.APPROVE_OPTION) { File file = chooser.getSelectedFile(); try { if (file.exists()) { int confirm = JOptionPane.showConfirmDialog(ui, "The file already exists. Overwrite?", "File Exists", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (confirm == JOptionPane.NO_OPTION) { return; } } URLFileSystem.copy(downloadedFile.toURL(), file); } catch (IOException e1) { Log.error(e1); } } } |
titleLabel.setText("You have received a file from " + contactItem.getNickname() + "."); | titleLabel.setText(Res.getString("message.received.file", contactItem.getNickname())); | private void transferDone(final FileTransferRequest request, FileTransfer transfer) { cancelButton.setVisible(false); showAlert(true); String bareJID = StringUtils.parseBareAddress(request.getRequestor()); ContactList contactList = SparkManager.getWorkspace().getContactList(); ContactItem contactItem = contactList.getContactItemByJID(bareJID); titleLabel.setText("You have received a file from " + contactItem.getNickname() + "."); fileLabel.setText(request.getFileName()); remove(acceptLabel); remove(declineLabel); remove(progressBar); final TransferButton openFileButton = new TransferButton(); final TransferButton openFolderButton = new TransferButton(); add(openFileButton, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); add(openFolderButton, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); Downloads downloads = Downloads.getInstance(); final File downloadedFile = new File(downloads.getDownloadDirectory(), request.getFileName()); openFileButton.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { openFileButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { openFileButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); openFolderButton.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { openFolderButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { openFolderButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); add(fileLabel, new GridBagConstraints(1, 1, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); ResourceUtils.resButton(openFileButton, "Open"); ResourceUtils.resButton(openFolderButton, "Open Folder"); openFileButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(73, 113, 196))); openFileButton.setForeground(new Color(73, 113, 196)); openFileButton.setFont(new Font("Verdana", Font.BOLD, 10)); openFolderButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(73, 113, 196))); openFolderButton.setForeground(new Color(73, 113, 196)); openFolderButton.setFont(new Font("Verdana", Font.BOLD, 10)); imageLabel.setIcon(GraphicUtils.getIcon(downloadedFile)); imageLabel.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { showPopup(e, downloadedFile); } public void mouseReleased(MouseEvent e) { showPopup(e, downloadedFile); } }); openFileButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { openFile(downloadedFile); } }); openFolderButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { try { Downloads downloads = Downloads.getInstance(); if (!Spark.isMac()) { try { Desktop.open(downloads.getDownloadDirectory()); } catch (DesktopException e) { Log.error(e); } } else if (Spark.isMac()) { Runtime.getRuntime().exec("open " + downloads.getDownloadDirectory().getCanonicalPath()); } } catch (IOException e1) { Log.error(e1); } } }); if (isImage(downloadedFile.getName())) { try { URL imageURL = downloadedFile.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)); } } invalidate(); validate(); repaint(); } |
ResourceUtils.resButton(openFileButton, "Open"); ResourceUtils.resButton(openFolderButton, "Open Folder"); | ResourceUtils.resButton(openFileButton, Res.getString("open")); ResourceUtils.resButton(openFolderButton, Res.getString("open.folder")); | private void transferDone(final FileTransferRequest request, FileTransfer transfer) { cancelButton.setVisible(false); showAlert(true); String bareJID = StringUtils.parseBareAddress(request.getRequestor()); ContactList contactList = SparkManager.getWorkspace().getContactList(); ContactItem contactItem = contactList.getContactItemByJID(bareJID); titleLabel.setText("You have received a file from " + contactItem.getNickname() + "."); fileLabel.setText(request.getFileName()); remove(acceptLabel); remove(declineLabel); remove(progressBar); final TransferButton openFileButton = new TransferButton(); final TransferButton openFolderButton = new TransferButton(); add(openFileButton, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); add(openFolderButton, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); Downloads downloads = Downloads.getInstance(); final File downloadedFile = new File(downloads.getDownloadDirectory(), request.getFileName()); openFileButton.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { openFileButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { openFileButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); openFolderButton.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { openFolderButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { openFolderButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); add(fileLabel, new GridBagConstraints(1, 1, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); ResourceUtils.resButton(openFileButton, "Open"); ResourceUtils.resButton(openFolderButton, "Open Folder"); openFileButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(73, 113, 196))); openFileButton.setForeground(new Color(73, 113, 196)); openFileButton.setFont(new Font("Verdana", Font.BOLD, 10)); openFolderButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(73, 113, 196))); openFolderButton.setForeground(new Color(73, 113, 196)); openFolderButton.setFont(new Font("Verdana", Font.BOLD, 10)); imageLabel.setIcon(GraphicUtils.getIcon(downloadedFile)); imageLabel.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { showPopup(e, downloadedFile); } public void mouseReleased(MouseEvent e) { showPopup(e, downloadedFile); } }); openFileButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { openFile(downloadedFile); } }); openFolderButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { try { Downloads downloads = Downloads.getInstance(); if (!Spark.isMac()) { try { Desktop.open(downloads.getDownloadDirectory()); } catch (DesktopException e) { Log.error(e); } } else if (Spark.isMac()) { Runtime.getRuntime().exec("open " + downloads.getDownloadDirectory().getCanonicalPath()); } } catch (IOException e1) { Log.error(e1); } } }); if (isImage(downloadedFile.getName())) { try { URL imageURL = downloadedFile.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)); } } invalidate(); validate(); repaint(); } |
openFileButton.setFont(new Font("Verdana", Font.BOLD, 10)); | openFileButton.setFont(new Font("Dialog", Font.BOLD, 10)); | private void transferDone(final FileTransferRequest request, FileTransfer transfer) { cancelButton.setVisible(false); showAlert(true); String bareJID = StringUtils.parseBareAddress(request.getRequestor()); ContactList contactList = SparkManager.getWorkspace().getContactList(); ContactItem contactItem = contactList.getContactItemByJID(bareJID); titleLabel.setText("You have received a file from " + contactItem.getNickname() + "."); fileLabel.setText(request.getFileName()); remove(acceptLabel); remove(declineLabel); remove(progressBar); final TransferButton openFileButton = new TransferButton(); final TransferButton openFolderButton = new TransferButton(); add(openFileButton, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); add(openFolderButton, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); Downloads downloads = Downloads.getInstance(); final File downloadedFile = new File(downloads.getDownloadDirectory(), request.getFileName()); openFileButton.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { openFileButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { openFileButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); openFolderButton.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { openFolderButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { openFolderButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); add(fileLabel, new GridBagConstraints(1, 1, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); ResourceUtils.resButton(openFileButton, "Open"); ResourceUtils.resButton(openFolderButton, "Open Folder"); openFileButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(73, 113, 196))); openFileButton.setForeground(new Color(73, 113, 196)); openFileButton.setFont(new Font("Verdana", Font.BOLD, 10)); openFolderButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(73, 113, 196))); openFolderButton.setForeground(new Color(73, 113, 196)); openFolderButton.setFont(new Font("Verdana", Font.BOLD, 10)); imageLabel.setIcon(GraphicUtils.getIcon(downloadedFile)); imageLabel.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { showPopup(e, downloadedFile); } public void mouseReleased(MouseEvent e) { showPopup(e, downloadedFile); } }); openFileButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { openFile(downloadedFile); } }); openFolderButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { try { Downloads downloads = Downloads.getInstance(); if (!Spark.isMac()) { try { Desktop.open(downloads.getDownloadDirectory()); } catch (DesktopException e) { Log.error(e); } } else if (Spark.isMac()) { Runtime.getRuntime().exec("open " + downloads.getDownloadDirectory().getCanonicalPath()); } } catch (IOException e1) { Log.error(e1); } } }); if (isImage(downloadedFile.getName())) { try { URL imageURL = downloadedFile.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)); } } invalidate(); validate(); repaint(); } |
openFolderButton.setFont(new Font("Verdana", Font.BOLD, 10)); | openFolderButton.setFont(new Font("Dialog", Font.BOLD, 10)); | private void transferDone(final FileTransferRequest request, FileTransfer transfer) { cancelButton.setVisible(false); showAlert(true); String bareJID = StringUtils.parseBareAddress(request.getRequestor()); ContactList contactList = SparkManager.getWorkspace().getContactList(); ContactItem contactItem = contactList.getContactItemByJID(bareJID); titleLabel.setText("You have received a file from " + contactItem.getNickname() + "."); fileLabel.setText(request.getFileName()); remove(acceptLabel); remove(declineLabel); remove(progressBar); final TransferButton openFileButton = new TransferButton(); final TransferButton openFolderButton = new TransferButton(); add(openFileButton, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); add(openFolderButton, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); Downloads downloads = Downloads.getInstance(); final File downloadedFile = new File(downloads.getDownloadDirectory(), request.getFileName()); openFileButton.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { openFileButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { openFileButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); openFolderButton.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { openFolderButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { openFolderButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }); add(fileLabel, new GridBagConstraints(1, 1, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); ResourceUtils.resButton(openFileButton, "Open"); ResourceUtils.resButton(openFolderButton, "Open Folder"); openFileButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(73, 113, 196))); openFileButton.setForeground(new Color(73, 113, 196)); openFileButton.setFont(new Font("Verdana", Font.BOLD, 10)); openFolderButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(73, 113, 196))); openFolderButton.setForeground(new Color(73, 113, 196)); openFolderButton.setFont(new Font("Verdana", Font.BOLD, 10)); imageLabel.setIcon(GraphicUtils.getIcon(downloadedFile)); imageLabel.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { showPopup(e, downloadedFile); } public void mouseReleased(MouseEvent e) { showPopup(e, downloadedFile); } }); openFileButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { openFile(downloadedFile); } }); openFolderButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { try { Downloads downloads = Downloads.getInstance(); if (!Spark.isMac()) { try { Desktop.open(downloads.getDownloadDirectory()); } catch (DesktopException e) { Log.error(e); } } else if (Spark.isMac()) { Runtime.getRuntime().exec("open " + downloads.getDownloadDirectory().getCanonicalPath()); } } catch (IOException e1) { Log.error(e1); } } }); if (isImage(downloadedFile.getName())) { try { URL imageURL = downloadedFile.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)); } } invalidate(); validate(); repaint(); } |
if (nonHTMLsrc == null) return null; | public static final String escape (String nonHTMLsrc) { StringBuffer res = new StringBuffer(); int l = nonHTMLsrc.length(); int idx; char c; for (int i = 0; i < l; i++) { c = nonHTMLsrc.charAt(i); idx = entityMap.indexOf(c); if (idx == -1) { res.append(c); } else { res.append(quickEntities[idx]); } } return res.toString(); } |
|
final DelayInformation offlineInformation = (DelayInformation)message.getExtension("x", "jabber:x:delay"); if (offlineInformation != null || message.getError() != null) { return; } | public void processPacket(final Packet packet) { SwingUtilities.invokeLater(new Runnable() { public void run() { final Message message = (Message)packet; boolean broadcast = message.getProperty("broadcast") != null; if ((broadcast || (message.getType() == Message.Type.NORMAL) || message.getType() == Message.Type.HEADLINE) && message.getBody() != null) { showAlert((Message)packet); } else { String host = SparkManager.getSessionManager().getServerAddress(); String from = packet.getFrom() != null ? packet.getFrom() : ""; if (host.equalsIgnoreCase(from) || !ModelUtil.hasLength(from)) { showAlert((Message)packet); } } } }); } |
|
final DelayInformation offlineInformation = (DelayInformation)message.getExtension("x", "jabber:x:delay"); if (offlineInformation != null || message.getError() != null) { return; } | public void run() { final Message message = (Message)packet; boolean broadcast = message.getProperty("broadcast") != null; if ((broadcast || (message.getType() == Message.Type.NORMAL) || message.getType() == Message.Type.HEADLINE) && message.getBody() != null) { showAlert((Message)packet); } else { String host = SparkManager.getSessionManager().getServerAddress(); String from = packet.getFrom() != null ? packet.getFrom() : ""; if (host.equalsIgnoreCase(from) || !ModelUtil.hasLength(from)) { showAlert((Message)packet); } } } |
|
public Object get(int i){ if ((i<1) || (i>fields.size())){ return _tbl.formatError("Invalid index: " + i + ". The column index must be between 1 and " + fields.size()); | public Object get(Object key){ Object o = super.get((_tbl.isCaseSensitive()) ? key : key.toString().toUpperCase()); if ((o == null) && (!fields.contains(key))){ return _tbl.formatError( key + " is not a column of this table!"); | public Object get(int i){ if ((i<1) || (i>fields.size())){ return _tbl.formatError("Invalid index: " + i + ". The column index must be between 1 and " + fields.size()); } return fields.getEntry(i-1); } |
return fields.getEntry(i-1); | return o; | public Object get(int i){ if ((i<1) || (i>fields.size())){ return _tbl.formatError("Invalid index: " + i + ". The column index must be between 1 and " + fields.size()); } return fields.getEntry(i-1); } |
Enumeration enum = elements(); | Enumeration enumeration = elements(); | final public Object build (BuildContext bc) throws BuildException { StringBuffer str = new StringBuffer(100); QuotedString qs = new QuotedString(); Enumeration enum = elements(); while (enum.hasMoreElements()) { Object txt = enum.nextElement(); if (txt instanceof Builder) { txt = ((Builder) txt).build(bc); } if (txt instanceof String) { str.append(txt); } else { qs.addElement(str.toString()); qs.addElement(txt); str.setLength(0); } } |
while (enum.hasMoreElements()) | while (enumeration.hasMoreElements()) | final public Object build (BuildContext bc) throws BuildException { StringBuffer str = new StringBuffer(100); QuotedString qs = new QuotedString(); Enumeration enum = elements(); while (enum.hasMoreElements()) { Object txt = enum.nextElement(); if (txt instanceof Builder) { txt = ((Builder) txt).build(bc); } if (txt instanceof String) { str.append(txt); } else { qs.addElement(str.toString()); qs.addElement(txt); str.setLength(0); } } |
Object txt = enum.nextElement(); | Object txt = enumeration.nextElement(); | final public Object build (BuildContext bc) throws BuildException { StringBuffer str = new StringBuffer(100); QuotedString qs = new QuotedString(); Enumeration enum = elements(); while (enum.hasMoreElements()) { Object txt = enum.nextElement(); if (txt instanceof Builder) { txt = ((Builder) txt).build(bc); } if (txt instanceof String) { str.append(txt); } else { qs.addElement(str.toString()); qs.addElement(txt); str.setLength(0); } } |
if (str.length() > 0) { qs.addElement(str.toString()); } if (qs.size() == 1) { return qs.elementAt(0); } else { return qs; } } | final public Object build (BuildContext bc) throws BuildException { StringBuffer str = new StringBuffer(100); QuotedString qs = new QuotedString(); Enumeration enum = elements(); while (enum.hasMoreElements()) { Object txt = enum.nextElement(); if (txt instanceof Builder) { txt = ((Builder) txt).build(bc); } if (txt instanceof String) { str.append(txt); } else { qs.addElement(str.toString()); qs.addElement(txt); str.setLength(0); } } |
|
true); | false); | public void invoke(JFrame parentFrame, PreferencesPanel contentPane) { this.prefPanel = contentPane; // Construct main panel w/ layout. final JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); // Construct Dialog preferenceDialog = new JDialog(parentFrame, "Preferences", true); Object[] options = {"Close"}; pane = new JOptionPane(contentPane, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options, options[0]); mainPanel.add(pane, BorderLayout.CENTER); preferenceDialog.pack(); preferenceDialog.setSize(600, 500); preferenceDialog.setContentPane(mainPanel); preferenceDialog.setLocationRelativeTo(SparkManager.getMainWindow()); pane.addPropertyChangeListener(this); preferenceDialog.setVisible(true); } |
throw new IllegalArgumentException("Could not load property editor: "+propertyEditor, e); | throw (IllegalArgumentException)new IllegalArgumentException("Could not load property editor: "+propertyEditor).initCause(e); | protected PropertyEditor createPropertyEditor(String propertyEditor) { ClassLoader cl = Thread.currentThread().getContextClassLoader(); if( cl==null ) { cl = XBeanNamespaceHandler.class.getClassLoader(); } try { return (PropertyEditor)cl.loadClass(propertyEditor).newInstance(); } catch (Throwable e){ throw new IllegalArgumentException("Could not load property editor: "+propertyEditor, e); } } |
else if (haltOnFailure) throw new BuildException( "Coverage check failed. See messages above."); | } | public void execute() throws BuildException { if (dataFile != null) { getJava().createArg().setValue("--datafile"); getJava().createArg().setValue(dataFile); } if (branchRate != null) { getJava().createArg().setValue("--branch"); getJava().createArg().setValue(branchRate); } if (lineRate != null) { getJava().createArg().setValue("--line"); getJava().createArg().setValue(lineRate); } if (totalBranchRate != null) { getJava().createArg().setValue("--totalbranch"); getJava().createArg().setValue(totalBranchRate); } if (totalLineRate != null) { getJava().createArg().setValue("--totalline"); getJava().createArg().setValue(totalLineRate); } Iterator iter = regexes.iterator(); while (iter.hasNext()) { getJava().createArg().setValue("--regex"); getJava().createArg().setValue(iter.next().toString()); } int returnCode = getJava().executeJava(); // Check the return code and print a message if (returnCode == 0) System.out.println("All checks passed."); else if (haltOnFailure) throw new BuildException( "Coverage check failed. See messages above."); else System.err.println("Coverage check failed. See messages above."); } |
System.err.println("Coverage check failed. See messages above."); | { if (haltOnFailure) throw new BuildException( "Coverage check failed. See messages above."); else if (failureProperty != null) getProject().setProperty(failureProperty, "true"); else System.err .println("Coverage check failed. See messages above."); } | public void execute() throws BuildException { if (dataFile != null) { getJava().createArg().setValue("--datafile"); getJava().createArg().setValue(dataFile); } if (branchRate != null) { getJava().createArg().setValue("--branch"); getJava().createArg().setValue(branchRate); } if (lineRate != null) { getJava().createArg().setValue("--line"); getJava().createArg().setValue(lineRate); } if (totalBranchRate != null) { getJava().createArg().setValue("--totalbranch"); getJava().createArg().setValue(totalBranchRate); } if (totalLineRate != null) { getJava().createArg().setValue("--totalline"); getJava().createArg().setValue(totalLineRate); } Iterator iter = regexes.iterator(); while (iter.hasNext()) { getJava().createArg().setValue("--regex"); getJava().createArg().setValue(iter.next().toString()); } int returnCode = getJava().executeJava(); // Check the return code and print a message if (returnCode == 0) System.out.println("All checks passed."); else if (haltOnFailure) throw new BuildException( "Coverage check failed. See messages above."); else System.err.println("Coverage check failed. See messages above."); } |
return context.getProperty(_names[0]); | return context.getProperty(_names); | public Object getValue (Context context) throws PropertyException { return context.getProperty(_names[0]); } |
if (pref.isHideChatHistory()) { | if (!pref.isChatHistoryEnabled()) { | public void chatRoomOpened(final ChatRoom room) { LocalPreferences pref = SettingsManager.getLocalPreferences(); if (pref.isHideChatHistory()) { return; } final String jid = room.getRoomname(); File transcriptFile = ChatTranscripts.getTranscriptFile(jid); if (!transcriptFile.exists()) { return; } final TranscriptWindow roomWindow = room.getTranscriptWindow(); final TranscriptWindow window = new TranscriptWindow(); window.setEditable(false); window.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { room.getChatInputEditor().requestFocusInWindow(); } }); insertHistory(room, roomWindow); if (room instanceof ChatRoomImpl) { // Add History Button ChatRoomButton chatRoomButton = new ChatRoomButton(SparkRes.getImageIcon(SparkRes.HISTORY_24x24_IMAGE)); room.getToolBar().addChatRoomButton(chatRoomButton); chatRoomButton.setToolTipText("View history"); chatRoomButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { ChatRoomImpl roomImpl = (ChatRoomImpl)room; showHistory(roomImpl.getParticipantJID()); } }); } } |
if (pref.isHideChatHistory()) { | if (!pref.isChatHistoryEnabled()) { | private void persistChatRoom(final ChatRoom room) { LocalPreferences pref = SettingsManager.getLocalPreferences(); if (pref.isHideChatHistory()) { return; } final String jid = room.getRoomname(); List transcripts = room.getTranscripts(); Iterator messages = transcripts.iterator(); ChatTranscript transcript = ChatTranscripts.getChatTranscript(jid); while (messages.hasNext()) { Message message = (Message)messages.next(); HistoryMessage history = new HistoryMessage(); history.setTo(message.getTo()); history.setFrom(message.getFrom()); history.setBody(message.getBody()); Date date = (Date)message.getProperty("date"); if (date != null) { history.setDate(date); } else { history.setDate(new Date()); } transcript.addHistoryMessage(history); } ChatTranscripts.saveTranscript(jid); } |
return ChatTranscripts.getChatTranscript(jid); | String bareJID = StringUtils.parseBareAddress(jid); return ChatTranscripts.getChatTranscript(bareJID); | private void showHistory(final String jid) { SwingWorker transcriptLoader = new SwingWorker() { public Object construct() { return ChatTranscripts.getChatTranscript(jid); } public void finished() { final JPanel mainPanel = new BackgroundPanel(); mainPanel.setLayout(new BorderLayout()); final VCardPanel topPanel = new VCardPanel(jid); mainPanel.add(topPanel, BorderLayout.NORTH); final TranscriptWindow window = new TranscriptWindow(); final JScrollPane pane = new JScrollPane(window); pane.getVerticalScrollBar().setBlockIncrement(50); pane.getVerticalScrollBar().setUnitIncrement(20); mainPanel.add(pane, BorderLayout.CENTER); ChatTranscript transcript = (ChatTranscript)get(); List<HistoryMessage> list = transcript.getMessages(); Collections.sort(list, dateComparator); for (HistoryMessage message : list) { String from = message.getFrom(); String nickname = StringUtils.parseName(from); final SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy h:mm a"); final String date = formatter.format(message.getDate()); String prefix = nickname + " [" + date + "]"; if (from.equals(SparkManager.getSessionManager().getJID())) { window.insertCustomMessage(prefix, message.getBody()); } else { window.insertCustomOtherMessage(prefix, message.getBody()); } } // Handle no history if (transcript.getMessages().size() == 0) { window.setText("There is no current chat history."); } final JFrame frame = new JFrame("History For " + jid); frame.setIconImage(SparkRes.getImageIcon(SparkRes.HISTORY_16x16).getImage()); frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(mainPanel, BorderLayout.CENTER); frame.pack(); frame.setSize(600, 400); window.setCaretPosition(0); GraphicUtils.centerWindowOnScreen(frame); frame.setVisible(true); } }; transcriptLoader.start(); } |
Collections.sort(list, dateComparator); | private void showHistory(final String jid) { SwingWorker transcriptLoader = new SwingWorker() { public Object construct() { return ChatTranscripts.getChatTranscript(jid); } public void finished() { final JPanel mainPanel = new BackgroundPanel(); mainPanel.setLayout(new BorderLayout()); final VCardPanel topPanel = new VCardPanel(jid); mainPanel.add(topPanel, BorderLayout.NORTH); final TranscriptWindow window = new TranscriptWindow(); final JScrollPane pane = new JScrollPane(window); pane.getVerticalScrollBar().setBlockIncrement(50); pane.getVerticalScrollBar().setUnitIncrement(20); mainPanel.add(pane, BorderLayout.CENTER); ChatTranscript transcript = (ChatTranscript)get(); List<HistoryMessage> list = transcript.getMessages(); Collections.sort(list, dateComparator); for (HistoryMessage message : list) { String from = message.getFrom(); String nickname = StringUtils.parseName(from); final SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy h:mm a"); final String date = formatter.format(message.getDate()); String prefix = nickname + " [" + date + "]"; if (from.equals(SparkManager.getSessionManager().getJID())) { window.insertCustomMessage(prefix, message.getBody()); } else { window.insertCustomOtherMessage(prefix, message.getBody()); } } // Handle no history if (transcript.getMessages().size() == 0) { window.setText("There is no current chat history."); } final JFrame frame = new JFrame("History For " + jid); frame.setIconImage(SparkRes.getImageIcon(SparkRes.HISTORY_16x16).getImage()); frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(mainPanel, BorderLayout.CENTER); frame.pack(); frame.setSize(600, 400); window.setCaretPosition(0); GraphicUtils.centerWindowOnScreen(frame); frame.setVisible(true); } }; transcriptLoader.start(); } |
|
return ChatTranscripts.getChatTranscript(jid); | String bareJID = StringUtils.parseBareAddress(jid); return ChatTranscripts.getChatTranscript(bareJID); | public Object construct() { return ChatTranscripts.getChatTranscript(jid); } |
Collections.sort(list, dateComparator); | public void finished() { final JPanel mainPanel = new BackgroundPanel(); mainPanel.setLayout(new BorderLayout()); final VCardPanel topPanel = new VCardPanel(jid); mainPanel.add(topPanel, BorderLayout.NORTH); final TranscriptWindow window = new TranscriptWindow(); final JScrollPane pane = new JScrollPane(window); pane.getVerticalScrollBar().setBlockIncrement(50); pane.getVerticalScrollBar().setUnitIncrement(20); mainPanel.add(pane, BorderLayout.CENTER); ChatTranscript transcript = (ChatTranscript)get(); List<HistoryMessage> list = transcript.getMessages(); Collections.sort(list, dateComparator); for (HistoryMessage message : list) { String from = message.getFrom(); String nickname = StringUtils.parseName(from); final SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy h:mm a"); final String date = formatter.format(message.getDate()); String prefix = nickname + " [" + date + "]"; if (from.equals(SparkManager.getSessionManager().getJID())) { window.insertCustomMessage(prefix, message.getBody()); } else { window.insertCustomOtherMessage(prefix, message.getBody()); } } // Handle no history if (transcript.getMessages().size() == 0) { window.setText("There is no current chat history."); } final JFrame frame = new JFrame("History For " + jid); frame.setIconImage(SparkRes.getImageIcon(SparkRes.HISTORY_16x16).getImage()); frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(mainPanel, BorderLayout.CENTER); frame.pack(); frame.setSize(600, 400); window.setCaretPosition(0); GraphicUtils.centerWindowOnScreen(frame); frame.setVisible(true); } |
|
public ServiceEvent(long eventId, Kernel kernel, ServiceName serviceName, ServiceFactory serviceFactory, ClassLoader classLoader, Object service, Set unsatisfiedConditions) { | public ServiceEvent(long eventId, Kernel kernel, ServiceName serviceName, ServiceFactory serviceFactory, ClassLoader classLoader, Object service) { | public ServiceEvent(long eventId, Kernel kernel, ServiceName serviceName, ServiceFactory serviceFactory, ClassLoader classLoader, Object service, Set unsatisfiedConditions) { this.eventId = eventId; this.kernel = kernel; this.serviceName = serviceName; this.serviceFactory = serviceFactory; this.classLoader = classLoader; this.service = service; this.unsatisfiedConditions = unsatisfiedConditions; cause = null; } |
this.unsatisfiedConditions = unsatisfiedConditions; | public ServiceEvent(long eventId, Kernel kernel, ServiceName serviceName, ServiceFactory serviceFactory, ClassLoader classLoader, Object service, Set unsatisfiedConditions) { this.eventId = eventId; this.kernel = kernel; this.serviceName = serviceName; this.serviceFactory = serviceFactory; this.classLoader = classLoader; this.service = service; this.unsatisfiedConditions = unsatisfiedConditions; cause = null; } |
|
unsatisfiedConditions = null; | public ServiceEvent(long eventId, Kernel kernel, ServiceName serviceName, ServiceFactory serviceFactory, ClassLoader classLoader, Object service, Set unsatisfiedConditions) { this.eventId = eventId; this.kernel = kernel; this.serviceName = serviceName; this.serviceFactory = serviceFactory; this.classLoader = classLoader; this.service = service; this.unsatisfiedConditions = unsatisfiedConditions; cause = null; } |
|
double ccn = Util.getCCN(finder.findFile(packageData.getSourceFileName()), false); | double ccn = packageData.getCCN(finder); | private void dumpPackage(PackageData packageData) { logger.debug("Dumping package " + packageData.getName()); double ccn = Util.getCCN(finder.findFile(packageData.getSourceFileName()), false); println("<package name=\"" + packageData.getName() + "\" line-rate=\"" + packageData.getLineCoverageRate() + "\" branch-rate=\"" + packageData.getBranchCoverageRate() + "\" complexity=\"" + ccn + "\"" + ">"); increaseIndentation(); dumpSourceFiles(packageData); decreaseIndentation(); println("</package>"); } |
public ArticleBlock(String titleKey, WFTabListener taskbarListener) { super(titleKey); setId(ARTICLE_BLOCK_ID); getTitlebar().setValueRefTitle(true); setMainAreaStyleClass(null); String bref = WFPage.CONTENT_BUNDLE + "."; WFTabBar tb = new WFTabBar(); tb.setId(TASKBAR_ID); add(tb); tb.addButtonVB(TASK_ID_EDIT, bref + "edit", getEditContainer()); tb.addButtonVB(TASK_ID_PREVIEW, bref + "preview", getPreviewContainer()); tb.setSelectedButtonId(TASK_ID_EDIT); if (taskbarListener != null) { tb.addTaskbarListener(taskbarListener); } | public ArticleBlock() { | public ArticleBlock(String titleKey, WFTabListener taskbarListener) { super(titleKey); setId(ARTICLE_BLOCK_ID); getTitlebar().setValueRefTitle(true); setMainAreaStyleClass(null); String bref = WFPage.CONTENT_BUNDLE + "."; WFTabBar tb = new WFTabBar(); tb.setId(TASKBAR_ID); add(tb); tb.addButtonVB(TASK_ID_EDIT, bref + "edit", getEditContainer()); tb.addButtonVB(TASK_ID_PREVIEW, bref + "preview", getPreviewContainer());// tb.addButtonVB(TASK_ID_MESSAGES, bref + "messages", getMessageContainer()); tb.setSelectedButtonId(TASK_ID_EDIT); if (taskbarListener != null) { tb.addTaskbarListener(taskbarListener); } } |
interfaces.addAll( getFullyQulifiedNames( javaClass.getImplementedInterfaces() ) ); | interfaces.addAll( getFullyQualifiedNames( javaClass.getImplementedInterfaces() ) ); | private ElementMapping loadElement(JavaClass javaClass) { DocletTag xbeanTag = javaClass.getTagByName(XBEAN_ANNOTATION); if (xbeanTag == null) { return null; } String element = getElementName(javaClass, xbeanTag); String description = getProperty(xbeanTag, "description"); if (description == null) { description = javaClass.getComment(); } String namespace = getProperty(xbeanTag, "namespace", defaultNamespace); boolean root = getBooleanProperty(xbeanTag, "rootElement"); String contentProperty = getProperty(xbeanTag, "contentProperty"); Map mapsByPropertyName = new HashMap(); List flatProperties = new ArrayList(); Map flatCollections = new HashMap(); Set attributes = new HashSet(); Map attributesByPropertyName = new HashMap(); for (JavaClass jClass = javaClass; jClass != null; jClass = jClass.getSuperJavaClass()) { BeanProperty[] beanProperties = jClass.getBeanProperties(); for (int i = 0; i < beanProperties.length; i++) { BeanProperty beanProperty = beanProperties[i]; // we only care about properties with a setter if (beanProperty.getMutator() != null) { AttributeMapping attributeMapping = loadAttribute(beanProperty, ""); if (attributeMapping != null) { attributes.add(attributeMapping); attributesByPropertyName.put(attributeMapping.getPropertyName(), attributeMapping); } JavaMethod acc = beanProperty.getAccessor(); if (acc != null) { DocletTag mapTag = acc.getTagByName(MAP_ANNOTATION); if (mapTag != null) { MapMapping mm = new MapMapping(mapTag.getNamedParameter("entryName"), mapTag.getNamedParameter("keyName")); mapsByPropertyName.put(beanProperty.getName(), mm); } DocletTag flatColTag = acc.getTagByName(FLAT_COLLECTION_ANNOTATION); if (flatColTag != null) { String childName = flatColTag.getNamedParameter("childElement"); if (childName == null) throw new InvalidModelException("Flat collections must specify the childElement attribute."); flatCollections.put(beanProperty.getName(), childName); } DocletTag flatPropTag = acc.getTagByName(FLAT_PROPERTY_ANNOTATION); if (flatPropTag != null) { flatProperties.add(beanProperty.getName()); } } } } } String initMethod = null; String destroyMethod = null; String factoryMethod = null; for (JavaClass jClass = javaClass; jClass != null; jClass = jClass.getSuperJavaClass()) { JavaMethod[] methods = javaClass.getMethods(); for (int i = 0; i < methods.length; i++) { JavaMethod method = methods[i]; if (method.isPublic() && !method.isConstructor()) { if (initMethod == null && method.getTagByName(INIT_METHOD_ANNOTATION) != null) { initMethod = method.getName(); } if (destroyMethod == null && method.getTagByName(DESTROY_METHOD_ANNOTATION) != null) { destroyMethod = method.getName(); } if (factoryMethod == null && method.getTagByName(FACTORY_METHOD_ANNOTATION) != null) { factoryMethod = method.getName(); } } } } List constructorArgs = new ArrayList(); JavaMethod[] methods = javaClass.getMethods(); for (int i = 0; i < methods.length; i++) { JavaMethod method = methods[i]; JavaParameter[] parameters = method.getParameters(); if (isValidConstructor(factoryMethod, method, parameters)) { List args = new ArrayList(parameters.length); for (int j = 0; j < parameters.length; j++) { JavaParameter parameter = parameters[j]; AttributeMapping attributeMapping = (AttributeMapping) attributesByPropertyName.get(parameter.getName()); if (attributeMapping == null) { attributeMapping = loadParameter(parameter); attributes.add(attributeMapping); attributesByPropertyName.put(attributeMapping.getPropertyName(), attributeMapping); } args.add(new ParameterMapping(attributeMapping.getPropertyName(), toMappingType(parameter.getType(), null))); } constructorArgs.add(Collections.unmodifiableList(args)); } } HashSet interfaces = new HashSet(); interfaces.addAll( getFullyQulifiedNames( javaClass.getImplementedInterfaces() ) ); System.out.println("Checking: "+javaClass.getFullyQualifiedName()); ArrayList superClasses = new ArrayList(); JavaClass p = javaClass; while( true ) { JavaClass s = javaClass.getSuperJavaClass(); if( s==null || s.equals(p) || "java.lang.Object".equals(s.getFullyQualifiedName()) ) { break; } p=s; superClasses.add(p.getFullyQualifiedName()); interfaces.addAll( getFullyQulifiedNames( p.getImplementedInterfaces() ) ); } return new ElementMapping(namespace, element, javaClass.getFullyQualifiedName(), description, root, initMethod, destroyMethod, factoryMethod, contentProperty, attributes, constructorArgs, flatProperties, mapsByPropertyName, flatCollections, superClasses, interfaces); } |
JavaClass s = javaClass.getSuperJavaClass(); if( s==null || s.equals(p) || "java.lang.Object".equals(s.getFullyQualifiedName()) ) { break; | JavaClass s = p.getSuperJavaClass(); if( s==null || s.equals(p) || "java.lang.Object".equals(s.getFullyQualifiedName()) ) { break; | private ElementMapping loadElement(JavaClass javaClass) { DocletTag xbeanTag = javaClass.getTagByName(XBEAN_ANNOTATION); if (xbeanTag == null) { return null; } String element = getElementName(javaClass, xbeanTag); String description = getProperty(xbeanTag, "description"); if (description == null) { description = javaClass.getComment(); } String namespace = getProperty(xbeanTag, "namespace", defaultNamespace); boolean root = getBooleanProperty(xbeanTag, "rootElement"); String contentProperty = getProperty(xbeanTag, "contentProperty"); Map mapsByPropertyName = new HashMap(); List flatProperties = new ArrayList(); Map flatCollections = new HashMap(); Set attributes = new HashSet(); Map attributesByPropertyName = new HashMap(); for (JavaClass jClass = javaClass; jClass != null; jClass = jClass.getSuperJavaClass()) { BeanProperty[] beanProperties = jClass.getBeanProperties(); for (int i = 0; i < beanProperties.length; i++) { BeanProperty beanProperty = beanProperties[i]; // we only care about properties with a setter if (beanProperty.getMutator() != null) { AttributeMapping attributeMapping = loadAttribute(beanProperty, ""); if (attributeMapping != null) { attributes.add(attributeMapping); attributesByPropertyName.put(attributeMapping.getPropertyName(), attributeMapping); } JavaMethod acc = beanProperty.getAccessor(); if (acc != null) { DocletTag mapTag = acc.getTagByName(MAP_ANNOTATION); if (mapTag != null) { MapMapping mm = new MapMapping(mapTag.getNamedParameter("entryName"), mapTag.getNamedParameter("keyName")); mapsByPropertyName.put(beanProperty.getName(), mm); } DocletTag flatColTag = acc.getTagByName(FLAT_COLLECTION_ANNOTATION); if (flatColTag != null) { String childName = flatColTag.getNamedParameter("childElement"); if (childName == null) throw new InvalidModelException("Flat collections must specify the childElement attribute."); flatCollections.put(beanProperty.getName(), childName); } DocletTag flatPropTag = acc.getTagByName(FLAT_PROPERTY_ANNOTATION); if (flatPropTag != null) { flatProperties.add(beanProperty.getName()); } } } } } String initMethod = null; String destroyMethod = null; String factoryMethod = null; for (JavaClass jClass = javaClass; jClass != null; jClass = jClass.getSuperJavaClass()) { JavaMethod[] methods = javaClass.getMethods(); for (int i = 0; i < methods.length; i++) { JavaMethod method = methods[i]; if (method.isPublic() && !method.isConstructor()) { if (initMethod == null && method.getTagByName(INIT_METHOD_ANNOTATION) != null) { initMethod = method.getName(); } if (destroyMethod == null && method.getTagByName(DESTROY_METHOD_ANNOTATION) != null) { destroyMethod = method.getName(); } if (factoryMethod == null && method.getTagByName(FACTORY_METHOD_ANNOTATION) != null) { factoryMethod = method.getName(); } } } } List constructorArgs = new ArrayList(); JavaMethod[] methods = javaClass.getMethods(); for (int i = 0; i < methods.length; i++) { JavaMethod method = methods[i]; JavaParameter[] parameters = method.getParameters(); if (isValidConstructor(factoryMethod, method, parameters)) { List args = new ArrayList(parameters.length); for (int j = 0; j < parameters.length; j++) { JavaParameter parameter = parameters[j]; AttributeMapping attributeMapping = (AttributeMapping) attributesByPropertyName.get(parameter.getName()); if (attributeMapping == null) { attributeMapping = loadParameter(parameter); attributes.add(attributeMapping); attributesByPropertyName.put(attributeMapping.getPropertyName(), attributeMapping); } args.add(new ParameterMapping(attributeMapping.getPropertyName(), toMappingType(parameter.getType(), null))); } constructorArgs.add(Collections.unmodifiableList(args)); } } HashSet interfaces = new HashSet(); interfaces.addAll( getFullyQulifiedNames( javaClass.getImplementedInterfaces() ) ); System.out.println("Checking: "+javaClass.getFullyQualifiedName()); ArrayList superClasses = new ArrayList(); JavaClass p = javaClass; while( true ) { JavaClass s = javaClass.getSuperJavaClass(); if( s==null || s.equals(p) || "java.lang.Object".equals(s.getFullyQualifiedName()) ) { break; } p=s; superClasses.add(p.getFullyQualifiedName()); interfaces.addAll( getFullyQulifiedNames( p.getImplementedInterfaces() ) ); } return new ElementMapping(namespace, element, javaClass.getFullyQualifiedName(), description, root, initMethod, destroyMethod, factoryMethod, contentProperty, attributes, constructorArgs, flatProperties, mapsByPropertyName, flatCollections, superClasses, interfaces); } |
p=s; superClasses.add(p.getFullyQualifiedName()); interfaces.addAll( getFullyQulifiedNames( p.getImplementedInterfaces() ) ); | p = s; superClasses.add(p.getFullyQualifiedName()); interfaces.addAll( getFullyQualifiedNames( p.getImplementedInterfaces() ) ); | private ElementMapping loadElement(JavaClass javaClass) { DocletTag xbeanTag = javaClass.getTagByName(XBEAN_ANNOTATION); if (xbeanTag == null) { return null; } String element = getElementName(javaClass, xbeanTag); String description = getProperty(xbeanTag, "description"); if (description == null) { description = javaClass.getComment(); } String namespace = getProperty(xbeanTag, "namespace", defaultNamespace); boolean root = getBooleanProperty(xbeanTag, "rootElement"); String contentProperty = getProperty(xbeanTag, "contentProperty"); Map mapsByPropertyName = new HashMap(); List flatProperties = new ArrayList(); Map flatCollections = new HashMap(); Set attributes = new HashSet(); Map attributesByPropertyName = new HashMap(); for (JavaClass jClass = javaClass; jClass != null; jClass = jClass.getSuperJavaClass()) { BeanProperty[] beanProperties = jClass.getBeanProperties(); for (int i = 0; i < beanProperties.length; i++) { BeanProperty beanProperty = beanProperties[i]; // we only care about properties with a setter if (beanProperty.getMutator() != null) { AttributeMapping attributeMapping = loadAttribute(beanProperty, ""); if (attributeMapping != null) { attributes.add(attributeMapping); attributesByPropertyName.put(attributeMapping.getPropertyName(), attributeMapping); } JavaMethod acc = beanProperty.getAccessor(); if (acc != null) { DocletTag mapTag = acc.getTagByName(MAP_ANNOTATION); if (mapTag != null) { MapMapping mm = new MapMapping(mapTag.getNamedParameter("entryName"), mapTag.getNamedParameter("keyName")); mapsByPropertyName.put(beanProperty.getName(), mm); } DocletTag flatColTag = acc.getTagByName(FLAT_COLLECTION_ANNOTATION); if (flatColTag != null) { String childName = flatColTag.getNamedParameter("childElement"); if (childName == null) throw new InvalidModelException("Flat collections must specify the childElement attribute."); flatCollections.put(beanProperty.getName(), childName); } DocletTag flatPropTag = acc.getTagByName(FLAT_PROPERTY_ANNOTATION); if (flatPropTag != null) { flatProperties.add(beanProperty.getName()); } } } } } String initMethod = null; String destroyMethod = null; String factoryMethod = null; for (JavaClass jClass = javaClass; jClass != null; jClass = jClass.getSuperJavaClass()) { JavaMethod[] methods = javaClass.getMethods(); for (int i = 0; i < methods.length; i++) { JavaMethod method = methods[i]; if (method.isPublic() && !method.isConstructor()) { if (initMethod == null && method.getTagByName(INIT_METHOD_ANNOTATION) != null) { initMethod = method.getName(); } if (destroyMethod == null && method.getTagByName(DESTROY_METHOD_ANNOTATION) != null) { destroyMethod = method.getName(); } if (factoryMethod == null && method.getTagByName(FACTORY_METHOD_ANNOTATION) != null) { factoryMethod = method.getName(); } } } } List constructorArgs = new ArrayList(); JavaMethod[] methods = javaClass.getMethods(); for (int i = 0; i < methods.length; i++) { JavaMethod method = methods[i]; JavaParameter[] parameters = method.getParameters(); if (isValidConstructor(factoryMethod, method, parameters)) { List args = new ArrayList(parameters.length); for (int j = 0; j < parameters.length; j++) { JavaParameter parameter = parameters[j]; AttributeMapping attributeMapping = (AttributeMapping) attributesByPropertyName.get(parameter.getName()); if (attributeMapping == null) { attributeMapping = loadParameter(parameter); attributes.add(attributeMapping); attributesByPropertyName.put(attributeMapping.getPropertyName(), attributeMapping); } args.add(new ParameterMapping(attributeMapping.getPropertyName(), toMappingType(parameter.getType(), null))); } constructorArgs.add(Collections.unmodifiableList(args)); } } HashSet interfaces = new HashSet(); interfaces.addAll( getFullyQulifiedNames( javaClass.getImplementedInterfaces() ) ); System.out.println("Checking: "+javaClass.getFullyQualifiedName()); ArrayList superClasses = new ArrayList(); JavaClass p = javaClass; while( true ) { JavaClass s = javaClass.getSuperJavaClass(); if( s==null || s.equals(p) || "java.lang.Object".equals(s.getFullyQualifiedName()) ) { break; } p=s; superClasses.add(p.getFullyQualifiedName()); interfaces.addAll( getFullyQulifiedNames( p.getImplementedInterfaces() ) ); } return new ElementMapping(namespace, element, javaClass.getFullyQualifiedName(), description, root, initMethod, destroyMethod, factoryMethod, contentProperty, attributes, constructorArgs, flatProperties, mapsByPropertyName, flatCollections, superClasses, interfaces); } |
String contentProperty, Set attributes, List constructors, List flatProperties, Map maps, Map flatCollections) { if (namespace == null) throw new NullPointerException("namespace"); | String contentProperty, Set attributes, List constructors, List flatProperties, Map maps, Map flatCollections, List superClasses, HashSet interfaces) { this.superClasses = superClasses; this.interfaces = interfaces; if (namespace == null) throw new NullPointerException("namespace"); | public ElementMapping(String namespace, String elementName, String className, String description, boolean rootElement, String initMethod, String destroyMethod, String factoryMethod, String contentProperty, Set attributes, List constructors, List flatProperties, Map maps, Map flatCollections) { if (namespace == null) throw new NullPointerException("namespace"); if (elementName == null) throw new NullPointerException("elementName"); if (className == null) throw new NullPointerException("className"); if (attributes == null) throw new NullPointerException("attributes"); if (constructors == null) throw new NullPointerException("constructors"); this.namespace = namespace; this.elementName = elementName; this.className = className; this.description = description; this.rootElement = rootElement; this.initMethod = initMethod; this.destroyMethod = destroyMethod; this.factoryMethod = factoryMethod; this.contentProperty = contentProperty; this.constructors = constructors; this.attributes = Collections.unmodifiableSet(new TreeSet(attributes)); this.maps = Collections.unmodifiableMap(maps); this.flatProperties = Collections.unmodifiableList(flatProperties); this.flatCollections = Collections.unmodifiableMap(flatCollections); Map attributesByName = new HashMap(); for (Iterator iterator = attributes.iterator(); iterator.hasNext();) { AttributeMapping attribute = (AttributeMapping) iterator.next(); attributesByName.put(attribute.getAttributeName(), attribute); } this.attributesByName = Collections.unmodifiableMap(attributesByName); } |
WebDAVCategories categoriesUI = (WebDAVCategories)findComponent(WebDAVCategories.CATEGORIES_BLOCK_ID); | WebDAVCategories categoriesUI = (WebDAVCategories)findComponent(CATEGORY_EDITOR_ID); | private UIComponent getCategoryEditor() { WebDAVCategories categoriesUI = (WebDAVCategories)findComponent(WebDAVCategories.CATEGORIES_BLOCK_ID); if(categoriesUI==null){ //id on the component is set implicitly categoriesUI=new WebDAVCategories(); //we want to set the categories also on the parent ".article" folder: categoriesUI.setCategoriesOnParent(true); categoriesUI.setDisplaySaveButton(false); categoriesUI.setDisplayHeader(false); //categoriesUI.setId(CATEGORY_EDITOR_ID); FacesContext context = getFacesContext(); String setCategories = (String) context.getExternalContext().getRequestParameterMap().get(ContentItemToolbar.PARAMETER_CATEGORIES); if(setCategories!=null){ categoriesUI.setCategories(setCategories); } //Categories are set in encodeBegin: //if(!isInCreateMode()){ //there is no resourcepath set for the article if it's about to be created // categoriesUI.setResourcePath(resourcePath); //} //parent.getChildren().add(categoriesUI); } return categoriesUI; } |
categoriesUI.setId(CATEGORY_EDITOR_ID); | private UIComponent getCategoryEditor() { WebDAVCategories categoriesUI = (WebDAVCategories)findComponent(WebDAVCategories.CATEGORIES_BLOCK_ID); if(categoriesUI==null){ //id on the component is set implicitly categoriesUI=new WebDAVCategories(); //we want to set the categories also on the parent ".article" folder: categoriesUI.setCategoriesOnParent(true); categoriesUI.setDisplaySaveButton(false); categoriesUI.setDisplayHeader(false); //categoriesUI.setId(CATEGORY_EDITOR_ID); FacesContext context = getFacesContext(); String setCategories = (String) context.getExternalContext().getRequestParameterMap().get(ContentItemToolbar.PARAMETER_CATEGORIES); if(setCategories!=null){ categoriesUI.setCategories(setCategories); } //Categories are set in encodeBegin: //if(!isInCreateMode()){ //there is no resourcepath set for the article if it's about to be created // categoriesUI.setResourcePath(resourcePath); //} //parent.getChildren().add(categoriesUI); } return categoriesUI; } |
|
bodyArea.addValueChangeListener(this); bodyArea.setImmediate(true); | public UIComponent getEditContainer() { FacesContext context = FacesContext.getCurrentInstance(); IWContext iwc = IWContext.getIWContext(context); WFResourceUtil localizer = WFResourceUtil.getResourceUtilArticle();// String bref = WFPage.CONTENT_BUNDLE + "."; WFContainer mainContainer = getMainContainer(); //Language dropdown UIComponent langDropdown = getLanguageDropdownMenu(); UIComponent languageText = WFUtil.group(localizer.getTextVB("language"), WFUtil.getText(":")); HtmlOutputLabel languageLabel = new HtmlOutputLabel(); languageLabel.getChildren().add(languageText); languageLabel.setFor(langDropdown.getClientId(context)); WFFormItem languageItem = new WFFormItem(); languageItem.add(languageLabel); languageItem.add(langDropdown); mainContainer.add(languageItem); //Headline input HtmlInputText headlineInput = WFUtil.getInputText(HEADLINE_ID, ref + "headline"); headlineInput.setSize(70); UIComponent headlineText = WFUtil.group(localizer.getTextVB("headline"), WFUtil.getText(":")); HtmlOutputLabel headlineLabel = new HtmlOutputLabel(); headlineLabel.getChildren().add(headlineText); headlineLabel.setFor(headlineInput.getClientId(context)); WFFormItem headlineItem = new WFFormItem(); headlineItem.add(headlineLabel); headlineItem.add(headlineInput); mainContainer.add(headlineItem); //HtmlSelectOneMenu localeMenu = WFUtil.getSelectOneMenu(LOCALE_ID, ref + "allLocales", ref + "pendingLocaleId"); //localeMenu.setOnchange("document.forms[0].submit();"); //p.getChildren().add(localeMenu); //Author input HtmlInputText authorInput = WFUtil.getInputText(AUTHOR_ID, ref + "author"); User user = iwc.getCurrentUser(); if(user!=null){ String userName = user.getName(); getArticleItemBean().setAuthor(userName); } UIComponent authorText = WFUtil.group(localizer.getTextVB("author"), WFUtil.getText(":")); HtmlOutputLabel authorLabel = new HtmlOutputLabel(); authorLabel.getChildren().add(authorText); authorLabel.setFor(authorInput.getClientId(context)); WFFormItem authorItem = new WFFormItem(); authorItem.add(authorLabel); authorItem.add(authorInput); mainContainer.add(authorItem); //Article body HTMLArea bodyArea = WFUtil.getHtmlAreaTextArea(BODY_ID, ref + "body", "500px", "400px"); //HTMLArea bodyArea = WFUtil.getHtmlAreaTextArea(BODY_ID, ref + "body"); bodyArea.setAllowFontSelection(false);// bodyArea.addPlugin(HTMLArea.PLUGIN_TABLE_OPERATIONS);// bodyArea.addPlugin(HTMLArea.PLUGIN_DYNAMIC_CSS, "3");// bodyArea.addPlugin(HTMLArea.PLUGIN_CSS, "3");// bodyArea.addPlugin(HTMLArea.PLUGIN_CONTEXT_MENU);// bodyArea.addPlugin(HTMLArea.PLUGIN_LIST_TYPE);// bodyArea.addPlugin(HTMLArea.PLUGIN_CHARACTER_MAP);// bodyArea.addPlugin("TableOperations");// bodyArea.addPlugin("Template");// bodyArea.addPlugin("Forms");// bodyArea.addPlugin("FormOperations");// bodyArea.addPlugin("EditTag");// bodyArea.addPlugin("Stylist");// bodyArea.addPlugin("CSS");// bodyArea.addPlugin("DynamicCSS");// bodyArea.addPlugin("FullPage");// bodyArea.addPlugin("NoteServer");// bodyArea.addPlugin("QuickTag");// bodyArea.addPlugin("InsertSmiley");// bodyArea.addPlugin("InsertWords");// bodyArea.addPlugin("ContextMenu");// bodyArea.addPlugin("LangMarks");// bodyArea.addPlugin("DoubleClick");// bodyArea.addPlugin("ListType");// bodyArea.addPlugin("ImageManager"); UIComponent bodyText = WFUtil.group(localizer.getTextVB("body"), WFUtil.getText(":")); HtmlOutputLabel bodyLabel = new HtmlOutputLabel(); bodyLabel.getChildren().add(bodyText); bodyLabel.setFor(bodyArea.getClientId(context)); WFFormItem bodyItem = new WFFormItem(); bodyItem.add(bodyLabel); bodyItem.add(bodyArea); mainContainer.add(bodyItem); //Teaser input HtmlInputTextarea teaserArea = WFUtil.getTextArea(TEASER_ID, ref + "teaser", "500px", "60px"); UIComponent teaserText = WFUtil.group(localizer.getTextVB("teaser"), WFUtil.getText(":")); HtmlOutputLabel teaserLabel = new HtmlOutputLabel(); teaserLabel.getChildren().add(teaserText); teaserLabel.setFor(teaserArea.getClientId(context)); WFFormItem teaserItem = new WFFormItem(); teaserItem.add(teaserLabel); teaserItem.add(teaserArea); mainContainer.add(teaserItem); //Source input HtmlInputText sourceInput = WFUtil.getInputText(SOURCE_ID, ref + "source"); UIComponent sourceText = WFUtil.group(localizer.getTextVB("source"), WFUtil.getText(":")); HtmlOutputLabel sourceLabel = new HtmlOutputLabel(); sourceLabel.getChildren().add(sourceText); sourceLabel.setFor(sourceInput.getClientId(context)); WFFormItem sourceItem = new WFFormItem(); sourceItem.add(sourceLabel); sourceItem.add(sourceInput); mainContainer.add(sourceItem); //Status field HtmlOutputText statusValue = WFUtil.getTextVB(ref + "status"); WFContainer statusContainer = new WFContainer(); statusContainer.getChildren().add(statusValue); UIComponent statusText = WFUtil.group(localizer.getTextVB("status"), WFUtil.getText(":")); HtmlOutputLabel statusLabel = new HtmlOutputLabel(); statusLabel.getChildren().add(statusText); statusLabel.setFor(statusValue.getClientId(context)); WFFormItem statusItem = new WFFormItem(); statusItem.add(statusLabel); statusItem.add(statusContainer); mainContainer.add(statusItem); //Version field HtmlOutputText versionValue = WFUtil.getTextVB(ref + "versionName"); WFContainer versionContainer = new WFContainer(); versionContainer.add(versionValue); UIComponent versionText = WFUtil.group(localizer.getTextVB("current_version"), WFUtil.getText(":")); HtmlOutputLabel versionLabel = new HtmlOutputLabel(); versionLabel.getChildren().add(versionText); versionLabel.setFor(versionValue.getClientId(context)); WFFormItem versionItem = new WFFormItem(); versionItem.add(versionLabel); versionItem.add(versionContainer); mainContainer.add(versionItem); //Comment input HtmlInputTextarea commentArea = WFUtil.getTextArea(COMMENT_ID, ref + "comment", "500px", "60px"); UIComponent commentText = WFUtil.group(localizer.getTextVB("comment"), WFUtil.getText(":")); HtmlOutputLabel commentLabel = new HtmlOutputLabel(); commentLabel.getChildren().add(commentText); commentLabel.setFor(commentArea.getClientId(context)); WFFormItem commentItem = new WFFormItem(); commentItem.add(commentLabel); commentItem.add(commentArea); mainContainer.add(commentItem); // WFContainer attachmentContainer = new WFContainer();// attachmentContainer.add(WFUtil.getButtonVB(ADD_ATTACHMENT_ID, bref + "add_attachment", this));// attachmentContainer.add(WFUtil.getBreak());// attachmentContainer.add(getAttachmentList());// p.getChildren().add(attachmentContainer); // mainContainer.add(p);// p = WFPanelUtil.getFormPanel(1);// p.getChildren().add(WFUtil.group(WFUtil.getTextVB(bref + "related_content_items"), WFUtil.getText(":"))); // WFContainer contentItemContainer = new WFContainer(); // contentItemContainer.add(WFUtil.getButtonVB(ADD_RELATED_CONTENT_ITEM_ID, bref + "add_content_item", this));// contentItemContainer.add(WFUtil.getBreak());// contentItemContainer.add(getRelatedContentItemsList());// p.getChildren().add(contentItemContainer);// p.getChildren().add(WFUtil.group(WFUtil.getTextVB(bref + "publishing_date"), WFUtil.getText(":"))); // WFDateInput publishedFromInput = WFUtil.getDateInput(PUBLISHED_FROM_DATE_ID, ref + "case.publishedFromDate");// publishedFromInput.setShowTime(true);// p.getChildren().add(publishedFromInput);// p.getChildren().add(WFUtil.group(WFUtil.getTextVB(bref + "expiration_date"), WFUtil.getText(":"))); // WFDateInput publishedToInput = WFUtil.getDateInput(PUBLISHED_TO_DATE_ID, ref + "case.publishedToDate");// publishedToInput.setShowTime(true);// p.getChildren().add(publishedToInput);// mainContainer.add(p);// mainContainer.add(WFUtil.getBreak());// p = WFPanelUtil.getPlainFormPanel(1);// HtmlCommandButton editCategoriesButton = WFUtil.getButtonVB(EDIT_CATEGORIES_ID, bref + "edit_categories", this);// p.getChildren().add(editCategoriesButton);// Temporary taking away folderr location// p.getChildren().add(WFUtil.group(localizer.getTextVB("folder"), WFUtil.getText(":")));// HtmlInputText folderInput = WFUtil.getInputText(FOLDER_ID, ref + "folderLocation");// if(null==folderInput.getValue() || "".equals(folderInput.getValue())) {// String FolderString = ArticleUtil.getArticleYearMonthPath();// System.out.println("Folder "+FolderString);// folderInput.setValue(FolderString);// } else {// File file = new File(folderInput.getValue().toString());// folderInput.setValue(file.getParentFile().getParent());// }// folderInput.setSize(70);// p.getChildren().add(folderInput); // p.getChildren().add(WFUtil.getBreak());// Categories// WebDAVCategories categoriesUI = new WebDAVCategories();// ArticleItemBean articleItemBean = (ArticleItemBean) getArticleItemBean();// String resourcePath = articleItemBean.getArticleResourcePath(); //Categories input UIComponent categoriesContainer = getCategoryEditor(); UIComponent categoriesText = WFUtil.group(localizer.getTextVB("categories"), WFUtil.getText(":")); HtmlOutputLabel categoriesLabel = new HtmlOutputLabel(); categoriesLabel.getChildren().add(categoriesText); categoriesLabel.setFor(categoriesContainer.getClientId(context)); WFFormItem categoriesItem = new WFFormItem(); categoriesItem.add(categoriesLabel); categoriesItem.add(categoriesContainer); mainContainer.add(categoriesItem); // WFComponentSelector cs = new WFComponentSelector();// cs.setId(BUTTON_SELECTOR_ID);// cs.setDividerText(" ");// HtmlCommandButton saveButton = WFUtil.getButtonVB(SAVE_ID, WFPage.CONTENT_BUNDLE + "save", this);// cs.add(saveButton);// cs.add(WFUtil.getButtonVB(FOR_REVIEW_ID, bref + "for_review", this));// cs.add(WFUtil.getButtonVB(PUBLISH_ID, bref + "publish", this));// cs.add(WFUtil.getButtonVB(REWRITE_ID, bref + "rewrite", this));// cs.add(WFUtil.getButtonVB(REJECT_ID, bref + "reject", this));// cs.add(WFUtil.getButtonVB(DELETE_ID, bref + "delete", this));// cs.add(WFUtil.getButtonVB(CANCEL_ID, bref + "cancel", this));// cs.setSelectedId(CANCEL_ID, true);// p.getChildren().add(cs); FieldSet buttons = new FieldSet(); buttons.setStyleClass("buttons"); HtmlCommandButton saveButton = localizer.getButtonVB(SAVE_ID, "save", this); buttons.getChildren().add(saveButton); mainContainer.getChildren().add(buttons); return mainContainer; } |
|
categoriesUI.saveCategoriesSettings(fileResourcePath, categoriesUI); | categoriesUI.saveCategoriesSettings(); | public void processAction(ActionEvent event) { String id = event.getComponent().getId(); UIComponent rootParent = rootParent = event.getComponent().getParent().getParent().getParent(); EditArticleView ab = (EditArticleView) rootParent.findComponent(EDIT_ARTICLE_BLOCK_ID); if (id.equals(SAVE_ID)) { //We have the save button pressed boolean saveSuccessful=false; saveSuccessful = ab.storeArticle(); if(saveSuccessful){ ArticleItemBean articleItemBean = getArticleItemBean(); String fileResourcePath = articleItemBean.getLocalizedArticle().getResourcePath(); WebDAVCategories categoriesUI = (WebDAVCategories) ab.getCategoryEditor(); if(categoriesUI!=null){ categoriesUI.setResourcePath(fileResourcePath); categoriesUI.saveCategoriesSettings(fileResourcePath, categoriesUI); } } clearOnInit=false; } else if (id.equals(DELETE_ID)) { //we are deleting ArticleItemBean articleItemBean = getArticleItemBean(); articleItemBean.delete(); WFUtil.addMessageVB(ab.findComponent(DELETE_ID),ArticleUtil.IW_BUNDLE_IDENTIFIER, "delete_successful"); } /* else if (id.equals(FOR_REVIEW_ID)) { WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setRequestedStatus", ContentItemCase.STATUS_READY_FOR_REVIEW); ab.storeArticle(); } else if (id.equals(PUBLISH_ID)) { WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setRequestedStatus", ContentItemCase.STATUS_PUBLISHED); ab.storeArticle(); } else if (id.equals(REWRITE_ID)) { WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setRequestedStatus", ContentItemCase.STATUS_REWRITE); ab.storeArticle(); } else if (id.equals(REJECT_ID)) { WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setRequestedStatus", ContentItemCase.STATUS_DELETED); ab.storeArticle(); } else if (id.equals(DELETE_ID)) { WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setRequestedStatus", ContentItemCase.STATUS_DELETED); ab.storeArticle(); } else if (id.equals(ADD_IMAGE_ID)) { ab.setEditView(FILE_UPLOAD_FORM_ID); } else if (id.equals(FILE_UPLOAD_CANCEL_ID)) { ab.setEditView(ARTICLE_EDITOR_ID); } else if (id.equals(FILE_UPLOAD_ID)) { ab.setEditView(ARTICLE_EDITOR_ID); } else if (id.equals(CaseListBean.CASE_ID)){ String itemId = WFUtil.getParameter(event.getComponent(), "id"); WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "addRelatedContentItem", new Integer(itemId)); ab.setEditView(ARTICLE_EDITOR_ID); }*/ } |
public void processValueChange(ValueChangeEvent arg0) throws AbortProcessingException { if(arg0.getOldValue()==null) { return; } if(arg0.getNewValue()==null) { return; } System.out.println("Language value has changed from "+arg0.getOldValue()+" to "+arg0.getNewValue()); | public void processValueChange(ValueChangeEvent event) throws AbortProcessingException { | public void processValueChange(ValueChangeEvent arg0) throws AbortProcessingException { if(arg0.getOldValue()==null) { return; } if(arg0.getNewValue()==null) { return; } System.out.println("Language value has changed from "+arg0.getOldValue()+" to "+arg0.getNewValue()); ArticleItemBean bean = getArticleItemBean(); //String articlePath = (String)WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "getArticlePath"); String articlePath = bean.getResourcePath(); //String language = (String)WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "getContentLanguage"); //String language = bean.getContentLanguage(); if(null==articlePath) { //Article has not been stored previously, so nothing has to be done return; } System.out.println("processValueChange: Article path: "+articlePath); //boolean result = ((Boolean)WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "load",articlePath+"/"+arg0.getNewValue()+ArticleItemBean.ARTICLE_SUFFIX)).booleanValue(); //System.out.println("loading other language "+result); //if(result) { //WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setLanguageChange",arg0.getNewValue().toString()); String langChange = arg0.getNewValue().toString(); bean.setLanguageChange(langChange); Locale locale = new Locale(langChange); bean.setLocale(locale); System.out.println("processValueChange: changint to other language "+langChange); //}else { //if(null!=language) { //result = ((Boolean)WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "load",articlePath+"/"+language+ArticleItemBean.ARTICLE_SUFFIX)).booleanValue(); //bean.setLanguageChange(language); //bean.setLocale(new Locale(language)); //System.out.println("loading other language "+result); //} //} } |
ArticleItemBean bean = getArticleItemBean(); String articlePath = bean.getResourcePath(); if(null==articlePath) { return; } System.out.println("processValueChange: Article path: "+articlePath); | if(event.getComponent().getId().equals(LOCALE_ID)){ if(event.getOldValue()==null) { return; } if(event.getNewValue()==null) { return; } System.out.println("Language value has changed from "+event.getOldValue()+" to "+event.getNewValue()); ArticleItemBean bean = getArticleItemBean(); String articlePath = bean.getResourcePath(); if(null==articlePath) { return; } System.out.println("processValueChange: Article path: "+articlePath); | public void processValueChange(ValueChangeEvent arg0) throws AbortProcessingException { if(arg0.getOldValue()==null) { return; } if(arg0.getNewValue()==null) { return; } System.out.println("Language value has changed from "+arg0.getOldValue()+" to "+arg0.getNewValue()); ArticleItemBean bean = getArticleItemBean(); //String articlePath = (String)WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "getArticlePath"); String articlePath = bean.getResourcePath(); //String language = (String)WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "getContentLanguage"); //String language = bean.getContentLanguage(); if(null==articlePath) { //Article has not been stored previously, so nothing has to be done return; } System.out.println("processValueChange: Article path: "+articlePath); //boolean result = ((Boolean)WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "load",articlePath+"/"+arg0.getNewValue()+ArticleItemBean.ARTICLE_SUFFIX)).booleanValue(); //System.out.println("loading other language "+result); //if(result) { //WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setLanguageChange",arg0.getNewValue().toString()); String langChange = arg0.getNewValue().toString(); bean.setLanguageChange(langChange); Locale locale = new Locale(langChange); bean.setLocale(locale); System.out.println("processValueChange: changint to other language "+langChange); //}else { //if(null!=language) { //result = ((Boolean)WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "load",articlePath+"/"+language+ArticleItemBean.ARTICLE_SUFFIX)).booleanValue(); //bean.setLanguageChange(language); //bean.setLocale(new Locale(language)); //System.out.println("loading other language "+result); //} //} } |
String langChange = arg0.getNewValue().toString(); | String langChange = event.getNewValue().toString(); | public void processValueChange(ValueChangeEvent arg0) throws AbortProcessingException { if(arg0.getOldValue()==null) { return; } if(arg0.getNewValue()==null) { return; } System.out.println("Language value has changed from "+arg0.getOldValue()+" to "+arg0.getNewValue()); ArticleItemBean bean = getArticleItemBean(); //String articlePath = (String)WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "getArticlePath"); String articlePath = bean.getResourcePath(); //String language = (String)WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "getContentLanguage"); //String language = bean.getContentLanguage(); if(null==articlePath) { //Article has not been stored previously, so nothing has to be done return; } System.out.println("processValueChange: Article path: "+articlePath); //boolean result = ((Boolean)WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "load",articlePath+"/"+arg0.getNewValue()+ArticleItemBean.ARTICLE_SUFFIX)).booleanValue(); //System.out.println("loading other language "+result); //if(result) { //WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setLanguageChange",arg0.getNewValue().toString()); String langChange = arg0.getNewValue().toString(); bean.setLanguageChange(langChange); Locale locale = new Locale(langChange); bean.setLocale(locale); System.out.println("processValueChange: changint to other language "+langChange); //}else { //if(null!=language) { //result = ((Boolean)WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "load",articlePath+"/"+language+ArticleItemBean.ARTICLE_SUFFIX)).booleanValue(); //bean.setLanguageChange(language); //bean.setLocale(new Locale(language)); //System.out.println("loading other language "+result); //} //} } |
} else if(event.getComponent().getId().equals(BODY_ID)){ String newBodyValue = event.getNewValue().toString(); getArticleItemBean().setBody(newBodyValue); } else if(event.getComponent().getId().equals(HEADLINE_ID)){ String newValue = event.getNewValue().toString(); getArticleItemBean().setHeadline(newValue); } else if(event.getComponent().getId().equals(AUTHOR_ID)){ String newValue = event.getNewValue().toString(); getArticleItemBean().setAuthor(newValue); } | public void processValueChange(ValueChangeEvent arg0) throws AbortProcessingException { if(arg0.getOldValue()==null) { return; } if(arg0.getNewValue()==null) { return; } System.out.println("Language value has changed from "+arg0.getOldValue()+" to "+arg0.getNewValue()); ArticleItemBean bean = getArticleItemBean(); //String articlePath = (String)WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "getArticlePath"); String articlePath = bean.getResourcePath(); //String language = (String)WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "getContentLanguage"); //String language = bean.getContentLanguage(); if(null==articlePath) { //Article has not been stored previously, so nothing has to be done return; } System.out.println("processValueChange: Article path: "+articlePath); //boolean result = ((Boolean)WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "load",articlePath+"/"+arg0.getNewValue()+ArticleItemBean.ARTICLE_SUFFIX)).booleanValue(); //System.out.println("loading other language "+result); //if(result) { //WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "setLanguageChange",arg0.getNewValue().toString()); String langChange = arg0.getNewValue().toString(); bean.setLanguageChange(langChange); Locale locale = new Locale(langChange); bean.setLocale(locale); System.out.println("processValueChange: changint to other language "+langChange); //}else { //if(null!=language) { //result = ((Boolean)WFUtil.invoke(ARTICLE_ITEM_BEAN_ID, "load",articlePath+"/"+language+ArticleItemBean.ARTICLE_SUFFIX)).booleanValue(); //bean.setLanguageChange(language); //bean.setLocale(new Locale(language)); //System.out.println("loading other language "+result); //} //} } |
|
contactList.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("Ctrl F11"), "viewClient"); | contactList.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("control F11"), "viewClient"); | public void initialize() { // Create IQ Filter PacketFilter packetFilter = new PacketTypeFilter(IQ.class); SparkManager.getConnection().addPacketListener(new PacketListener() { public void processPacket(Packet packet) { IQ iq = (IQ)packet; // Handle Version Request if (iq instanceof Version && iq.getType() == IQ.Type.GET) { // Send Version Version version = new Version(); version.setName("Spark IM Client"); version.setOs(JiveInfo.getOS()); version.setVersion(JiveInfo.getVersion()); // Send back as a reply version.setPacketID(iq.getPacketID()); version.setType(IQ.Type.RESULT); version.setTo(iq.getFrom()); version.setFrom(iq.getTo()); SparkManager.getConnection().sendPacket(version); } // Send time else if (iq instanceof Time && iq.getType() == IQ.Type.GET) { Time time = new Time(); time.setPacketID(iq.getPacketID()); time.setFrom(iq.getTo()); time.setTo(iq.getFrom()); time.setTime(new Date()); time.setType(IQ.Type.RESULT); // Send Time SparkManager.getConnection().sendPacket(time); } } }, packetFilter); final ContactList contactList = SparkManager.getWorkspace().getContactList(); contactList.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("Ctrl F11"), "viewClient"); contactList.addContextMenuListener(new ContextMenuListener() { public void poppingUp(final Object component, JPopupMenu popup) { if (!(component instanceof ContactItem)) { return; } Action versionRequest = new AbstractAction() { public void actionPerformed(ActionEvent e) { viewClient(); } }; versionRequest.putValue(Action.NAME, Res.getString("menuitem.view.client.version")); popup.add(versionRequest); } public void poppingDown(JPopupMenu popup) { } public boolean handleDefaultAction(MouseEvent e) { return false; } }); contactList.getActionMap().put("viewClient", new AbstractAction("viewClient") { public void actionPerformed(ActionEvent evt) { viewClient(); } }); } |
this.context = context; if (initializedSignal != null) { initializedSignal.countDown(); } | public void initialize(ServiceConditionContext context) { initializeCalled = true; } |
|
private void destroy() throws UnsatisfiedConditionsException, IllegalServiceStateException { | private void destroy(StopStrategy stopStrategy) { ServiceState initialState = serviceManager.getState(); | private void destroy() throws UnsatisfiedConditionsException, IllegalServiceStateException { serviceMonitor.reset(); serviceManager.destroy(StopStrategies.SYNCHRONOUS); assertSame(serviceName, serviceManager.getServiceName()); assertSame(serviceFactory, serviceManager.getServiceFactory()); assertSame(classLoader, serviceManager.getClassLoader()); assertEquals(0, serviceManager.getStartTime()); assertNull(serviceManager.getService()); assertSame(ServiceState.STOPPED, serviceManager.getState()); // verify expected events fired assertNull(serviceMonitor.registered); assertNull(serviceMonitor.starting); assertNull(serviceMonitor.waitingToStart); assertNull(serviceMonitor.startError); assertNull(serviceMonitor.running); assertNull(serviceMonitor.stopping); assertNull(serviceMonitor.waitingToStop); assertNull(serviceMonitor.stopError); assertNull(serviceMonitor.stopped); assertNotNull(serviceMonitor.unregistered); } |
serviceManager.destroy(StopStrategies.SYNCHRONOUS); | startCondition.reset(); stopCondition.reset(); kernel.reset(); try { serviceManager.destroy(stopStrategy); } catch (IllegalServiceStateException e) { assertFalse(stopCondition.satisfied); assertSame(StopStrategies.ASYNCHRONOUS, stopStrategy); } catch (UnsatisfiedConditionsException e) { assertFalse(stopCondition.satisfied); assertSame(StopStrategies.SYNCHRONOUS, stopStrategy); assertTrue(e.getUnsatisfiedConditions().contains(stopCondition)); } | private void destroy() throws UnsatisfiedConditionsException, IllegalServiceStateException { serviceMonitor.reset(); serviceManager.destroy(StopStrategies.SYNCHRONOUS); assertSame(serviceName, serviceManager.getServiceName()); assertSame(serviceFactory, serviceManager.getServiceFactory()); assertSame(classLoader, serviceManager.getClassLoader()); assertEquals(0, serviceManager.getStartTime()); assertNull(serviceManager.getService()); assertSame(ServiceState.STOPPED, serviceManager.getState()); // verify expected events fired assertNull(serviceMonitor.registered); assertNull(serviceMonitor.starting); assertNull(serviceMonitor.waitingToStart); assertNull(serviceMonitor.startError); assertNull(serviceMonitor.running); assertNull(serviceMonitor.stopping); assertNull(serviceMonitor.waitingToStop); assertNull(serviceMonitor.stopError); assertNull(serviceMonitor.stopped); assertNotNull(serviceMonitor.unregistered); } |
assertSame(serviceName, serviceManager.getServiceName()); assertSame(serviceFactory, serviceManager.getServiceFactory()); assertSame(classLoader, serviceManager.getClassLoader()); assertEquals(0, serviceManager.getStartTime()); assertNull(serviceManager.getService()); assertSame(ServiceState.STOPPED, serviceManager.getState()); assertNull(serviceMonitor.registered); assertNull(serviceMonitor.starting); assertNull(serviceMonitor.waitingToStart); assertNull(serviceMonitor.startError); assertNull(serviceMonitor.running); assertNull(serviceMonitor.stopping); assertNull(serviceMonitor.waitingToStop); assertNull(serviceMonitor.stopError); assertNull(serviceMonitor.stopped); assertNotNull(serviceMonitor.unregistered); | if (serviceFactory.restartable || initialState == ServiceState.STOPPED) { assertSame(ServiceState.STOPPED, serviceManager.getState()); assertSame(serviceName, serviceManager.getServiceName()); assertSame(serviceFactory, serviceManager.getServiceFactory()); assertSame(classLoader, serviceManager.getClassLoader()); assertEquals(0, serviceManager.getStartTime()); assertNull(serviceManager.getService()); assertNull(serviceMonitor.registered); assertNull(serviceMonitor.starting); assertNull(serviceMonitor.waitingToStart); assertNull(serviceMonitor.startError); assertNull(serviceMonitor.running); assertNull(serviceMonitor.stopping); assertNull(serviceMonitor.waitingToStop); assertNull(serviceMonitor.stopError); assertNull(serviceMonitor.stopped); assertNotNull(serviceMonitor.unregistered); } else if (!stopCondition.satisfied && stopStrategy != StopStrategies.FORCE) { assertSame(ServiceState.RUNNING, serviceManager.getState()); assertSame(serviceName, serviceManager.getServiceName()); assertSame(serviceFactory, serviceManager.getServiceFactory()); assertSame(classLoader, serviceManager.getClassLoader()); assertTrue(serviceManager.getStartTime() > 0); assertNotNull(serviceManager.getService()); assertNull(serviceMonitor.registered); assertNull(serviceMonitor.starting); assertNull(serviceMonitor.waitingToStart); assertNull(serviceMonitor.startError); assertNull(serviceMonitor.running); assertNull(serviceMonitor.stopping); if (stopStrategy == StopStrategies.ASYNCHRONOUS) { assertNotNull(serviceMonitor.waitingToStop); assertTrue(serviceMonitor.waitingToStop.getUnsatisfiedConditions().contains(stopCondition)); } else { assertNull(serviceMonitor.waitingToStop); } assertNull(serviceMonitor.stopError); assertNull(serviceMonitor.stopped); assertNull(serviceMonitor.unregistered); } else if (serviceFactory.throwExceptionFromDestroy != true) { assertSame(ServiceState.STOPPED, serviceManager.getState()); assertEquals(0, serviceManager.getStartTime()); assertNull(serviceManager.getService()); assertNull(serviceMonitor.registered); assertNull(serviceMonitor.starting); assertNull(serviceMonitor.waitingToStart); assertNull(serviceMonitor.startError); assertNull(serviceMonitor.running); assertNotNull(serviceMonitor.stopping); assertNull(serviceMonitor.waitingToStop); if (!stopCondition.satisfied && stopStrategy == StopStrategies.FORCE) { assertNotNull(serviceMonitor.stopError); } else { assertNull(serviceMonitor.stopError); } assertNotNull(serviceMonitor.stopped); assertNotNull(serviceMonitor.unregistered); if (!stopCondition.satisfied && stopStrategy == StopStrategies.FORCE) { assertEquals(serviceMonitor.stopError.getEventId() + 1, serviceMonitor.stopping.getEventId()); assertEquals(serviceMonitor.stopError.getEventId() + 2, serviceMonitor.stopped.getEventId()); assertEquals(serviceMonitor.stopError.getEventId() + 3, serviceMonitor.unregistered.getEventId()); } else { assertEquals(serviceMonitor.stopping.getEventId() + 1, serviceMonitor.stopped.getEventId()); assertEquals(serviceMonitor.stopping.getEventId() + 2, serviceMonitor.unregistered.getEventId()); } assertFalse(startCondition.initializeCalled); assertFalse(startCondition.isSatisfiedCalled); assertTrue(startCondition.destroyCalled); assertTrue(stopCondition.isSatisfiedCalled); assertTrue(stopCondition.destroyCalled); } else { assertSame(ServiceState.STOPPED, serviceManager.getState()); assertEquals(0, serviceManager.getStartTime()); assertNull(serviceManager.getService()); assertNull(serviceMonitor.registered); assertNull(serviceMonitor.starting); assertNull(serviceMonitor.waitingToStart); assertNull(serviceMonitor.startError); assertNull(serviceMonitor.running); assertNotNull(serviceMonitor.stopping); assertNull(serviceMonitor.waitingToStop); assertNotNull(serviceMonitor.stopError); assertNotNull(serviceMonitor.stopped); assertNotNull(serviceMonitor.unregistered); assertEquals(serviceMonitor.stopping.getEventId() + 1, serviceMonitor.stopError.getEventId()); assertEquals(serviceMonitor.stopping.getEventId() + 2, serviceMonitor.stopped.getEventId()); assertEquals(serviceMonitor.stopping.getEventId() + 3, serviceMonitor.unregistered.getEventId()); assertFalse(startCondition.initializeCalled); assertFalse(startCondition.isSatisfiedCalled); assertTrue(startCondition.destroyCalled); assertTrue(stopCondition.initializeCalled); assertTrue(stopCondition.isSatisfiedCalled); assertTrue(stopCondition.destroyCalled); } | private void destroy() throws UnsatisfiedConditionsException, IllegalServiceStateException { serviceMonitor.reset(); serviceManager.destroy(StopStrategies.SYNCHRONOUS); assertSame(serviceName, serviceManager.getServiceName()); assertSame(serviceFactory, serviceManager.getServiceFactory()); assertSame(classLoader, serviceManager.getClassLoader()); assertEquals(0, serviceManager.getStartTime()); assertNull(serviceManager.getService()); assertSame(ServiceState.STOPPED, serviceManager.getState()); // verify expected events fired assertNull(serviceMonitor.registered); assertNull(serviceMonitor.starting); assertNull(serviceMonitor.waitingToStart); assertNull(serviceMonitor.startError); assertNull(serviceMonitor.running); assertNull(serviceMonitor.stopping); assertNull(serviceMonitor.waitingToStop); assertNull(serviceMonitor.stopError); assertNull(serviceMonitor.stopped); assertNotNull(serviceMonitor.unregistered); } |
try { start(false, startStrategy); } catch (IllegalServiceStateException e) { assertTrue(startStrategy == StartStrategies.UNREGISTER); } try { start(false, startStrategy); } catch (IllegalServiceStateException e) { assertTrue(startStrategy == StartStrategies.UNREGISTER); } | start(false, startStrategy); start(false, startStrategy); | private void disabledStart(StartStrategy startStrategy) throws Exception { serviceFactory.setEnabled(false); try { serviceManager.start(false, startStrategy); fail("A disabled service should throw an IllegalServiceStateException from start"); } catch (IllegalServiceStateException e) { // expected } // move to starting disable, move to running, and try to restart serviceFactory.setEnabled(true); startCondition.satisfied = false; start(false, StartStrategies.ASYNCHRONOUS); serviceFactory.setEnabled(false);// try {// start(false, startStrategy);// } catch (IllegalServiceStateException e) {// assertTrue(startStrategy == StartStrategies.UNREGISTER);// } catch (UnsatisfiedConditionsException e) {// assertTrue(startStrategy == StartStrategies.SYNCHRONOUS);// assertTrue(e.getUnsatisfiedConditions().contains(startCondition));// } catch (UnregisterServiceException e) {// assertEquals(StartStrategies.UNREGISTER, startStrategy);// UnsatisfiedConditionsException cause = (UnsatisfiedConditionsException) e.getCause();// assertTrue(cause.getUnsatisfiedConditions().contains(startCondition));// } startCondition.satisfied = true; try { start(false, startStrategy); } catch (IllegalServiceStateException e) { assertTrue(startStrategy == StartStrategies.UNREGISTER); } try { start(false, startStrategy); } catch (IllegalServiceStateException e) { assertTrue(startStrategy == StartStrategies.UNREGISTER); } stop(StopStrategies.ASYNCHRONOUS); try { serviceManager.start(false, startStrategy); fail("A disabled service should throw an IllegalServiceStateException from start"); } catch (IllegalServiceStateException e) { // expected } } |
serviceManager.initialize(); | startCondition.reset(); stopCondition.reset(); kernel.reset(); try { serviceManager.initialize(); } catch (MockCreateException e) { assertTrue(serviceFactory.throwExceptionFromCreate == true); assertSame(serviceFactory.createException, e); } catch (UnsatisfiedConditionsException e) { assertTrue(startCondition.satisfied == false); assertTrue(e.getUnsatisfiedConditions().contains(startCondition)); } catch (IllegalServiceStateException e) { assertFalse(serviceFactory.isEnabled()); } | private void initialize() throws Exception { serviceMonitor.reset(); serviceManager.initialize(); assertSame(serviceName, serviceManager.getServiceName()); assertSame(serviceFactory, serviceManager.getServiceFactory()); assertSame(classLoader, serviceManager.getClassLoader()); assertEquals(0, serviceManager.getStartTime()); assertNull(serviceManager.getService()); assertSame(ServiceState.STOPPED, serviceManager.getState()); // verify expected events fired assertNotNull(serviceMonitor.registered); assertNull(serviceMonitor.starting); assertNull(serviceMonitor.waitingToStart); assertNull(serviceMonitor.startError); assertNull(serviceMonitor.running); assertNull(serviceMonitor.stopping); assertNull(serviceMonitor.waitingToStop); assertNull(serviceMonitor.stopError); assertNull(serviceMonitor.stopped); assertNull(serviceMonitor.unregistered); } |
assertEquals(0, serviceManager.getStartTime()); assertNull(serviceManager.getService()); assertSame(ServiceState.STOPPED, serviceManager.getState()); assertNotNull(serviceMonitor.registered); assertNull(serviceMonitor.starting); assertNull(serviceMonitor.waitingToStart); assertNull(serviceMonitor.startError); assertNull(serviceMonitor.running); assertNull(serviceMonitor.stopping); assertNull(serviceMonitor.waitingToStop); assertNull(serviceMonitor.stopError); assertNull(serviceMonitor.stopped); assertNull(serviceMonitor.unregistered); | if (serviceFactory.restartable) { assertSame(ServiceState.STOPPED, serviceManager.getState()); assertEquals(0, serviceManager.getStartTime()); assertNull(serviceManager.getService()); assertNotNull(serviceMonitor.registered); assertNull(serviceMonitor.starting); assertNull(serviceMonitor.waitingToStart); assertNull(serviceMonitor.startError); assertNull(serviceMonitor.running); assertNull(serviceMonitor.stopping); assertNull(serviceMonitor.waitingToStop); assertNull(serviceMonitor.stopError); assertNull(serviceMonitor.stopped); assertNull(serviceMonitor.unregistered); assertFalse(startCondition.initializeCalled); assertFalse(startCondition.isSatisfiedCalled); assertFalse(startCondition.destroyCalled); assertFalse(stopCondition.initializeCalled); assertFalse(stopCondition.isSatisfiedCalled); assertFalse(stopCondition.destroyCalled); } else if (!serviceFactory.isEnabled()) { assertSame(ServiceState.STOPPED, serviceManager.getState()); assertEquals(0, serviceManager.getStartTime()); assertNull(serviceManager.getService()); assertNull(serviceMonitor.registered); assertNull(serviceMonitor.starting); assertNull(serviceMonitor.waitingToStart); assertNull(serviceMonitor.startError); assertNull(serviceMonitor.running); assertNull(serviceMonitor.stopping); assertNull(serviceMonitor.stopError); assertNull(serviceMonitor.stopped); assertNull(serviceMonitor.unregistered); assertFalse(startCondition.initializeCalled); assertFalse(startCondition.isSatisfiedCalled); assertFalse(startCondition.destroyCalled); assertFalse(stopCondition.initializeCalled); assertFalse(stopCondition.isSatisfiedCalled); assertFalse(stopCondition.destroyCalled); } else if (serviceFactory.throwExceptionFromCreate != true && startCondition.satisfied == true) { assertSame(ServiceState.RUNNING, serviceManager.getState()); assertSame(SERVICE, serviceManager.getService()); assertTrue(serviceManager.getStartTime() > now); assertNotNull(serviceMonitor.registered); assertNotNull(serviceMonitor.starting); assertNull(serviceMonitor.waitingToStart); assertNull(serviceMonitor.startError); assertNotNull(serviceMonitor.running); assertNull(serviceMonitor.stopping); assertNull(serviceMonitor.stopError); assertNull(serviceMonitor.stopped); assertNull(serviceMonitor.unregistered); assertEquals(serviceMonitor.registered.getEventId() + 1, serviceMonitor.starting.getEventId()); assertEquals(serviceMonitor.registered.getEventId() + 2, serviceMonitor.running.getEventId()); assertTrue(startCondition.initializeCalled); assertTrue(startCondition.isSatisfiedCalled); assertFalse(startCondition.destroyCalled); assertFalse(stopCondition.initializeCalled); assertFalse(stopCondition.isSatisfiedCalled); assertFalse(stopCondition.destroyCalled); } else { assertSame(ServiceState.STOPPED, serviceManager.getState()); assertEquals(0, serviceManager.getStartTime()); assertNull(serviceManager.getService()); assertNotNull(serviceMonitor.registered); assertNotNull(serviceMonitor.starting); assertNull(serviceMonitor.waitingToStart); assertNull(serviceMonitor.startError); assertNull(serviceMonitor.running); assertNotNull(serviceMonitor.stopping); assertNull(serviceMonitor.stopError); assertNotNull(serviceMonitor.stopped); assertNotNull(serviceMonitor.unregistered); assertEquals(serviceMonitor.registered.getEventId() + 1, serviceMonitor.starting.getEventId()); assertEquals(serviceMonitor.registered.getEventId() + 2, serviceMonitor.stopping.getEventId()); assertEquals(serviceMonitor.registered.getEventId() + 3, serviceMonitor.stopped.getEventId()); assertEquals(serviceMonitor.registered.getEventId() + 4, serviceMonitor.unregistered.getEventId()); assertTrue(startCondition.initializeCalled); assertTrue(startCondition.isSatisfiedCalled); assertTrue(startCondition.destroyCalled); assertFalse(stopCondition.initializeCalled); assertFalse(stopCondition.isSatisfiedCalled); assertFalse(stopCondition.destroyCalled); } | private void initialize() throws Exception { serviceMonitor.reset(); serviceManager.initialize(); assertSame(serviceName, serviceManager.getServiceName()); assertSame(serviceFactory, serviceManager.getServiceFactory()); assertSame(classLoader, serviceManager.getClassLoader()); assertEquals(0, serviceManager.getStartTime()); assertNull(serviceManager.getService()); assertSame(ServiceState.STOPPED, serviceManager.getState()); // verify expected events fired assertNotNull(serviceMonitor.registered); assertNull(serviceMonitor.starting); assertNull(serviceMonitor.waitingToStart); assertNull(serviceMonitor.startError); assertNull(serviceMonitor.running); assertNull(serviceMonitor.stopping); assertNull(serviceMonitor.waitingToStop); assertNull(serviceMonitor.stopError); assertNull(serviceMonitor.stopped); assertNull(serviceMonitor.unregistered); } |
private void startException(StartStrategy startStrategy) throws Exception { | private void startException(StartStrategy startStrategy, boolean recursive) throws Exception { | private void startException(StartStrategy startStrategy) throws Exception { serviceFactory.throwExceptionFromCreate = true; try { start(false, startStrategy); } catch (MockCreateException e) { assertTrue(startStrategy == StartStrategies.SYNCHRONOUS || startStrategy == StartStrategies.BLOCK); assertEquals(serviceFactory.createException, e); } catch (UnregisterServiceException e) { assertEquals(StartStrategies.UNREGISTER, startStrategy); assertSame(serviceFactory.createException, e.getCause()); } stop(StopStrategies.SYNCHRONOUS); } |
start(false, startStrategy); | start(recursive, startStrategy); | private void startException(StartStrategy startStrategy) throws Exception { serviceFactory.throwExceptionFromCreate = true; try { start(false, startStrategy); } catch (MockCreateException e) { assertTrue(startStrategy == StartStrategies.SYNCHRONOUS || startStrategy == StartStrategies.BLOCK); assertEquals(serviceFactory.createException, e); } catch (UnregisterServiceException e) { assertEquals(StartStrategies.UNREGISTER, startStrategy); assertSame(serviceFactory.createException, e.getCause()); } stop(StopStrategies.SYNCHRONOUS); } |
private void startStop(StartStrategy startStrategy) throws Exception { start(false, startStrategy); | private void startStop(StartStrategy startStrategy, boolean recursive) throws Exception { start(recursive, startStrategy); | private void startStop(StartStrategy startStrategy) throws Exception { start(false, startStrategy); stop(StopStrategies.SYNCHRONOUS); start(false, startStrategy); start(false, startStrategy); stop(StopStrategies.SYNCHRONOUS); stop(StopStrategies.SYNCHRONOUS); } |
start(false, startStrategy); start(false, startStrategy); | start(recursive, startStrategy); start(recursive, startStrategy); | private void startStop(StartStrategy startStrategy) throws Exception { start(false, startStrategy); stop(StopStrategies.SYNCHRONOUS); start(false, startStrategy); start(false, startStrategy); stop(StopStrategies.SYNCHRONOUS); stop(StopStrategies.SYNCHRONOUS); } |
} else if (!stopCondition.satisfied) { | } else if (!stopCondition.satisfied && stopStrategy != StopStrategies.FORCE) { | private void stop(StopStrategy stopStrategy) throws Exception { serviceMonitor.reset(); startCondition.reset(); stopCondition.reset(); ServiceState initialState = serviceManager.getState(); serviceManager.stop(stopStrategy); assertSame(serviceName, serviceManager.getServiceName()); assertSame(serviceFactory, serviceManager.getServiceFactory()); assertSame(classLoader, serviceManager.getClassLoader()); // these events should never fire in response to start assertNull(serviceMonitor.registered); assertNull(serviceMonitor.starting); assertNull(serviceMonitor.waitingToStart); assertNull(serviceMonitor.startError); assertNull(serviceMonitor.running); if (initialState == ServiceState.STOPPED) { // // We were alredy stopped so nothing should have happened // assertEquals(0, serviceManager.getStartTime()); assertNull(serviceManager.getService()); assertSame(ServiceState.STOPPED, serviceManager.getState()); assertNull(serviceMonitor.stopping); assertNull(serviceMonitor.waitingToStop); assertNull(serviceMonitor.stopError); assertNull(serviceMonitor.stopped); assertNull(serviceMonitor.unregistered); // start condition methods assertFalse(startCondition.initializeCalled); assertFalse(startCondition.isSatisfiedCalled); assertFalse(startCondition.destroyCalled); // stop condition methods assertFalse(stopCondition.initializeCalled); assertFalse(stopCondition.isSatisfiedCalled); assertFalse(stopCondition.destroyCalled); } else if (!stopCondition.satisfied) { // // waiting to stop // assertSame(ServiceState.STOPPING, serviceManager.getState()); assertTrue(serviceManager.getStartTime() > 0); assertSame(SERVICE, serviceManager.getService()); // verify expected events fired if (initialState != ServiceState.STOPPING) { assertNotNull(serviceMonitor.stopping); } assertNotNull(serviceMonitor.waitingToStop); assertNull(serviceMonitor.stopError); assertNull(serviceMonitor.stopped); assertNull(serviceMonitor.unregistered); // verify events fired in the correct order if (initialState != ServiceState.STOPPING) { assertEquals(serviceMonitor.stopping.getEventId() + 1, serviceMonitor.waitingToStop.getEventId()); } // our condition should be in the unsatisfied condition list assertNotNull(serviceMonitor.waitingToStop.getUnsatisfiedConditions()); assertTrue(serviceMonitor.waitingToStop.getUnsatisfiedConditions().contains(stopCondition)); // start condition methods assertFalse(startCondition.initializeCalled); assertFalse(startCondition.isSatisfiedCalled); assertFalse(startCondition.destroyCalled); // stop condition methods if (initialState == ServiceState.RUNNING) { assertTrue(stopCondition.initializeCalled); } else { assertFalse(stopCondition.initializeCalled); } assertTrue(stopCondition.isSatisfiedCalled); assertFalse(stopCondition.destroyCalled); } else if (!serviceFactory.throwExceptionFromDestroy) { // // Normal transition to STOPPED from either STARTING, RUNNING or STOPPING // assertSame(ServiceState.STOPPED, serviceManager.getState()); assertEquals(0, serviceManager.getStartTime()); assertNull(serviceManager.getService()); // verify expected events fired if (initialState != ServiceState.STOPPING) { assertNotNull(serviceMonitor.stopping); } assertNull(serviceMonitor.waitingToStop); assertNull(serviceMonitor.stopError); assertNotNull(serviceMonitor.stopped); assertNull(serviceMonitor.unregistered); // verify events fired in the correct order if (initialState != ServiceState.STOPPING) { assertEquals(serviceMonitor.stopping.getEventId() + 1, serviceMonitor.stopped.getEventId()); } // start condition methods assertFalse(startCondition.initializeCalled); assertFalse(startCondition.isSatisfiedCalled); assertTrue(startCondition.destroyCalled); // stop condition methods if (initialState == ServiceState.STOPPING) { assertFalse(stopCondition.initializeCalled); assertTrue(stopCondition.isSatisfiedCalled); assertTrue(stopCondition.destroyCalled); } else { assertTrue(stopCondition.initializeCalled); assertTrue(stopCondition.isSatisfiedCalled); assertTrue(stopCondition.destroyCalled); } } else { // // Throw an exception from the destroy method // assertEquals(0, serviceManager.getStartTime()); assertNull(serviceManager.getService()); assertSame(ServiceState.STOPPED, serviceManager.getState()); // verify expected events fired if (initialState != ServiceState.STOPPING) { assertNotNull(serviceMonitor.stopping); } assertNull(serviceMonitor.waitingToStop); assertNotNull(serviceMonitor.stopError); assertNotNull(serviceMonitor.stopped); assertNull(serviceMonitor.unregistered); // verify events fired in the correct order if (initialState != ServiceState.STOPPING) { assertEquals(serviceMonitor.stopping.getEventId() + 1, serviceMonitor.stopError.getEventId()); assertEquals(serviceMonitor.stopping.getEventId() + 2, serviceMonitor.stopped.getEventId()); } else { assertEquals(serviceMonitor.stopError.getEventId() + 1, serviceMonitor.stopped.getEventId()); } // verify that the exception is in the reson field assertSame(serviceFactory.destroyException, serviceMonitor.stopError.getCause()); // start condition methods assertFalse(startCondition.initializeCalled); assertFalse(startCondition.isSatisfiedCalled); assertTrue(startCondition.destroyCalled); // stop condition methods if (initialState == ServiceState.RUNNING) { assertTrue(stopCondition.initializeCalled); } else { assertFalse(stopCondition.initializeCalled); } assertTrue(stopCondition.isSatisfiedCalled); assertTrue(stopCondition.destroyCalled); } } |