This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

refactoring

  • Loading branch information...
kryukov committed Nov 2, 2013
1 parent 17d0d6d commit 179f19fa5903f1a697603197e3471216b78d2ece
@@ -35,9 +35,6 @@
import jimm.search.Search;
import jimmui.view.*;
import jimmui.view.base.*;
// #sijapp cond.if modules_ACTIVITYUI is "true"#
import jimmui.view.notify.*;
// #sijapp cond.end#
import jimm.util.JLocale;
import protocol.Protocol;
import protocol.ui.MessageEditor;
@@ -58,10 +55,6 @@

private ChatUpdater chatUpdater = new ChatUpdater();

// #sijapp cond.if modules_ACTIVITYUI is "true"#
private ActivityUI activity;
// #sijapp cond.end#

public PhoneInfo phone = new PhoneInfo();

public final String VERSION = "###VERSION###";
@@ -273,7 +266,7 @@ public void wakeUp() {
}

public static java.io.InputStream getResourceAsStream(String name) {
InputStream in = null;
InputStream in;
// #sijapp cond.if modules_ANDROID is "true" #
in = jimm.modules.fs.FileSystem.openJimmFile(name);
if (null == in) {
@@ -283,7 +276,7 @@ public void wakeUp() {
}
}
// #sijapp cond.else #
in = new Object().getClass().getResourceAsStream(name);
//# in = name.getClass().getResourceAsStream(name);
// #sijapp cond.end #

return in;
@@ -404,11 +397,6 @@ private void initUiPhase4() {
if (null != uiUpdater) uiUpdater.stop();
uiUpdater = new UIUpdater();
uiUpdater.startUIUpdater();
// #sijapp cond.if modules_ACTIVITYUI is "true"#
if (phone.isPhone(PhoneInfo.PHONE_SE) && (750 <= phone.getSeVersion())) {
activity = new ActivityUI();
}
// #sijapp cond.end#
// #sijapp cond.if modules_ANDROID is "true" #
ru.net.jimm.JimmActivity.getInstance().service.started();
// #sijapp cond.end #
@@ -6,6 +6,7 @@
import jimmui.view.roster.items.GroupBranch;
import jimmui.view.roster.items.ProtocolBranch;
import jimmui.updater.RosterUpdater;
import jimmui.view.roster.items.TreeNode;
import protocol.Protocol;
import protocol.Roster;

@@ -20,7 +21,7 @@
*/
public class ChatsModel extends ContactListModel {
@Override
public void buildFlatItems(Vector items) {
public void buildFlatItems(Vector<TreeNode> items) {
Vector<ChatModel> chats = Jimm.getJimm().jimmModel.chats;
for (int i = 0; i < chats.size(); ++i) {
items.addElement(((ChatModel)chats.elementAt(i)).getContact());
@@ -5,6 +5,7 @@
import jimmui.view.roster.items.ProtocolBranch;
import jimmui.updater.RosterUpdater;
import jimm.comm.Util;
import jimmui.view.roster.items.TreeNode;
import protocol.Contact;
import protocol.Protocol;
import protocol.Roster;
@@ -24,7 +25,7 @@
public ContactModel() {
}

public void buildFlatItems(Vector items) {
public void buildFlatItems(Vector<TreeNode> items) {
// build
rebuildContacts(contacts, items);
}
@@ -6,6 +6,7 @@
import jimmui.updater.RosterUpdater;
import jimm.comm.Util;
import jimm.util.JLocale;
import jimmui.view.roster.items.TreeNode;
import protocol.Group;
import protocol.Protocol;
import protocol.Roster;
@@ -29,7 +30,7 @@ public GroupContactModel() {
notInListGroup.setMode(Group.MODE_NONE);
}

public void buildFlatItems(Vector items) {
public void buildFlatItems(Vector<TreeNode> items) {
// build
Vector groups = this.groups;
for (int groupIndex = 0; groupIndex < groups.size(); ++groupIndex) {
@@ -5,6 +5,7 @@
import jimmui.view.roster.ContactListModel;
import jimmui.view.roster.items.GroupBranch;
import jimmui.view.roster.items.ProtocolBranch;
import jimmui.view.roster.items.TreeNode;
import protocol.Protocol;
import protocol.Roster;

@@ -19,9 +20,9 @@
* @author vladimir
*/
public class ProtocolContactModel extends ContactListModel {
private Hashtable protos = new Hashtable();
private Hashtable<Protocol, ProtocolBranch> protos = new Hashtable<Protocol, ProtocolBranch>();

public void buildFlatItems(Vector items) {
public void buildFlatItems(Vector<TreeNode> items) {
final int count = getProtocolCount();
for (int i = 0; i < count; ++i) {
Protocol p = getProtocol(i);
@@ -5,6 +5,7 @@
import jimmui.view.roster.items.GroupBranch;
import jimmui.view.roster.items.ProtocolBranch;
import jimmui.updater.RosterUpdater;
import jimmui.view.roster.items.TreeNode;
import protocol.Group;
import protocol.Protocol;
import protocol.Roster;
@@ -20,9 +21,9 @@
* @author vladimir
*/
public class ProtocolGroupContactModel extends ContactListModel {
private Hashtable protos = new Hashtable();
private Hashtable<Protocol, ProtocolBranch> protos = new Hashtable<Protocol, ProtocolBranch>();

public void buildFlatItems(Vector items) {
public void buildFlatItems(Vector<TreeNode> items) {
final int count = getProtocolCount();
for (int i = 0; i < count; ++i) {
Protocol p = getProtocol(i);
@@ -42,8 +42,8 @@
public void addProtocols(Vector<Protocol> protocols) {
this.protocols = new Protocol[protocols.size()];
protocols.copyInto(this.protocols);
for (int i = 0; i < this.protocols.length; ++i) {
updateProtocol(this.protocols[i], null);
for (Protocol protocol : this.protocols) {
updateProtocol(protocol, null);
}
}
public final void setAlwaysVisibleNode(TreeNode node) {
@@ -71,7 +71,7 @@ Protocol getContactProtocol(Contact c) {
return null;
}

public abstract void buildFlatItems(Vector items);
public abstract void buildFlatItems(Vector<TreeNode> items);

public abstract void updateOrder(RosterUpdater.Update u);

@@ -94,7 +94,7 @@ protected GroupBranch createGroup(Group g) {
group.setMode(g.getMode());
return group;
}
protected final void rebuildGroup(GroupBranch g, boolean show, Vector drawItems) {
protected final void rebuildGroup(GroupBranch g, boolean show, Vector<TreeNode> drawItems) {
if (show || isNotEmpty(g.getContacts())) {
drawItems.addElement(g);
if (g.isExpanded()) {
@@ -112,7 +112,7 @@ private boolean isNotEmpty(Vector contacts) {
}
return false;
}
protected final void rebuildContacts(Vector contacts, Vector drawItems) {
protected final void rebuildContacts(Vector contacts, Vector<TreeNode> drawItems) {
Contact c;
for (int contactIndex = 0; contactIndex < contacts.size(); ++contactIndex) {
c = (Contact)contacts.elementAt(contactIndex);
@@ -131,8 +131,8 @@ protected final void rebuildContacts(Vector contacts, Vector drawItems) {
public abstract ProtocolBranch getProtocolNode(RosterUpdater.Update u);

public boolean hasProtocol(Protocol p) {
for (int i = 0; i < this.protocols.length; ++i) {
if (p == this.protocols[i]) return true;
for (Protocol protocol : this.protocols) {
if (p == protocol) return true;
}
return false;
}
@@ -73,10 +73,10 @@ private boolean startsWith(String what, String with) {
return false;
}

private String ARRAY_FOREACH_TEMPLATE = "for\\s*\\(\\s*(\\w+)\\s+(\\w+)\\s*:\\s*(\\w+)\\s*\\)\\s*\\{\\s*";
private String ARRAY_FOREACH_TEMPLATE = "for\\s*\\(\\s*(\\w+)\\s+(\\w+)\\s*:\\s*((?:\\w+\\.)*\\w+)\\s*\\)\\s*\\{\\s*";
private String J2ME_ARRAY_FOREACH_TEMPLATE = "for (int i_$2 = 0; i_$2 < $3.length; ++i_$2) { $1 $2 = $3[i_$2];";

private String LIST_FOREACH_TEMPLATE = "for\\s*\\(\\s*(\\w+)\\s+(\\w+)\\s*:\\s*(\\w+)\\s*\\)\\s*\\{\\s*";
private String LIST_FOREACH_TEMPLATE = "for\\s*\\(\\s*(\\w+)\\s+(\\w+)\\s*:\\s*((?:\\w+\\.)*\\w+)\\s*\\)\\s*\\{\\s*";
private String J2ME_LIST_FOREACH_TEMPLATE = "for (int i_$2 = 0; i_$2 < $3.size(); ++i_$2) { $1 $2 = $3.get(i_$2);";

private Pattern ARRAY_FOREACH = Pattern.compile(ARRAY_FOREACH_TEMPLATE);

0 comments on commit 179f19f

Please sign in to comment.