You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(32) |
Jul
(39) |
Aug
(1) |
Sep
(55) |
Oct
(117) |
Nov
(112) |
Dec
(118) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(287) |
Feb
(275) |
Mar
(305) |
Apr
|
May
(3) |
Jun
|
Jul
(3) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
2007 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
(4) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <oms...@us...> - 2007-07-21 01:23:34
|
Revision: 990 http://svn.sourceforge.net/azcvsupdater/?rev=990&view=rev Author: omschaub Date: 2007-07-20 18:23:37 -0700 (Fri, 20 Jul 2007) Log Message: ----------- Posting changes so that I can work on rest from home - Completely removing TPC - make sure thread is start(), not run() Modified Paths: -------------- trunk/omschaub/omschaub/stuffer/containers/TotalPeerContainer.java trunk/omschaub/omschaub/stuffer/containers/TotalPeerSetUtils.java trunk/omschaub/omschaub/stuffer/main/BlockIPUtils.java trunk/omschaub/omschaub/stuffer/main/Plugin.java trunk/omschaub/omschaub/stuffer/main/Utils.java Modified: trunk/omschaub/omschaub/stuffer/containers/TotalPeerContainer.java =================================================================== --- trunk/omschaub/omschaub/stuffer/containers/TotalPeerContainer.java 2007-07-20 22:17:22 UTC (rev 989) +++ trunk/omschaub/omschaub/stuffer/containers/TotalPeerContainer.java 2007-07-21 01:23:37 UTC (rev 990) @@ -2,7 +2,7 @@ * Created on Dec 13, 2005 * Created by omschaub * - */ + package omschaub.stuffer.containers; import java.util.Comparator; @@ -14,381 +14,382 @@ public class TotalPeerContainer implements Comparable{ - - private long originalConnectionTime = 0; - private long lastConnectionTime = 0; - private int connectionAttempts = 1; - private int disconnects = 0; - private long uploaded = 0; - private long downloaded = 0; - private int percent = -1; - private int snubs = 0; - private long averageUp = 0; - private long averageDown = 0; - private long discarded = 0; - private IP ip; - private long connectionTimeFromCore = 0; - - - /** - * Initialize the Peer - * @param IP ip - * @param long time - * - */ - public TotalPeerContainer( - IP ip, - long time){ - - this.ip = ip; - this.originalConnectionTime = time; - - } - - - //---SET PARAMETERS--\\ - - /** - * Adds one to the total Disconnects - * - */ - public void setDisconnectsPlusOne(){ - this.disconnects++; - } - - /** - * Adds one to the total Snubs - * - */ - public void setSnubsPlusOne(){ - this.snubs++; - } - - /** - * Adds one to the total Connection Attempts - * - */ - public void setConnectionAttemptsPlusOne(){ - this.connectionAttempts++; - } - - /** - * Adds the given long to the Uploaded - * @param long uploadAmountToAdd - */ - public void setUploaded(long uploadAmountToAdd){ - this.uploaded += uploadAmountToAdd; - } - - /** - * Adds the given long to the Downloaded - * @param long downloadAmountToAdd - */ - public void setDownloaded(long downloadAmountToAdd){ - this.downloaded += downloadAmountToAdd; - } - - /** - * Sets the lastConnectionTime with given long time - * @param time - */ - public void setLastConnectionTime(long time){ - this.lastConnectionTime = time; - } - - /** - * Sets the percent done of the peer - * @param percent - */ - public void setPercentDone(int percent){ - if(this.percent > percent && percent > 900){ - System.out.println("Peer: " + this.ip.getAsString() + " Old Percent: " + this.percent - + " New Percent: " + percent + " FAILED reconnect rule 1!"); - }else if(this.percent > percent){ - //System.out.println(this.percent + " : " + percent); - } - this.percent = percent; - } - - /** - * Sets the averageUp for the peer - * @param averageUp - */ - public void setAverageUp(long averageUp){ - this.averageUp = averageUp; - } - - - /** - * Sets the averageDown for the peer - * @param averageDown - */ - public void setAverageDown(long averageDown){ - this.averageDown = averageDown; - } - - /** - * Increases the total amount discraded by the peer by given long - * @param discarded - */ - public void setAmountDiscarded(long discarded){ - this.discarded += discarded; - } - - public void setAllByPeerStats(PeerStats ps){ - this.uploaded = ps.getTotalSent(); - this.downloaded = ps.getTotalReceived(); - this.averageUp = ps.getUploadAverage(); - this.averageDown = ps.getDownloadAverage(); - this.connectionTimeFromCore = ps.getTimeSinceConnectionEstablished(); - } - - - - //---GET PARAMETERS--\\ - - /** - * Returns the IP of the Peer - * @return IP ip - */ - public IP getIP(){ - return ip; - } - - /** - * Gets the total Disconnects - * @return int disconnects - */ - public int getDisconnects(){ - return this.disconnects; - } - - /** - * Get the total Snubs - * @return int snubs - */ - public int getSnubs(){ - return this.snubs; - } - - /** - * Get the total Connection Attempts - * @return int connectionAttempts - */ - public int getConnectionAttempts(){ - return this.connectionAttempts; - } - - /** - * Gets the Uploaded Amount - * @return long uploaded - */ - public long getUploaded(){ - return this.uploaded; - } - - /** - * Gets the Downloaded Amount - * @return long downloaded - */ - public long getDownloaded(){ - return this.downloaded; - } - - /** - * Gets the original Connection Time - * @return long time - */ - public long getOriginalConnectionTime(){ - return this.originalConnectionTime; - } - - /** - * Gets the Last Connection Time - * @return long lastConnectionTime - */ - public long getLastConnectionTime(){ - return this.lastConnectionTime; - } - - /** - * Gets the total time connected - * @return long (lastConnectionTime - originalConnectionTime) - */ - public long getTotalConnectionTime(){ - if(this.lastConnectionTime != 0){ - return (Plugin.getPluginInterface().getUtilities().getCurrentSystemTime() - this.lastConnectionTime); - }else{ - return (Plugin.getPluginInterface().getUtilities().getCurrentSystemTime() - this.originalConnectionTime); - } - } - - - /** - * Gets the percent done of the peer - * @return int percent - */ - public int getPercentDone(){ - return this.percent; - } - - /** - * Gets the averageUp for the peer - * @return long averageUp - */ - public long getAverageUp(){ - return this.averageUp; - } - - - /** - * Gets the averageDown for the peer - * @return long averageDown - */ - public long getAverageDown(){ - return this.averageDown; - } - - /** - * Returns the total amount discraded by the peer - * @return long discarded - */ - public long getAmountDiscarded(){ - return this.discarded; - } - - /** - * Gets the total connection time as reported by the core - * @return long - */ - public long getPeerConnectionTimeFromCore(){ - return connectionTimeFromCore; - } - - - public String[] getTableItemAsString(){ - - return new String[]{ - ip.getAsString(), - String.valueOf(connectionAttempts), - uploaded>0? String.valueOf(uploaded/1024) + "KB": "N/D", - downloaded>0? String.valueOf(downloaded/1024) + "KB": "N/D", - percent == -1? "N/D" : String.valueOf(Utils.round(((float)percent/10),2)) + "%", - String.valueOf(snubs), - averageUp > 0? String.valueOf(Utils.round(((float)averageUp/1024),2)) + "KB/s" : "N/D", - averageDown > 0 ? String.valueOf(Utils.round(((float)averageDown/1024),2)) + "KB/s" : "N/D", - discarded > 0? String.valueOf(Utils.round((float)discarded/1024,2)) + "KB" : "N/D", - connectionTimeFromCore > 0 ? Utils.getFormattedTime(connectionTimeFromCore/1000) : "Not Connected" }; - } - - //------------Sorters---------\\ - - - /** - * @param dir - * @return a Comparator that sorts by IP in the given order. - */ - public static Comparator getSortByIP (int dir) { - final int direction = dir!=0 ? dir : 1; - return new Comparator() { - public int compare(Object arg0, Object arg1) { - TotalPeerContainer a = (TotalPeerContainer)arg0; - TotalPeerContainer b = (TotalPeerContainer)arg1; - - int result = a.ip.compareTo(b.ip); - if(result == 0){ - result = (int)(a.connectionTimeFromCore - b.connectionTimeFromCore); - } - if(result == 1) result = 1; - return direction * result; - }; - }; - } - - - - //------------RULES------------\\ - //-----------a la Gabe---------\\ - - /** - * Rule 1 -- Reconnect Rule - * @return true if fails the rule - */ - public boolean rule1(long newPercentDone){ - /*if(this.percent > newPercentDone && newPercentDone > 900){ - System.out.println("Peer: " + this.ip.getAsString() + " FAILED reconnect rule 1!"); - return true; - } - - System.out.println("Peer: " + this.ip.getAsString() + " Old Percent: " + this.percent - + " New Percent: " + newPercentDone + " passed reconnect rule 1!"); - - */ - return false; - } - - - /** - * Rule 2 -- Lesser Faked Filesize Rule - * @return true if fails - */ - public boolean rule2(){ - - - - return false; - } - - /** - * Rule 3 - * @return true if fails - */ - public boolean rule3(){ - return false; - } - - /** - * Rule 4 -- Fake Seed Rule - * @return true if fails - */ - public boolean rule4(){ - if(this.percent == 1000){ - - } - - - return false; - } - - - /** - * Rule 5 - * @return true if fails - */ - public boolean rule5(){ - return false; - } - - /** - * Rule 6 - * @return true if fails - */ - public boolean rule6(){ - return false; - } - - /** - * Rule 7 - * @return true if fails - */ - public boolean rule7(){ - return false; - } + private long originalConnectionTime = 0; + private long lastConnectionTime = 0; + private int connectionAttempts = 1; + private int disconnects = 0; + private long uploaded = 0; + private long downloaded = 0; + private int percent = -1; + private int snubs = 0; + private long averageUp = 0; + private long averageDown = 0; + private long discarded = 0; + private IP ip; + private long connectionTimeFromCore = 0; - public int compareTo(Object arg0) { - // TODO Auto-generated method stub - return 0; - } - + + *//** + * Initialize the Peer + * @param IP ip + * @param long time + * + *//* + public TotalPeerContainer( + IP ip, + long time){ + + this.ip = ip; + this.originalConnectionTime = time; + + } + + + //---SET PARAMETERS--\\ + + *//** + * Adds one to the total Disconnects + * + *//* + public void setDisconnectsPlusOne(){ + this.disconnects++; + } + + *//** + * Adds one to the total Snubs + * + *//* + public void setSnubsPlusOne(){ + this.snubs++; + } + + *//** + * Adds one to the total Connection Attempts + * + *//* + public void setConnectionAttemptsPlusOne(){ + this.connectionAttempts++; + } + + *//** + * Adds the given long to the Uploaded + * @param long uploadAmountToAdd + *//* + public void setUploaded(long uploadAmountToAdd){ + this.uploaded += uploadAmountToAdd; + } + + *//** + * Adds the given long to the Downloaded + * @param long downloadAmountToAdd + *//* + public void setDownloaded(long downloadAmountToAdd){ + this.downloaded += downloadAmountToAdd; + } + + *//** + * Sets the lastConnectionTime with given long time + * @param time + *//* + public void setLastConnectionTime(long time){ + this.lastConnectionTime = time; + } + + *//** + * Sets the percent done of the peer + * @param percent + *//* + public void setPercentDone(int percent){ + if(this.percent > percent && percent > 900){ + System.out.println("Peer: " + this.ip.getAsString() + " Old Percent: " + this.percent + + " New Percent: " + percent + " FAILED reconnect rule 1!"); + }else if(this.percent > percent){ + //System.out.println(this.percent + " : " + percent); + } + this.percent = percent; + } + + *//** + * Sets the averageUp for the peer + * @param averageUp + *//* + public void setAverageUp(long averageUp){ + this.averageUp = averageUp; + } + + + *//** + * Sets the averageDown for the peer + * @param averageDown + *//* + public void setAverageDown(long averageDown){ + this.averageDown = averageDown; + } + + *//** + * Increases the total amount discraded by the peer by given long + * @param discarded + *//* + public void setAmountDiscarded(long discarded){ + this.discarded += discarded; + } + + public void setAllByPeerStats(PeerStats ps){ + this.uploaded = ps.getTotalSent(); + this.downloaded = ps.getTotalReceived(); + this.averageUp = ps.getUploadAverage(); + this.averageDown = ps.getDownloadAverage(); + this.connectionTimeFromCore = ps.getTimeSinceConnectionEstablished(); + } + + + + //---GET PARAMETERS--\\ + + *//** + * Returns the IP of the Peer + * @return IP ip + *//* + public IP getIP(){ + return ip; + } + + *//** + * Gets the total Disconnects + * @return int disconnects + *//* + public int getDisconnects(){ + return this.disconnects; + } + + *//** + * Get the total Snubs + * @return int snubs + *//* + public int getSnubs(){ + return this.snubs; + } + + *//** + * Get the total Connection Attempts + * @return int connectionAttempts + *//* + public int getConnectionAttempts(){ + return this.connectionAttempts; + } + + *//** + * Gets the Uploaded Amount + * @return long uploaded + *//* + public long getUploaded(){ + return this.uploaded; + } + + *//** + * Gets the Downloaded Amount + * @return long downloaded + *//* + public long getDownloaded(){ + return this.downloaded; + } + + *//** + * Gets the original Connection Time + * @return long time + *//* + public long getOriginalConnectionTime(){ + return this.originalConnectionTime; + } + + *//** + * Gets the Last Connection Time + * @return long lastConnectionTime + *//* + public long getLastConnectionTime(){ + return this.lastConnectionTime; + } + + *//** + * Gets the total time connected + * @return long (lastConnectionTime - originalConnectionTime) + *//* + public long getTotalConnectionTime(){ + if(this.lastConnectionTime != 0){ + return (Plugin.getPluginInterface().getUtilities().getCurrentSystemTime() - this.lastConnectionTime); + }else{ + return (Plugin.getPluginInterface().getUtilities().getCurrentSystemTime() - this.originalConnectionTime); + } + } + + + *//** + * Gets the percent done of the peer + * @return int percent + *//* + public int getPercentDone(){ + return this.percent; + } + + *//** + * Gets the averageUp for the peer + * @return long averageUp + *//* + public long getAverageUp(){ + return this.averageUp; + } + + + *//** + * Gets the averageDown for the peer + * @return long averageDown + *//* + public long getAverageDown(){ + return this.averageDown; + } + + *//** + * Returns the total amount discraded by the peer + * @return long discarded + *//* + public long getAmountDiscarded(){ + return this.discarded; + } + + *//** + * Gets the total connection time as reported by the core + * @return long + *//* + public long getPeerConnectionTimeFromCore(){ + return connectionTimeFromCore; + } + + + public String[] getTableItemAsString(){ + + return new String[]{ + ip.getAsString(), + String.valueOf(connectionAttempts), + uploaded>0? String.valueOf(uploaded/1024) + "KB": "N/D", + downloaded>0? String.valueOf(downloaded/1024) + "KB": "N/D", + percent == -1? "N/D" : String.valueOf(Utils.round(((float)percent/10),2)) + "%", + String.valueOf(snubs), + averageUp > 0? String.valueOf(Utils.round(((float)averageUp/1024),2)) + "KB/s" : "N/D", + averageDown > 0 ? String.valueOf(Utils.round(((float)averageDown/1024),2)) + "KB/s" : "N/D", + discarded > 0? String.valueOf(Utils.round((float)discarded/1024,2)) + "KB" : "N/D", + connectionTimeFromCore > 0 ? Utils.getFormattedTime(connectionTimeFromCore/1000) : "Not Connected" }; + } + + //------------Sorters---------\\ + + + *//** + * @param dir + * @return a Comparator that sorts by IP in the given order. + *//* + public static Comparator getSortByIP (int dir) { + final int direction = dir!=0 ? dir : 1; + return new Comparator() { + public int compare(Object arg0, Object arg1) { + TotalPeerContainer a = (TotalPeerContainer)arg0; + TotalPeerContainer b = (TotalPeerContainer)arg1; + + int result = a.ip.compareTo(b.ip); + if(result == 0){ + result = (int)(a.connectionTimeFromCore - b.connectionTimeFromCore); + } + if(result == 1) result = 1; + return direction * result; + }; + }; + } + + + + //------------RULES------------\\ + //-----------a la Gabe---------\\ + + *//** + * Rule 1 -- Reconnect Rule + * @return true if fails the rule + *//* + public boolean rule1(long newPercentDone){ + if(this.percent > newPercentDone && newPercentDone > 900){ + System.out.println("Peer: " + this.ip.getAsString() + " FAILED reconnect rule 1!"); + return true; + } + + System.out.println("Peer: " + this.ip.getAsString() + " Old Percent: " + this.percent + + " New Percent: " + newPercentDone + " passed reconnect rule 1!"); + + + return false; + } + + + *//** + * Rule 2 -- Lesser Faked Filesize Rule + * @return true if fails + *//* + public boolean rule2(){ + + + + return false; + } + + *//** + * Rule 3 + * @return true if fails + *//* + public boolean rule3(){ + return false; + } + + *//** + * Rule 4 -- Fake Seed Rule + * @return true if fails + *//* + public boolean rule4(){ + if(this.percent == 1000){ + + } + + + return false; + } + + + *//** + * Rule 5 + * @return true if fails + *//* + public boolean rule5(){ + return false; + } + + *//** + * Rule 6 + * @return true if fails + *//* + public boolean rule6(){ + return false; + } + + *//** + * Rule 7 + * @return true if fails + *//* + public boolean rule7(){ + return false; + } + + + public int compareTo(Object arg0) { + // TODO Auto-generated method stub + return 0; + } + }//EOF +*/ \ No newline at end of file Modified: trunk/omschaub/omschaub/stuffer/containers/TotalPeerSetUtils.java =================================================================== --- trunk/omschaub/omschaub/stuffer/containers/TotalPeerSetUtils.java 2007-07-20 22:17:22 UTC (rev 989) +++ trunk/omschaub/omschaub/stuffer/containers/TotalPeerSetUtils.java 2007-07-21 01:23:37 UTC (rev 990) @@ -2,7 +2,7 @@ * Created on Dec 15, 2005 * Created by omschaub * - */ + package omschaub.stuffer.containers; import java.util.Arrays; @@ -19,98 +19,99 @@ public class TotalPeerSetUtils { - - private SortedMap map; - private Set set; - /** - * Initialize the set - * - */ - public TotalPeerSetUtils(){ - map = new TreeMap(new Comparator() - { - public int - compare( - Object arg0, - Object arg1 ) - { - IP o1 = new IP((String)arg0); - IP o2 = new IP((String)arg1); - - int result = o1.compareTo(o2); - - if(result == 0) return 0; - else if (result > 0) return 1; - else return -1; - } - }); - set = map.entrySet(); - - } - - /** - * Adds the totalPeerContainer to the Hashtable by key "ip" - * @param totalPeerContainer - */ - public void addToMap(TotalPeerContainer totalPeerContainer){ - map.put(totalPeerContainer.getIP().getAsString(), totalPeerContainer); - } - - - /** - * Sees if given IP is already present in the set - * @param ip - * @return boolean - */ - public boolean isPresent(IP ip){ - return map.containsKey(ip.getAsString()); - } - - /** - * Gets the TotalPeerContainer based on given IP - * @param ip - * @return - */ - public TotalPeerContainer getTotalPeerContainer(IP ip){ - return (TotalPeerContainer)map.get(ip.getAsString()); - } - - /** - * Obtain all of the TotalPeerContainers from the SET - * @return TotalPeerConatiner[] - */ - public TotalPeerContainer[] getAllTotalPeerContainers(){ - return (TotalPeerContainer[])map.values().toArray((new TotalPeerContainer[map.size()])); - } - - public TotalPeerContainer[] getAllTotalPeerContainer_FromSET(){ - System.out.println(set.size()); - return(TotalPeerContainer[])map.entrySet().toArray(new TotalPeerContainer[set.size()]); - - } - - /** - * Returns the TOTAL Size of the set - * @return - */ - public int getSize(){ - return map.size(); - } - -/* public Listener sortByIP(){ - Listener sortListener = new Listener() { - public void handleEvent(Event e) { - - Constants.TABLE1_IP_SORT = Constants.TABLE1_IP_SORT ? false : true; - TotalPeerContainer[] tpc = getAllTotalPeerContainers(); - Arrays.sort(tpc,TotalPeerContainer.getSortByIP(1)); - //set. - - - Plugin.getTab3().resetTable(); - } - }; - return sortListener; - }*/ - + + private SortedMap map; + private Set set; + *//** + * Initialize the set + * + *//* + public TotalPeerSetUtils(){ + map = new TreeMap(new Comparator() + { + public int + compare( + Object arg0, + Object arg1 ) + { + IP o1 = new IP((String)arg0); + IP o2 = new IP((String)arg1); + + int result = o1.compareTo(o2); + + if(result == 0) return 0; + else if (result > 0) return 1; + else return -1; + } + }); + set = map.entrySet(); + + } + + *//** + * Adds the totalPeerContainer to the Hashtable by key "ip" + * @param totalPeerContainer + *//* + public void addToMap(TotalPeerContainer totalPeerContainer){ + map.put(totalPeerContainer.getIP().getAsString(), totalPeerContainer); + } + + + *//** + * Sees if given IP is already present in the set + * @param ip + * @return boolean + *//* + public boolean isPresent(IP ip){ + return map.containsKey(ip.getAsString()); + } + + *//** + * Gets the TotalPeerContainer based on given IP + * @param ip + * @return + *//* + public TotalPeerContainer getTotalPeerContainer(IP ip){ + return (TotalPeerContainer)map.get(ip.getAsString()); + } + + *//** + * Obtain all of the TotalPeerContainers from the SET + * @return TotalPeerConatiner[] + *//* + public TotalPeerContainer[] getAllTotalPeerContainers(){ + return (TotalPeerContainer[])map.values().toArray((new TotalPeerContainer[map.size()])); + } + + public TotalPeerContainer[] getAllTotalPeerContainer_FromSET(){ + System.out.println(set.size()); + return(TotalPeerContainer[])map.entrySet().toArray(new TotalPeerContainer[set.size()]); + + } + + *//** + * Returns the TOTAL Size of the set + * @return + *//* + public int getSize(){ + return map.size(); + } + + public Listener sortByIP(){ + Listener sortListener = new Listener() { + public void handleEvent(Event e) { + + Constants.TABLE1_IP_SORT = Constants.TABLE1_IP_SORT ? false : true; + TotalPeerContainer[] tpc = getAllTotalPeerContainers(); + Arrays.sort(tpc,TotalPeerContainer.getSortByIP(1)); + //set. + + + Plugin.getTab3().resetTable(); + } + }; + return sortListener; + } + } +*/ \ No newline at end of file Modified: trunk/omschaub/omschaub/stuffer/main/BlockIPUtils.java =================================================================== --- trunk/omschaub/omschaub/stuffer/main/BlockIPUtils.java 2007-07-20 22:17:22 UTC (rev 989) +++ trunk/omschaub/omschaub/stuffer/main/BlockIPUtils.java 2007-07-21 01:23:37 UTC (rev 990) @@ -11,7 +11,7 @@ import omschaub.stuffer.containers.ClientBlock; import omschaub.stuffer.containers.IP; -import omschaub.stuffer.containers.TotalPeerContainer; +//import omschaub.stuffer.containers.TotalPeerContainer; import org.eclipse.swt.graphics.RGB; import org.gudy.azureus2.plugins.PluginInterface; @@ -30,147 +30,148 @@ import org.gudy.azureus2.pluginsimpl.local.ipfilter.IPFilterImpl; public class BlockIPUtils { - private static int total30; + private static int total30; - public static void startMainClientCheck(){ + public static void startMainClientCheck(){ - try{ + try{ - final PluginInterface pluginInterface = Plugin.getPluginInterface(); + final PluginInterface pluginInterface = Plugin.getPluginInterface(); - DownloadManager dm = pluginInterface.getDownloadManager(); + DownloadManager dm = pluginInterface.getDownloadManager(); - //Setting up the main listener - final PeerManagerListener pml = new PeerManagerListener() - { - public void - peerAdded( - final PeerManager manager, - final Peer peer ) - { + //Setting up the main listener + final PeerManagerListener pml = new PeerManagerListener() + { + public void + peerAdded( + final PeerManager manager, + final Peer peer ) + { - IP peerIP = new IP(peer.getIp()); - if(!Plugin.totalPeer_set.isPresent(peerIP)){ - TotalPeerContainer tpc = new TotalPeerContainer(peerIP,Plugin.getPluginInterface().getUtilities().getCurrentSystemTime()); - Plugin.totalPeer_set.addToMap(tpc); - }else{ - TotalPeerContainer tpc = Plugin.totalPeer_set.getTotalPeerContainer(peerIP); - tpc.setConnectionAttemptsPlusOne(); - tpc.setLastConnectionTime(Plugin.getPluginInterface().getUtilities().getCurrentSystemTime()); - /*if(tpc.rule1(peer.getPercentDoneInThousandNotation())){ - try { - makeIPFilterRule(peer.getIp(),getPeerID(peer.getId()),peer.getClient(),manager.getDownload().getName(),"r255,g255,b255"); - } catch (DownloadException e) { - e.printStackTrace(); - } - }*/ - } + IP peerIP = new IP(peer.getIp()); +/* if(!Plugin.totalPeer_set.isPresent(peerIP)){ + TotalPeerContainer tpc = new TotalPeerContainer(peerIP,Plugin.getPluginInterface().getUtilities().getCurrentSystemTime()); + Plugin.totalPeer_set.addToMap(tpc); + }else{ + TotalPeerContainer tpc = Plugin.totalPeer_set.getTotalPeerContainer(peerIP); + tpc.setConnectionAttemptsPlusOne(); + tpc.setLastConnectionTime(Plugin.getPluginInterface().getUtilities().getCurrentSystemTime()); + if(tpc.rule1(peer.getPercentDoneInThousandNotation())){ + try { + makeIPFilterRule(peer.getIp(),getPeerID(peer.getId()),peer.getClient(),manager.getDownload().getName(),"r255,g255,b255"); + } catch (DownloadException e) { + e.printStackTrace(); + } + } + } +*/ + peer.addListener(new PeerListener2(){ + public void eventOccurred(PeerEvent event) { - peer.addListener(new PeerListener2(){ - public void eventOccurred(PeerEvent event) { + if(event.getType() == PeerEvent.ET_STATE_CHANGED){ + if(Plugin.areRulesPaused) return; + if(((Integer)event.getData()).intValue() == Peer.TRANSFERING){ + try{ + if(Plugin.getPluginInterface().getPluginconfig().getPluginBooleanParameter("Stuffer_Block_Seeder",false)){ + System.out.println(" % done: " + peer.getPercentDoneInThousandNotation()); + if(peer.isSeed() || peer.getPercentDoneInThousandNotation() == 1000){ + //System.out.println(" % done: " + peer.getPercentDoneInThousandNotation()); + String color = Plugin.getPluginInterface().getPluginconfig().getPluginStringParameter("Stuffer_Block_Seeder_Color","r255g0b0"); + //System.out.println("Seeder Color: " + color); + if(!color.equalsIgnoreCase("null")){ + String peerID = getPeerID(peer.getId()); + String clientName = peer.getClient(); + // peer.setSnubbed(true); + makeIPFilterRule(peer.getIp(),"Seeder: " + peerID,clientName + " Seeder",manager.getDownload().getName(), color); + Constants.SEEDER_CLIENT_BLOCKS++; + Plugin.getTab2().renumberMOD_Seeder(false, true); + } + } + } - if(event.getType() == PeerEvent.ET_STATE_CHANGED){ - if(Plugin.areRulesPaused) return; - if(((Integer)event.getData()).intValue() == Peer.TRANSFERING){ - try{ - if(Plugin.getPluginInterface().getPluginconfig().getPluginBooleanParameter("Stuffer_Block_Seeder",false)){ - System.out.println(" % done: " + peer.getPercentDoneInThousandNotation()); - if(peer.isSeed() || peer.getPercentDoneInThousandNotation() == 1000){ - //System.out.println(" % done: " + peer.getPercentDoneInThousandNotation()); - String color = Plugin.getPluginInterface().getPluginconfig().getPluginStringParameter("Stuffer_Block_Seeder_Color","r255g0b0"); - //System.out.println("Seeder Color: " + color); - if(!color.equalsIgnoreCase("null")){ - String peerID = getPeerID(peer.getId()); - String clientName = peer.getClient(); - // peer.setSnubbed(true); - makeIPFilterRule(peer.getIp(),"Seeder: " + peerID,clientName + " Seeder",manager.getDownload().getName(), color); - Constants.SEEDER_CLIENT_BLOCKS++; - Plugin.getTab2().renumberMOD_Seeder(false, true); - } - } - } + if(Plugin.getPluginInterface().getPluginconfig().getPluginBooleanParameter("Stuffer_Block_Mods",true)){ + Pattern p = Pattern.compile("Azureus (?:[^0-2]|[^01]\\.[^0-2]|[^01]\\.[^01]\\.[^0]|[^01]\\.[^01]\\.[\\d]\\.[^0-2])"); + Matcher m = p.matcher(peer.getClient()); - if(Plugin.getPluginInterface().getPluginconfig().getPluginBooleanParameter("Stuffer_Block_Mods",true)){ - Pattern p = Pattern.compile("Azureus (?:[^0-2]|[^01]\\.[^0-2]|[^01]\\.[^01]\\.[^0]|[^01]\\.[^01]\\.[\\d]\\.[^0-2])"); - Matcher m = p.matcher(peer.getClient()); + if(m.find()){ + //System.out.println("Inside RegEx Expression: " + peer.getClient()); + if(!peer.supportsMessaging()){ + String clientName = peer.getClient(); - if(m.find()){ - //System.out.println("Inside RegEx Expression: " + peer.getClient()); - if(!peer.supportsMessaging()){ - String clientName = peer.getClient(); + System.out.println("Found MOD client " + clientName + " : " + peer.getIp() + " at " + Utils.getCurrentTime()); - System.out.println("Found MOD client " + clientName + " : " + peer.getIp() + " at " + Utils.getCurrentTime()); + try { + if(manager != null){ + String color = Plugin.getPluginInterface().getPluginconfig().getPluginStringParameter("Stuffer_Block_Mods_Color","r255g0b0"); + //String peerID = Plugin.getPluginInterface().getUtilities().getFormatters().encodeBytesToString(peer.getId()); + if(!color.equalsIgnoreCase("null")){ + String peerID = getPeerID(peer.getId()); + // peer.setSnubbed(true); + makeIPFilterRule(peer.getIp(),"MOD: " + peerID,clientName + " MOD",manager.getDownload().getName(), color); + Constants.MOD_CLIENT_BLOCKS++; + Plugin.getTab2().renumberMOD_Seeder(true,false); + } + } + } catch (DownloadException e) { + e.printStackTrace(); + } + } + } + } + }catch(Exception e){ + e.printStackTrace(); + } - try { - if(manager != null){ - String color = Plugin.getPluginInterface().getPluginconfig().getPluginStringParameter("Stuffer_Block_Mods_Color","r255g0b0"); - //String peerID = Plugin.getPluginInterface().getUtilities().getFormatters().encodeBytesToString(peer.getId()); - if(!color.equalsIgnoreCase("null")){ - String peerID = getPeerID(peer.getId()); - // peer.setSnubbed(true); - makeIPFilterRule(peer.getIp(),"MOD: " + peerID,clientName + " MOD",manager.getDownload().getName(), color); - Constants.MOD_CLIENT_BLOCKS++; - Plugin.getTab2().renumberMOD_Seeder(true,false); - } - } - } catch (DownloadException e) { - e.printStackTrace(); - } - } - } - } - }catch(Exception e){ - e.printStackTrace(); - } + try { + if(manager != null){ + String clientName = peer.getClient(); + String color = mainRuleRun(clientName,manager.isSuperSeeding(), manager.getDownload().getState()); + if(!color.equalsIgnoreCase("null")){ + String peerID = getPeerID(peer.getId()); + /*String peerID; + try { + peerID = new String(peer.getId(),"ISO-8859-1"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + peerID = "Normal Peer"; + }*/ + //String peerID = Plugin.getPluginInterface().getUtilities().getFormatters().encodeBytesToString(peer.getId()); + //peer.setSnubbed(true); + makeIPFilterRule(peer.getIp(),peerID,clientName,manager.getDownload().getName(), color); + } + } + } catch (DownloadException e) { + e.printStackTrace(); + } + } + }else if(event.getType() == PeerEvent.ET_BAD_CHUNK){ + System.out.println(" sentBadChunk listener has been triggered by " + peer.getIp() + " : " + peer.getClient()); + /*if(arg1 >= 1){ + System.out.println("Peer has sent a bad chunk: " + peer.getClient() + peer.getIp()); + if(Plugin.getPluginInterface().getPluginconfig().getPluginBooleanParameter("Stuffer_Block_Bad",true)){ + try { + String color = Plugin.getPluginInterface().getPluginconfig().getPluginStringParameter("Stuffer_Block_Bad_Color","r0g255b0"); + if(!color.equalsIgnoreCase("null")){ - try { - if(manager != null){ - String clientName = peer.getClient(); - String color = mainRuleRun(clientName,manager.isSuperSeeding(), manager.getDownload().getState()); - if(!color.equalsIgnoreCase("null")){ - String peerID = getPeerID(peer.getId()); - /*String peerID; - try { - peerID = new String(peer.getId(),"ISO-8859-1"); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - peerID = "Normal Peer"; - }*/ - //String peerID = Plugin.getPluginInterface().getUtilities().getFormatters().encodeBytesToString(peer.getId()); - //peer.setSnubbed(true); - makeIPFilterRule(peer.getIp(),peerID,clientName,manager.getDownload().getName(), color); - } - } - } catch (DownloadException e) { - e.printStackTrace(); - } - } - }else if(event.getType() == PeerEvent.ET_BAD_CHUNK){ - System.out.println(" sentBadChunk listener has been triggered by " + peer.getIp() + " : " + peer.getClient()); - /*if(arg1 >= 1){ - System.out.println("Peer has sent a bad chunk: " + peer.getClient() + peer.getIp()); - if(Plugin.getPluginInterface().getPluginconfig().getPluginBooleanParameter("Stuffer_Block_Bad",true)){ - try { - String color = Plugin.getPluginInterface().getPluginconfig().getPluginStringParameter("Stuffer_Block_Bad_Color","r0g255b0"); - if(!color.equalsIgnoreCase("null")){ + makeIPFilterRule(peer.getIp(),"Bad Data Peer",peer.getClient(),manager.getDownload().getName(), color); + Constants.BAD_CLIENT_BLOCKS++; + Tab2Utilities.renumberMOD_BAD(false,true); + } + } catch (DownloadException e) { - makeIPFilterRule(peer.getIp(),"Bad Data Peer",peer.getClient(),manager.getDownload().getName(), color); - Constants.BAD_CLIENT_BLOCKS++; - Tab2Utilities.renumberMOD_BAD(false,true); - } - } catch (DownloadException e) { + e.printStackTrace(); + } + } + }*/ - e.printStackTrace(); - } - } - }*/ + } - } @@ -182,364 +183,363 @@ + }//End of Event Occurred - }//End of Event Occurred + }); - }); + } - } + public void + peerRemoved( + PeerManager manager, + Peer peer ) + { + IP peerIP = new IP(peer.getIp()); +/* TotalPeerContainer tpc = Plugin.totalPeer_set.getTotalPeerContainer(peerIP); + if(tpc != null){ + tpc.setDisconnectsPlusOne(); + tpc.setPercentDone(peer.getPercentDoneInThousandNotation()); + }*/ - public void - peerRemoved( - PeerManager manager, - Peer peer ) - { - IP peerIP = new IP(peer.getIp()); - TotalPeerContainer tpc = Plugin.totalPeer_set.getTotalPeerContainer(peerIP); - if(tpc != null){ - tpc.setDisconnectsPlusOne(); - tpc.setPercentDone(peer.getPercentDoneInThousandNotation()); - } + if(peer != null){ - if(peer != null){ + if(peer.getState() != 50){ + total30++; + System.out.println("peer: " + peer.getIp() + " State: " + peer.getState() + " Total: " + total30); - if(peer.getState() != 50){ - total30++; - System.out.println("peer: " + peer.getIp() + " State: " + peer.getState() + " Total: " + total30); + } - } + } - } + } + }; + dm.addListener( + new DownloadManagerListener() + { + public void + downloadAdded( + final Download download ) + { - } - }; - dm.addListener( - new DownloadManagerListener() - { - public void - downloadAdded( - final Download download ) - { + download.addPeerListener( + new DownloadPeerListener() + { + public void + peerManagerAdded( + Download download, + final PeerManager peer_manager ) + { + peer_manager.addListener(pml); - download.addPeerListener( - new DownloadPeerListener() - { - public void - peerManagerAdded( - Download download, - final PeerManager peer_manager ) - { - peer_manager.addListener(pml); + } - } + public void + peerManagerRemoved( + Download download, + PeerManager peer_manager ) + { + peer_manager.removeListener(pml); + } + }); + } + public void + downloadRemoved( + Download download ) + { - public void - peerManagerRemoved( - Download download, - PeerManager peer_manager ) - { - peer_manager.removeListener(pml); - } - }); - } - public void - downloadRemoved( - Download download ) - { + } + }); - } - }); + }catch( Throwable e ){ - }catch( Throwable e ){ + e.printStackTrace(); + } - e.printStackTrace(); - } + } - } + /** + * Main method to make a IPFilter rule and report it to the GUI if it is running + * **Be sure to snub the peer BEFORE entering this code! + * + * @param peerIP + * @param peerID + * @param peerClient + * @param downloadName + * @param color + */ + public static void makeIPFilterRule(final String peerIP, + final String peerID, + final String peerClient, + final String downloadName, + final String color){ - /** - * Main method to make a IPFilter rule and report it to the GUI if it is running - * **Be sure to snub the peer BEFORE entering this code! - * - * @param peerIP - * @param peerID - * @param peerClient - * @param downloadName - * @param color - */ - public static void makeIPFilterRule(final String peerIP, - final String peerID, - final String peerClient, - final String downloadName, - final String color){ + Thread makeFilter = new Thread() { + public void run() { + try{ + IPFilter ipf = new IPFilterImpl(); + RGB rgb = Utils.getRGB(color); + if (!ipf.isInRange(peerIP)){ + //peer.setSnubbed(true); + //System.out.println(Utils.parseString(peerID) + " : Blocked -- Peer: " + peerClient); + IPRange ipr = Plugin.getPluginInterface().getIPFilter().createRange(true); + ipr.setStartIP(peerIP); + ipr.setEndIP(peerIP); + ipr.setDescription("Stuffer - " + Utils.parseString(peerClient) + " Killed"+ " c#" + Utils.getHexfromRGB(rgb)); + ipr.checkValid(); + ipf.addRange(ipr); + if(Plugin.getTab1() != null){ + Plugin.getTab1().addElement(peerIP,peerID,peerClient,downloadName, color); + Plugin.getTab1().totalChange(); + } - Thread makeFilter = new Thread() { - public void run() { - try{ - IPFilter ipf = new IPFilterImpl(); - RGB rgb = Utils.getRGB(color); - if (!ipf.isInRange(peerIP)){ - //peer.setSnubbed(true); - //System.out.println(Utils.parseString(peerID) + " : Blocked -- Peer: " + peerClient); - IPRange ipr = Plugin.getPluginInterface().getIPFilter().createRange(true); - ipr.setStartIP(peerIP); - ipr.setEndIP(peerIP); - ipr.setDescription("Stuffer - " + Utils.parseString(peerClient) + " Killed"+ " c#" + Utils.getHexfromRGB(rgb)); - ipr.checkValid(); - ipf.addRange(ipr); - if(Plugin.getTab1() != null){ - Plugin.getTab1().addElement(peerIP,peerID,peerClient,downloadName, color); - Plugin.getTab1().totalChange(); - } + } - } + }catch(Exception e){ + e.printStackTrace(); + } + } + }; + makeFilter.setDaemon(true); + makeFilter.start(); - }catch(Exception e){ - e.printStackTrace(); - } - } - }; - makeFilter.setDaemon(true); - makeFilter.run(); + } - } + /** + * Parse out the nasty stuff from the PeerID and return a nice human readable string + * @param peerBytes + * @return + * @throws UnsupportedEncodingException + */ + public static String getPeerID (byte[] peerBytes){ + for (int i = 0; i < peerBytes.length; i++) { + int b = (0xFF & peerBytes[i]); + if (b < 32 || b > 127) + peerBytes[i] = '-'; + } - /** - * Parse out the nasty stuff from the PeerID and return a nice human readable string - * @param peerBytes - * @return - * @throws UnsupportedEncodingException - */ - public static String getPeerID (byte[] peerBytes){ - for (int i = 0; i < peerBytes.length; i++) { - int b = (0xFF & peerBytes[i]); - if (b < 32 || b > 127) - peerBytes[i] = '-'; - } + String peerID; + try { + //peerID = new String(peerBytes,"ISO-8859-1"); + peerID = new String(peerBytes); + return peerID; + } catch (Exception e) { + e.printStackTrace(); + return "Error Parsing ID"; + } - String peerID; - try { - //peerID = new String(peerBytes,"ISO-8859-1"); - peerID = new String(peerBytes); - return peerID; - } catch (Exception e) { - e.printStackTrace(); - return "Error Parsing ID"; - } + } - } + /** + * Main Rule Run.. it will test all the rules from the clientList + * @param peerClientID + * @param downloadName + * @param isSuperSeeding + * @param downloadState + */ + public static String mainRuleRun(final String peerClient, + final boolean isSuperSeeding, + final int downloadState){ - /** - * Main Rule Run.. it will test all the rules from the clientList - * @param peerClientID - * @param downloadName - * @param isSuperSeeding - * @param downloadState - */ - public static String mainRuleRun(final String peerClient, - final boolean isSuperSeeding, - final int downloadState){ + if(Plugin.areRulesPaused) + return "null"; - if(Plugin.areRulesPaused) - return "null"; + try{ + Iterator it = Plugin.clientBlock_set.getIterator(); + //System.out.println(Plugin.clientBlock_set.getSize()); + while(it.hasNext()){ + ClientBlock cb = (ClientBlock)it.next(); - try{ - Iterator it = Plugin.clientBlock_set.getIterator(); - //System.out.println(Plugin.clientBlock_set.getSize()); - while(it.hasNext()){ - ClientBlock cb = (ClientBlock)it.next(); + //check if the clientName is RegEx or not + if(!cb.get_isRegEx()){ + //is Regular String + if(stringContains(peerClient.toLowerCase(),cb.getClientName().toLowerCase())){ + //match.. so block according to the rules - //check if the clientName is RegEx or not - if(!cb.get_isRegEx()){ - //is Regular String - if(stringContains(peerClient.toLowerCase(),cb.getClientName().toLowerCase())){ - //match.. so block according to the rules + //check for superseeding block + if(cb.get_isSuperseeding()){ + //positive for superseeding only.. now check if torrent is superseeding + if(isSuperSeeding){ + Utils.changeHits(cb.getIndex(), 1); + return cb.getColor(); + //makeIPFilterRule(peerIP,peerID,peerClient,downloadName,clientList[i][6]); + } + return "null"; + }else{ + //check for rule for download/upload - //check for superseeding block - if(cb.get_isSuperseeding()){ - //positive for superseeding only.. now check if torrent is superseeding - if(isSuperSeeding){ - Utils.changeHits(cb.getIndex(), 1); - return cb.getColor(); - //makeIPFilterRule(peerIP,peerID,peerClient,downloadName,clientList[i][6]); - } - return "null"; - }else{ - //check for rule for download/upload + //first see if both are postive, and if so, block the peer out right + if(cb.get_isDownloading() && cb.get_isUploading()){ + //both positive, so block away + //makeIPFilterRule(peerIP,peerID,peerClient,downloadName,clientList[i][6]); + Utils.changeHits(cb.getIndex(), 1); + return cb.getColor(); + }else{ + //both are not positve.. so need to step through and see which one is - //first see if both are postive, and if so, block the peer out right - if(cb.get_isDownloading() && cb.get_isUploading()){ - //both positive, so block away - //makeIPFilterRule(peerIP,peerID,peerClient,downloadName,clientList[i][6]); - Utils.changeHits(cb.getIndex(), 1); - return cb.getColor(); - }else{ - //both are not positve.. so need to step through and see which one is + try { - try { + if(downloadState == Download.ST_DOWNLOADING){ + //torrent of peer is downloading + //now see if the rule is there to block it + if(cb.get_isDownloading()){ + //positive for the rule, so block + //makeIPFilterRule(peerIP,peerID,peerClient,downloadName,clientList[i][6]); + Utils.changeHits(cb.getIndex(), 1); + return cb.getColor(); + } + return "null"; + }else if(downloadState == Download.ST_SEEDING){ + //torrent of peer is seeding + //now see if the rule is there to block it + if(cb.get_isUploading()){ + //positve for the rule,so block + //makeIPFilterRule(peerIP,peerID,peerClient,downloadName,clientList[i][6]); + Utils.changeHits(cb.getIndex(), 1); + return cb.getColor(); + } + return "null"; + }else{ + return "null"; + } - if(downloadState == Download.ST_DOWNLOADING){ - //torrent of peer is downloading - //now see if the rule is there to block it - if(cb.get_isDownloading()){ - //positive for the rule, so block - //makeIPFilterRule(peerIP,peerID,peerClient,downloadName,clientList[i][6]); - Utils.changeHits(cb.getIndex(), 1); - return cb.getColor(); - } - return "null"; - }else if(downloadState == Download.ST_SEEDING){ - //torrent of peer is seeding - //now see if the rule is there to block it - if(cb.get_isUploading()){ - //positve for the rule,so block - //makeIPFilterRule(peerIP,peerID,peerClient,downloadName,clientList[i][6]); - Utils.changeHits(cb.getIndex(), 1); - return cb.getColor(); - } - return "null"; - }else{ - return "null"; - } + } catch (Exception e) { + e.printStackTrace(); + return "null"; + }//end of single upload or download check - } catch (Exception e) { - e.printStackTrace(); - return "null"; - }//end of single upload or download check + }//end of upload/download check - }//end of upload/download check + }//end of major superseed vs up/down check - }//end of major superseed vs up/down check + }//end of regular string match + }else{ + //isRegEx + Pattern p = Pattern.compile(cb.getClientName()); + Matcher m = p.matcher(peerClient); + //System.out.println("INPUT: " + peer.getClient() + " : " + "Regex: " + p.pattern() + " : " + m.matches()); + if(m.find()){ + //check for superseeding block + if(cb.get_isSuperseeding()){ + //positive for superseeding only.. now check if torrent is superseeding + if(isSuperSeeding){ + //makeIPFilterRule(peerIP,peerID,peerClient,downloadName,clientList[i][6]); + Utils.changeHits(cb.getIndex(), 1); + return cb.getColor(); + } + return "null"; + }else{ + //check for rule for download/upload - }//end of regular string match - }else{ - //isRegEx - Pattern p = Pattern.compile(cb.getClientName()); - Matcher m = p.matcher(peerClient); - //System.out.println("INPUT: " + peer.getClient() + " : " + "Regex: " + p.pattern() + " : " + m.matches()); - if(m.find()){ - //check for superseeding block - if(cb.get_isSuperseeding()){ - //positive for superseeding only.. now check if torrent is superseeding - if(isSuperSeeding){ - //makeIPFilterRule(peerIP,peerID,peerClient,downloadName,clientList[i][6]); - Utils.changeHits(cb.getIndex(), 1); - return cb.getColor(); - } - return "null"; - }else{ - //check for rule for download/upload + //first see if both are postive, and if so, block the peer out right + if(cb.get_isDownloading() && cb.get_isUploading()){ + //both positive, so block away + //makeIPFilterRule(peerIP,peerID,peerClient,downloadName,clientList[i][6]); + Utils.changeHits(cb.getIndex(), 1); + return cb.getColor(); + }else{ + //both are not positve.. so need to step through and see which one is - //first see if both are postive, and if so, block the peer out right - if(cb.get_isDownloading() && cb.get_isUploading()){ - //both positive, so block away - //makeIPFilterRule(peerIP,peerID,peerClient,downloadName,clientList[i][6]); - Utils.changeHits(cb.getIndex(), 1); - return cb.getColor(); - }else{ - //both are not positve.. so need to step through and see which one is + try { - try { + if(downloadState == Download.ST_DOWNLOADING){ + //torrent of peer is downloading + //now see if the rule is there to block it + if(cb.get_isDownloading()){ + //positive for the rule, so block + //makeIPFilterRule(peerIP,peerID,peerClient,downloadName,clientList[i][6]); + Utils.changeHits(cb.getIndex(), 1); + return cb.getColor(); + }else{ + return "null"; + } - if(downloadState == Download.ST_DOWNLOADING){ - //torrent of peer is downloading - //now see if the rule is there to block it - if(cb.get_isDownloading()){ - //positive for the rule, so block - //makeIPFilterRule(peerIP,peerID,peerClient,downloadName,clientList[i][6]); - Utils.changeHits(cb.getIndex(), 1); - return cb.getColor(); - }else{ - ... [truncated message content] |
From: <oms...@us...> - 2007-07-20 22:43:33
|
Revision: 989 http://svn.sourceforge.net/azcvsupdater/?rev=989&view=rev Author: omschaub Date: 2007-07-20 15:17:22 -0700 (Fri, 20 Jul 2007) Log Message: ----------- forgot to purge this TPC code Modified Paths: -------------- trunk/omschaub/omschaub/stuffer/main/Utils.java Modified: trunk/omschaub/omschaub/stuffer/main/Utils.java =================================================================== --- trunk/omschaub/omschaub/stuffer/main/Utils.java 2007-07-20 22:01:13 UTC (rev 988) +++ trunk/omschaub/omschaub/stuffer/main/Utils.java 2007-07-20 22:17:22 UTC (rev 989) @@ -26,396 +26,396 @@ public class Utils { - /**time get for NEXT timer run - * - * @param long AUTO_UPDATE_CHECK_PERIOD - * @param boolean MilitaryTime - * @return String datecurrentTime - */ - public static String getNextRunTime(long AUTO_UPDATE_CHECK_PERIOD, boolean MilitaryTime){ - String dateCurrentTime; - Date when = new Date(); - Date when2 = new Date(); - //when.getTime(); - when.setTime(Plugin.getPluginInterface().getUtilities().getCurrentSystemTime()); + /**time get for NEXT timer run + * + * @param long AUTO_UPDATE_CHECK_PERIOD + * @param boolean MilitaryTime + * @return String datecurrentTime + */ + public static String getNextRunTime(long AUTO_UPDATE_CHECK_PERIOD, boolean MilitaryTime){ + String dateCurrentTime; + Date when = new Date(); + Date when2 = new Date(); + //when.getTime(); + when.setTime(Plugin.getPluginInterface().getUtilities().getCurrentSystemTime()); - when2.setTime(when.getTime() + AUTO_UPDATE_CHECK_PERIOD); - SimpleDateFormat sdf; - if(MilitaryTime) - { - sdf= new SimpleDateFormat("HH:mm" ); - } - else - { - sdf= new SimpleDateFormat("hh:mm aa" ); - } + when2.setTime(when.getTime() + AUTO_UPDATE_CHECK_PERIOD); + SimpleDateFormat sdf; + if(MilitaryTime) + { + sdf= new SimpleDateFormat("HH:mm" ); + } + else + { + sdf= new SimpleDateFormat("hh:mm aa" ); + } - sdf.setTimeZone(TimeZone.getDefault()); - //System.out.println(TimeZone.getDefault().toString()); - dateCurrentTime = sdf.format(when2); - return dateCurrentTime; - } + sdf.setTimeZone(TimeZone.getDefault()); + //System.out.println(TimeZone.getDefault().toString()); + dateCurrentTime = sdf.format(when2); + return dateCurrentTime; + } - /**returns the current time formatted in 12 hr or 24 hr time - * based on user preferences - * @return String dateCurrentTime - * @param boolean MilitarTime - */ + /**returns the current time formatted in 12 hr or 24 hr time + * based on user preferences + * @return String dateCurrentTime + * @param boolean MilitarTime + */ - public static String getCurrentTime(boolean MilitaryTime){ - String dateCurrentTime; - SimpleDateFormat sdf; - Date when = new Date(); - when.setTime(Plugin.getPluginInterface().getUtilities().getCurrentSystemTime()); - //when.getTime(); - if(MilitaryTime) - { - sdf = new SimpleDateFormat("dd/MM/yyy HH:mm:ss" ); - } - else - { - sdf = new SimpleDateFormat("MM/dd/yyy hh:mm:ss aa" ); - } + public static String getCurrentTime(boolean MilitaryTime){ + String dateCurrentTime; + SimpleDateFormat sdf; + Date when = new Date(); + when.setTime(Plugin.getPluginInterface().getUtilities().getCurrentSystemTime()); + //when.getTime(); + if(MilitaryTime) + { + sdf = new SimpleDateFormat("dd/MM/yyy HH:mm:ss" ); + } + else + { + sdf = new SimpleDateFormat("MM/dd/yyy hh:mm:ss aa" ); + } - sdf.setTimeZone(TimeZone.getDefault()); - dateCurrentTime = sdf.format(when); - return dateCurrentTime; - } + sdf.setTimeZone(TimeZone.getDefault()); + dateCurrentTime = sdf.format(when); + return dateCurrentTime; + } - public static String getCurrentTime(){ - String dateCurrentTime; - Date when = new Date(); - when.getTime(); - if(Plugin.config_getter.getPluginBooleanParameter("stuffer_military_time",false)){ - SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss" ); - sdf.setTimeZone(TimeZone.getDefault()); - dateCurrentTime = sdf.format(when); - return dateCurrentTime; - }else{ - SimpleDateFormat sdf = new SimpleDateFormat("MM.dd.yyyy hh:mm:ss aa" ); - sdf.setTimeZone(TimeZone.getDefault()); - dateCurrentTime = sdf.format(when); - return dateCurrentTime; - } + public static String getCurrentTime(){ + String dateCurrentTime; + Date when = new Date(); + when.getTime(); + if(Plugin.config_getter.getPluginBooleanParameter("stuffer_military_time",false)){ + SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss" ); + sdf.setTimeZone(TimeZone.getDefault()); + dateCurrentTime = sdf.format(when); + return dateCurrentTime; + }else{ + SimpleDateFormat sdf = new SimpleDateFormat("MM.dd.yyyy hh:mm:ss aa" ); + sdf.setTimeZone(TimeZone.getDefault()); + dateCurrentTime = sdf.format(when); + return dateCurrentTime; + } - } + } - /**returns the given time formatted in 12 hr or 24 hr time - * based on user preferences - * @return String dateCurrentTime - * @param boolean MilitarTime - */ + /**returns the given time formatted in 12 hr or 24 hr time + * based on user preferences + * @return String dateCurrentTime + * @param boolean MilitarTime + */ - public static String getFormattedTime(long timeInSeconds){ - int hours, minutes, seconds; - hours = (int)timeInSeconds / 3600; - timeInSeconds = timeInSeconds - (hours * 3600); - minutes = (int)timeInSeconds / 60; - timeInSeconds = timeInSeconds - (minutes * 60); - seconds = (int)timeInSeconds; - return (hours + "h " + minutes + "m " + seconds + "s"); - } + public static String getFormattedTime(long timeInSeconds){ + int hours, minutes, seconds; + hours = (int)timeInSeconds / 3600; + timeInSeconds = timeInSeconds - (hours * 3600); + minutes = (int)timeInSeconds / 60; + timeInSeconds = timeInSeconds - (minutes * 60); + seconds = (int)timeInSeconds; + return (hours + "h " + minutes + "m " + seconds + "s"); + } - /** - * Round a double value to a specified number of decimal - * places. - * - * @param val the value to be rounded. - * @param places the number of decimal places to round to. - * @return val rounded to places decimal places. - */ - public static float round(float val, int places) { - long factor = (long)Math.pow(10,places); + /** + * Round a double value to a specified number of decimal + * places. + * + * @param val the value to be rounded. + * @param places the number of decimal places to round to. + * @return val rounded to places decimal places. + */ + public static float round(float val, int places) { + long factor = (long)Math.pow(10,places); - // Shift the decimal the correct number of places - // to the right. - val = val * factor; + // Shift the decimal the correct number of places + // to the right. + val = val * factor; - // Round to the nearest integer. - long tmp = Math.round(val); + // Round to the nearest integer. + long tmp = Math.round(val); - // Shift the decimal the correct number of places - // back to the left. - return (float)tmp / factor; - } + // Shift the decimal the correct number of places + // back to the left. + return (float)tmp / factor; + } public static void killConnectedPeers(){ - DownloadManager dm = Plugin.getPluginInterface().getDownloadManager(); - Download downloads[] = dm.getDownloads(); - if(downloads == null || downloads.length == 0) return; - for(int i = 0; i < downloads.length ; i++){ + DownloadManager dm = Plugin.getPluginInterface().getDownloadManager(); + Download downloads[] = dm.getDownloads(); + if(downloads == null || downloads.length == 0) return; + for(int i = 0; i < downloads.length ; i++){ - try{ - Peer[] peers = downloads[i].getPeerManager().getPeers(); + try{ + Peer[] peers = downloads[i].getPeerManager().getPeers(); - //System.out.println(downloads[i].getName() + " Peers: " + peers.length); + //System.out.println(downloads[i].getName() + " Peers: " + peers.length); - if(peers !=null){ - for(int j = 0; j < peers.length; j++){ + if(peers !=null){ + for(int j = 0; j < peers.length; j++){ - PeerManager manager = peers[j].getManager(); + PeerManager manager = peers[j].getManager(); - try { - if(manager != null){ + try { + if(manager != null){ - //-----Data Mining-----\\ - TotalPeerContainer tpc = Plugin.totalPeer_set.getTotalPeerContainer(new IP(peers[j].getIp())); - if(tpc != null){ - PeerStats ps = peers[j].getStats(); - tpc.setAllByPeerStats(ps); - tpc.setPercentDone((peers[j].getPercentDoneInThousandNotation())); +/* //-----Data Mining-----\\ + TotalPeerContainer tpc = Plugin.totalPeer_set.getTotalPeerContainer(new IP(peers[j].getIp())); + if(tpc != null){ + PeerStats ps = peers[j].getStats(); + tpc.setAllByPeerStats(ps); + tpc.setPercentDone((peers[j].getPercentDoneInThousandNotation())); - } - //--Looking for escaped seeds---\\ - if(Plugin.getPluginInterface().getPluginconfig().getPluginBooleanParameter("Stuffer_Block_Seeder",false)){ - if(peers[j].isSeed() || peers[j].getPercentDoneInThousandNotation() == 1000){ - String color = Plugin.getPluginInterface().getPluginconfig().getPluginStringParameter("Stuffer_Block_Seeder_Color","r255g0b0"); - System.out.println("Escaped Seeder: " + peers[j].getPercentDoneInThousandNotation()); - if(!color.equalsIgnoreCase("null")){ - String peerID = BlockIPUtils.getPeerID(peers[j].getId()); - String clientName = peers[j].getClient(); - // peer.setSnubbed(true); - BlockIPUtils.makeIPFilterRule(peers[j].getIp(),"Escaped Seeder: " + peerID,clientName + " Escaped Seeder",manager.getDownload().getName(), color); - Constants.SEEDER_CLIENT_BLOCKS++; - Plugin.getTab2().renumberMOD_Seeder(false, true); - } - } - } + }*/ + //--Looking for escaped seeds---\\ + if(Plugin.getPluginInterface().getPluginconfig().getPluginBooleanParameter("Stuffer_Block_Seeder",false)){ + if(peers[j].isSeed() || peers[j].getPercentDoneInThousandNotation() == 1000){ + String color = Plugin.getPluginInterface().getPluginconfig().getPluginStringParameter("Stuffer_Block_Seeder_Color","r255g0b0"); + System.out.println("Escaped Seeder: " + peers[j].getPercentDoneInThousandNotation()); + if(!color.equalsIgnoreCase("null")){ + String peerID = BlockIPUtils.getPeerID(peers[j].getId()); + String clientName = peers[j].getClient(); + // peer.setSnubbed(true); + BlockIPUtils.makeIPFilterRule(peers[j].getIp(),"Escaped Seeder: " + peerID,clientName + " Escaped Seeder",manager.getDownload().getName(), color); + Constants.SEEDER_CLIENT_BLOCKS++; + Plugin.getTab2().renumberMOD_Seeder(false, true); + } + } + } - //-----Look for Escaped peers----\\ - String peerClient = peers[j].getClient(); - String color = BlockIPUtils.mainRuleRun(peerClient,manager.isSuperSeeding(), manager.getDownload().getState()); - if(!color.equalsIgnoreCase("null")){ - String peerID = BlockIPUtils.getPeerID(peers[j].getId()); - BlockIPUtils.makeIPFilterRule(peers[j].getIp(),"ESCAPED: " + peerID,peerClient,manager.getDownload().getName(), color); - } - } - } catch (DownloadException e) { - e.printStackTrace(); - } + //-----Look for Escaped peers----\\ + String peerClient = peers[j].getClient(); + String color = BlockIPUtils.mainRuleRun(peerClient,manager.isSuperSeeding(), manager.getDownload().getState()); + if(!color.equalsIgnoreCase("null")){ + String peerID = BlockIPUtils.getPeerID(peers[j].getId()); + BlockIPUtils.makeIPFilterRule(peers[j].getIp(),"ESCAPED: " + peerID,peerClient,manager.getDownload().getName(), color); + } + } + } catch (DownloadException e) { + e.printStackTrace(); + } - }//End of Peer for loop + }//End of Peer for loop - /*//pop the tab3 table - Plugin.getTab3().resetTable();*/ + /*//pop the tab3 table + Plugin.getTab3().resetTable();*/ - }// End of if peer != null + }// End of if peer != null - }catch(Exception e){ - // e.printStackTrace(); - } - }//End of Downloads for loop - //System.out.println("Finished Peer Scan Loop"); + }catch(Exception e){ + // e.printStackTrace(); + } + }//End of Downloads for loop + //System.out.println("Finished Peer Scan Loop"); } - /** Centers a Shell and opens it relative to the users Monitor - * - * @param shell - */ + /** Centers a Shell and opens it relative to the users Monitor + * + * @param shell + */ - public static void centerShellandOpen(Shell shell){ - //open shell - shell.pack(); + public static void centerShellandOpen(Shell shell){ + //open shell + shell.pack(); - //Center Shell - Monitor primary = Plugin.getDisplay().getPrimaryMonitor (); - Rectangle bounds = primary.getBounds (); - Rectangle rect = shell.getBounds (); - int x = bounds.x + (bounds.width - rect.width) / 2; - int y = bounds.y +(bounds.height - rect.height) / 2; - shell.setLocation (x, y); + //Center Shell + Monitor primary = Plugin.getDisplay().getPrimaryMonitor (); + Rectangle bounds = primary.getBounds (); + Rectangle rect = shell.getBounds (); + int x = bounds.x + (bounds.width - rect.width) / 2; + int y = bounds.y +(bounds.height - rect.height) / 2; + shell.setLocation (x, y); - //open shell - shell.open(); - } + //open shell + shell.open(); + } - /** - * Returns a string holding the rgb format of the color from the ruleset - * @param color in r000g000b000 format - * @return RGB - */ - public static RGB getRGB(String color){ - RGB rgb; - try{ - int red = color.indexOf("r") + 1; - int green = color.indexOf("g") + 1 ; - int blue = color.indexOf("b") + 1; + /** + * Returns a string holding the rgb format of the color from the ruleset + * @param color in r000g000b000 format + * @return RGB + */ + public static RGB getRGB(String color){ + RGB rgb; + try{ + int red = color.indexOf("r") + 1; + int green = color.indexOf("g") + 1 ; + int blue = color.indexOf("b") + 1; - rgb = new RGB(new Integer(color.substring(red,green-1)).intValue(), - new Integer(color.substring(green, blue-1)).intValue(), - new Integer(color.substring(blue,color.length())).intValue()); - return rgb; - }catch(Exception e){ - e.printStackTrace(); - return new RGB(0,0,0); - } - } + rgb = new RGB(new Integer(color.substring(red,green-1)).intValue(), + new Integer(color.substring(green, blue-1)).intValue(), + new Integer(color.substring(blue,color.length())).intValue()); + return rgb; + }catch(Exception e){ + e.printStackTrace(); + return new RGB(0,0,0); + } + } - public static String getHexfromRGB(RGB rgb){ - try{ - String red = Integer.toString((rgb.red & 0xff) + 0x100, 16 /*radix*/ ).substring(1); - String green = Integer.toString((rgb.green & 0xff) + 0x100, 16 /*radix*/ ).substring(1); - String blue = Integer.toString((rgb.blue & 0xff) + 0x100, 16 /*radix*/ ).substring(1); - return red + green + blue; - }catch(Exception e){ - e.printStackTrace(); - return "000000"; - } + public static String getHexfromRGB(RGB rgb){ + try{ + String red = Integer.toString((rgb.red & 0xff) + 0x100, 16 /*radix*/ ).substring(1); + String green = Integer.toString((rgb.green & 0xff) + 0x100, 16 /*radix*/ ).substring(1); + String blue = Integer.toString((rgb.blue & 0xff) + 0x100, 16 /*radix*/ ).substring(1); + return red + green + blue; + }catch(Exception e){ + e.printStackTrace(); + return "000000"; + } - } + } - public static RGB getRGBfromHex(String peerLine){ - int index = peerLine.indexOf("c#") + 2; - if( index > -1){ - String hashColor = peerLine.substring(index,index+6); - //System.out.println(hashColor); - byte[] color_array = fromHexString(hashColor); + public static RGB getRGBfromHex(String peerLine){ + int index = peerLine.indexOf("c#") + 2; + if( index > -1){ + String hashColor = peerLine.substring(index,index+6); + //System.out.println(hashColor); + byte[] color_array = fromHexString(hashColor); - int[] color_array_int = new int[3]; - for(int i = 0; i < color_array.length ; i++){ - color_array_int[i] = color_array[i]; - if(color_array_int[i] < 0){ - color_array_int[i] = (255 + color_array_int[i]); - } - } + int[] color_array_int = new int[3]; + for(int i = 0; i < color_array.length ; i++){ + color_array_int[i] = color_array[i]; + if(color_array_int[i] < 0){ + color_array_int[i] = (255 + color_array_int[i]); + } + } - //System.out.println("After: " + color_array_int[0] + " : " + color_array_int[1] + " : " + color_array_int[2]); + //System.out.println("After: " + color_array_int[0] + " : " + color_array_int[1] + " : " + color_array_int[2]); - RGB rgb = new RGB(color_array_int[0], color_array_int[1], color_array_int[2]); - return rgb; + RGB rgb = new RGB(color_array_int[0], color_array_int[1], color_array_int[2]); + return rgb; - }else{ - return new RGB(0,0,0); - } + }else{ + return new RGB(0,0,0); + } - } + } - /** - * Convert a hex string to a byte array. - * Permits upper or lower case hex. - * - * @param s String must have even number of characters. - * and be formed only of digits 0-9 A-F or - * a-f. No spaces, minus or plus signs. - * @return corresponding byte array. - */ - public static byte[] fromHexString ( String s ) - { - int stringLength = s.length(); - if ( (stringLength & 0x1) != 0 ) - { - throw new IllegalArgumentException ( "fromHexString requires an even number of hex characters" ); - }byte[] b = new byte[stringLength / 2]; + /** + * Convert a hex string to a byte array. + * Permits upper or lower case hex. + * + * @param s String must have even number of characters. + * and be formed only of digits 0-9 A-F or + * a-f. No spaces, minus or plus signs. + * @return corresponding byte array. + */ + public static byte[] fromHexString ( String s ) + { + int stringLength = s.length(); + if ( (stringLength & 0x1) != 0 ) + { + throw new IllegalArgumentException ( "fromHexString requires an even number of hex characters" ); + }byte[] b = new byte[stringLength / 2]; - for ( int i=0,j=0; i<stringLength; i+=2,j++ ) - { - int high = charToNibble( s.charAt ( i ) ); - int low = charToNibble( s.charAt ( i+1 ) ); - b[j] = (byte)( ( high << 4 ) | low ); - } - return b; - } + for ( int i=0,j=0; i<stringLength; i+=2,j++ ) + { + int high = charToNibble( s.charAt ( i ) ); + int low = charToNibble( s.charAt ( i+1 ) ); + b[j] = (byte)( ( high << 4 ) | low ); + } + return b; + } - /** - * Alternate implementation of charToNibble using a precalculated array. - * Based on code by: - * Brian Marquis - * Orion Group Software Engineers http://www.ogse.com - * - * convert a single char to corresponding nibble. - * - * @param c char to convert. must be 0-9 a-f A-F, no - * spaces, plus or minus signs. - * - * @return corresponding integer - * @throws IllegalArgumentException on invalid c. - * @throws ArrayIndexOutOfBoundsException on invalid c - */ - private static int charToNibble ( char c ) - { - int nibble = correspondingNibble[c]; - if ( nibble < 0 ) - { - throw new IllegalArgumentException ( "Invalid hex character: " + c ); - } - return nibble; - } + /** + * Alternate implementation of charToNibble using a precalculated array. + * Based on code by: + * Brian Marquis + * Orion Group Software Engineers http://www.ogse.com + * + * convert a single char to corresponding nibble. + * + * @param c char to convert. must be 0-9 a-f A-F, no + * spaces, plus or minus signs. + * + * @return corresponding integer + * @throws IllegalArgumentException on invalid c. + * @throws ArrayIndexOutOfBoundsException on invalid c + */ + private static int charToNibble ( char c ) + { + int nibble = correspondingNibble[c]; + if ( nibble < 0 ) + { + throw new IllegalArgumentException ( "Invalid hex character: " + c ); + } + return nibble; + } - private static byte[] correspondingNibble = new byte['f'+1]; + private static byte[] correspondingNibble = new byte['f'+1]; - static { - // only 0..9 A..F a..f have meaning. rest are errors. - for ( int i=0; i<='f'; i++ ) - { - correspondingNibble[i] = -1; - } - for ( int i='0'; i<='9'; i++ ) - { - correspondingNibble[i] = (byte)( i - '0' ); - } - for ( int i='A'; i<='F'; i++ ) - { - correspondingNibble[i] = (byte)( i - 'A' + 10 ); - } - for ( int i='a'; i<='f'; i++ ) - { - correspondingNibble[i] = (byte)( i - 'a' + 10 ); - } - } + static { + // only 0..9 A..F a..f have meaning. rest are errors. + for ( int i=0; i<='f'; i++ ) + { + correspondingNibble[i] = -1; + } + for ( int i='0'; i<='9'; i++ ) + { + correspondingNibble[i] = (byte)( i - '0' ); + } + for ( int i='A'; i<='F'; i++ ) + { + correspondingNibble[i] = (byte)( i - 'A' + 10 ); + } + for ( int i='a'; i<='f'; i++ ) + { + correspondingNibble[i] = (byte)( i - 'a' + 10 ); + } + } - /** - * Parses a string to get rid of everything that is not a letter or digit - * @param stringToCheck - * @return parsedString - */ - public static String parseString(String stringToCheck){ - StringBuffer buf = new StringBuffer(stringToCheck); - for (int i = 0; i < stringToCheck.length() ; i++){ - char c = stringToCheck.charAt(i); + /** + * Parses a string to get rid of everything that is not a letter or digit + * @param stringToCheck + * @return parsedString + */ + public static String parseString(String stringToCheck){ + StringBuffer buf = new StringBuffer(stringToCheck); + for (int i = 0; i < stringToCheck.length() ; i++){ + char c = stringToCheck.charAt(i); // System.out.println(c + " : " + Character.isDefined(c)); - /* if(!Character.isLetterOrDigit(c) && c != ' ' - && c != '?' && c != '.' && c != '-' && c != '[' && c != ']' && c !='_' - && c!= '!' && c != '{' && c != '}' && c!= '(' && c!= ')' && c!='+' - && c!='^' && c!= '@' && c!='$' && c!='<' && c!='>' && c!='"' - && c!='#' && c!='&' && c!='\\' && c!= '|' && c!=';' - && c!=':' && c!= '\'' && c!='/'&& c!='~' && c!='`'){*/ - if(!Character.isDefined(c)){ - System.out.println("Stuffer - Illegal Character: " + c + " Replaced -- Numeric: "+ Character.getType(c) ); - buf.replace(i,i+1,"?"); - } - } - return new String(buf); - } + /* if(!Character.isLetterOrDigit(c) && c != ' ' + && c != '?' && c != '.' && c != '-' && c != '[' && c != ']' && c !='_' + && c!= '!' && c != '{' && c != '}' && c!= '(' && c!= ')' && c!='+' + && c!='^' && c!= '@' && c!='$' && c!='<' && c!='>' && c!='"' + && c!='#' && c!='&' && c!='\\' && c!= '|' && c!=';' + && c!=':' && c!= '\'' && c!='/'&& c!='~' && c!='`'){*/ + if(!Character.isDefined(c)){ + System.out.println("Stuffer - Illegal Character: " + c + " Replaced -- Numeric: "+ Character.getType(c) ); + buf.replace(i,i+1,"?"); + } + } + return new String(buf); + } - /** - * Change the number of Hits for a given client at index - * @param index - * @param state (0 for Change to 0, 1 for increase, 2 for decrease) - */ - public static void changeHits(final int index, final int state){ + /** + * Change the number of Hits for a given client at index + * @param index + * @param state (0 for Change to 0, 1 for increase, 2 for decrease) + */ + public static void changeHits(final int index, final int state){ - final ClientBlock cb = Plugin.clientBlock_set.getClientBlockByIndex(index); - if(state == 0) cb.setHitsThisSession(0); - else if(state == 1) cb.setHitsThisSession(cb.getHitsThisSession() + 1); - else cb.setHitsThisSession(cb.getHitsThisSession() - 1); + final ClientBlock cb = Plugin.clientBlock_set.getClientBlockByIndex(index); + if(state == 0) cb.setHitsThisSession(0); + else if(state == 1) cb.setHitsThisSession(cb.getHitsThisSession() + 1); + else cb.setHitsThisSession(cb.getHitsThisSession() - 1); - //Try to change the hits on the Tab2 if it is open - try{ - if(Plugin.getTab2Utilities() != null){ - Plugin.getTab2Utilities().changeHits(index, state, cb); - } - } catch (final Exception e) { + //Try to change the hits on the Tab2 if it is open + try{ + if(Plugin.getTab2Utilities() != null){ + Plugin.getTab2Utilities().changeHits(index, state, cb); + } + } catch (final Exception e) { - e.printStackTrace(); - } - } + e.printStackTrace(); + } + } }//EOF \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <oms...@us...> - 2007-07-20 22:01:12
|
Revision: 988 http://svn.sourceforge.net/azcvsupdater/?rev=988&view=rev Author: omschaub Date: 2007-07-20 15:01:13 -0700 (Fri, 20 Jul 2007) Log Message: ----------- changed CCombo to just a combo to see if this helps the8549863905793769376 any Modified Paths: -------------- trunk/omschaub/omschaub/stuffer/main/Tab2Utilities.java Modified: trunk/omschaub/omschaub/stuffer/main/Tab2Utilities.java =================================================================== --- trunk/omschaub/omschaub/stuffer/main/Tab2Utilities.java 2007-07-20 16:52:19 UTC (rev 987) +++ trunk/omschaub/omschaub/stuffer/main/Tab2Utilities.java 2007-07-20 22:01:13 UTC (rev 988) @@ -13,7 +13,7 @@ import omschaub.stuffer.utilities.ImageRepository; import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CCombo; + import org.eclipse.swt.custom.TableEditor; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; @@ -23,6 +23,7 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.ColorDialog; +import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Event; @@ -34,702 +35,702 @@ import org.eclipse.swt.widgets.Text; public class Tab2Utilities { - - private Shell errorShell; - - - public void addNewClient(){ - final Thread addNew_thread = new Thread() { - public void run() { - if(Plugin.getDisplay()==null && Plugin.getDisplay().isDisposed()) - return; - Plugin.getDisplay().asyncExec( new Runnable() { - public void run() { + + private Shell errorShell; + + + public void addNewClient(){ + final Thread addNew_thread = new Thread() { + public void run() { + if(Plugin.getDisplay()==null && Plugin.getDisplay().isDisposed()) + return; + Plugin.getDisplay().asyncExec( new Runnable() { + public void run() { // Shell Initialize - - final Shell shell = new Shell(SWT.DIALOG_TRIM); - if(!Plugin.getPluginInterface().getUtilities().isOSX()) - shell.setImage(ImageRepository.getImage("plus")); - - //Grid Layout - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - shell.setLayout(layout); - - //composite for shell - Composite backup_composite = new Composite(shell,SWT.NULL); - - //Grid Layout - layout = new GridLayout(); - layout.numColumns = 3; - backup_composite.setLayout(layout); - - //shell title - shell.setText("Add New Client"); - - - //Text Line 1 - Label nameLabel = new Label(backup_composite, SWT.NONE); - GridData gridData = new GridData(GridData.FILL_HORIZONTAL); - gridData.horizontalSpan = 3; - nameLabel.setLayoutData( gridData ); - nameLabel.setText("Input Name of Client you wish to block"); - - + final Shell shell = new Shell(SWT.DIALOG_TRIM); + if(!Plugin.getPluginInterface().getUtilities().isOSX()) + shell.setImage(ImageRepository.getImage("plus")); - //Input field - final Text line1 = new Text(backup_composite,SWT.BORDER); - gridData = new GridData(GridData.FILL_HORIZONTAL); - gridData.horizontalSpan = 3; - line1.setLayoutData( gridData); - - //Radio buttons for Normal vs RegEx - Composite comp_buttons = new Composite(backup_composite,SWT.NULL); - comp_buttons.setLayout(new GridLayout(3,false)); - gridData = new GridData(GridData.FILL_HORIZONTAL); - gridData.horizontalSpan = 3; - comp_buttons.setLayoutData(gridData); - - final Button choiceString = new Button(comp_buttons,SWT.RADIO); - choiceString.setText("Simple String (simple match)"); - choiceString.setSelection(true); - - final Button choiceRegEx = new Button(comp_buttons,SWT.RADIO); - choiceRegEx.setText("RegEx (complex match)"); - - - - //Color Comp - Composite color_comp = new Composite(backup_composite,SWT.NULL); - color_comp.setLayout(new GridLayout(3,false)); - gridData = new GridData(GridData.FILL_HORIZONTAL); - gridData.horizontalSpan = 3; - color_comp.setLayoutData(gridData); - - final Label labelcolor = new Label(color_comp,SWT.BORDER); - labelcolor.setBackground(Plugin.getDisplay().getSystemColor(SWT.COLOR_BLACK)); - gridData = new GridData (GridData.FILL_HORIZONTAL); - gridData.widthHint = 50; - labelcolor.setLayoutData(gridData); - - final Button color_choose = new Button(color_comp,SWT.PUSH); - color_choose.setText("Choose Color for Client"); - color_choose.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - //Choose color - ColorDialog colorDialog1 = new ColorDialog(shell); - colorDialog1.setText("Choose Color for Client"); - colorDialog1.setRGB(new RGB(0,0,0)); - RGB selectedColor = colorDialog1.open(); - - if(selectedColor != null){ - Color color = new Color(Plugin.getDisplay(), - selectedColor.red, - selectedColor.green, - selectedColor.blue); - labelcolor.setBackground(color); - color.dispose(); - } - } - }); - - - - - - //Button for Accept - Button commit = new Button(backup_composite, SWT.PUSH); - gridData = new GridData(GridData.CENTER); - gridData.horizontalSpan = 1; - commit.setLayoutData( gridData); - commit.setText( "Accept"); - commit.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - - if(line1.getText().equalsIgnoreCase("")){ - MessageBox mb = new MessageBox(Plugin.getDisplay().getActiveShell(),SWT.ICON_ERROR); - mb.setText("Error"); - mb.setMessage("Please input the client name you wish to block."); - mb.open(); - return; - } - if(!choiceString.getSelection() && !choiceRegEx.getSelection()){ - MessageBox mb = new MessageBox(Plugin.getDisplay().getActiveShell(),SWT.ICON_ERROR); - mb.setText("Error"); - mb.setMessage("Please select whether this new client's name is a regular string or a regex expression."); - mb.open(); - return; - }else{ - if(choiceString.getSelection()){ - FileUtilities.writeNewClient(line1.getText(),"0","1","1","0","r"+labelcolor.getBackground().getRed() + "g" + labelcolor.getBackground().getGreen() + "b" + labelcolor.getBackground().getBlue()); - }else{ - try{ - Pattern p = Pattern.compile(line1.getText()); - Matcher m = p.matcher("Test"); - m.find(); - }catch(PatternSyntaxException f){ - f.printStackTrace(); - - String text = ("Java is reporting that your RegEx is incorrectly formed, please correcct this. \n\n" + - "For further information and examples, check the readme at \n\n" + - "http://azcvsupdater.sourceforge.net/stuffer/readme.txt \n\n " + - "Also check http://www.regular-expressions.info for more information\n\n" + - "Java is reporting the following problem with the expression: \n" - + f.getDescription()) + " at position " + f.getIndex() + " in the rule"; - openErrorMessageBox("Error",text); - - - return; - } - - - FileUtilities.writeNewClient(line1.getText(),"1","1","1","0","r"+labelcolor.getBackground().getRed() + "g" + labelcolor.getBackground().getGreen() + "b" + labelcolor.getBackground().getBlue()); - } - loadClientTable(-1); - shell.dispose(); - } - } - }); - + //Grid Layout + GridLayout layout = new GridLayout(); + layout.numColumns = 1; + shell.setLayout(layout); + + //composite for shell + Composite backup_composite = new Composite(shell,SWT.NULL); + + //Grid Layout + layout = new GridLayout(); + layout.numColumns = 3; + backup_composite.setLayout(layout); + + //shell title + shell.setText("Add New Client"); + + + + //Text Line 1 + Label nameLabel = new Label(backup_composite, SWT.NONE); + GridData gridData = new GridData(GridData.FILL_HORIZONTAL); + gridData.horizontalSpan = 3; + nameLabel.setLayoutData( gridData ); + nameLabel.setText("Input Name of Client you wish to block"); + + + + //Input field + final Text line1 = new Text(backup_composite,SWT.BORDER); + gridData = new GridData(GridData.FILL_HORIZONTAL); + gridData.horizontalSpan = 3; + line1.setLayoutData( gridData); + + //Radio buttons for Normal vs RegEx + Composite comp_buttons = new Composite(backup_composite,SWT.NULL); + comp_buttons.setLayout(new GridLayout(3,false)); + gridData = new GridData(GridData.FILL_HORIZONTAL); + gridData.horizontalSpan = 3; + comp_buttons.setLayoutData(gridData); + + final Button choiceString = new Button(comp_buttons,SWT.RADIO); + choiceString.setText("Simple String (simple match)"); + choiceString.setSelection(true); + + final Button choiceRegEx = new Button(comp_buttons,SWT.RADIO); + choiceRegEx.setText("RegEx (complex match)"); + + + + //Color Comp + Composite color_comp = new Composite(backup_composite,SWT.NULL); + color_comp.setLayout(new GridLayout(3,false)); + gridData = new GridData(GridData.FILL_HORIZONTAL); + gridData.horizontalSpan = 3; + color_comp.setLayoutData(gridData); + + final Label labelcolor = new Label(color_comp,SWT.BORDER); + labelcolor.setBackground(Plugin.getDisplay().getSystemColor(SWT.COLOR_BLACK)); + gridData = new GridData (GridData.FILL_HORIZONTAL); + gridData.widthHint = 50; + labelcolor.setLayoutData(gridData); + + final Button color_choose = new Button(color_comp,SWT.PUSH); + color_choose.setText("Choose Color for Client"); + color_choose.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event e) { + //Choose color + ColorDialog colorDialog1 = new ColorDialog(shell); + colorDialog1.setText("Choose Color for Client"); + colorDialog1.setRGB(new RGB(0,0,0)); + RGB selectedColor = colorDialog1.open(); + + if(selectedColor != null){ + Color color = new Color(Plugin.getDisplay(), + selectedColor.red, + selectedColor.green, + selectedColor.blue); + labelcolor.setBackground(color); + color.dispose(); + } + } + }); + + + + + + //Button for Accept + Button commit = new Button(backup_composite, SWT.PUSH); + gridData = new GridData(GridData.CENTER); + gridData.horizontalSpan = 1; + commit.setLayoutData( gridData); + commit.setText( "Accept"); + commit.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event e) { + + if(line1.getText().equalsIgnoreCase("")){ + MessageBox mb = new MessageBox(Plugin.getDisplay().getActiveShell(),SWT.ICON_ERROR); + mb.setText("Error"); + mb.setMessage("Please input the client name you wish to block."); + mb.open(); + return; + } + if(!choiceString.getSelection() && !choiceRegEx.getSelection()){ + MessageBox mb = new MessageBox(Plugin.getDisplay().getActiveShell(),SWT.ICON_ERROR); + mb.setText("Error"); + mb.setMessage("Please select whether this new client's name is a regular string or a regex expression."); + mb.open(); + return; + }else{ + if(choiceString.getSelection()){ + FileUtilities.writeNewClient(line1.getText(),"0","1","1","0","r"+labelcolor.getBackground().getRed() + "g" + labelcolor.getBackground().getGreen() + "b" + labelcolor.getBackground().getBlue()); + }else{ + try{ + Pattern p = Pattern.compile(line1.getText()); + Matcher m = p.matcher("Test"); + m.find(); + }catch(PatternSyntaxException f){ + f.printStackTrace(); + + String text = ("Java is reporting that your RegEx is incorrectly formed, please correcct this. \n\n" + + "For further information and examples, check the readme at \n\n" + + "http://azcvsupdater.sourceforge.net/stuffer/readme.txt \n\n " + + "Also check http://www.regular-expressions.info for more information\n\n" + + "Java is reporting the following problem with the expression: \n" + + f.getDescription()) + " at position " + f.getIndex() + " in the rule"; + openErrorMessageBox("Error",text); + + + return; + } + + + FileUtilities.writeNewClient(line1.getText(),"1","1","1","0","r"+labelcolor.getBackground().getRed() + "g" + labelcolor.getBackground().getGreen() + "b" + labelcolor.getBackground().getBlue()); + } + loadClientTable(-1); + shell.dispose(); + } + } + }); + // Button for Cancel - Button cancel = new Button(backup_composite, SWT.PUSH); - gridData = new GridData(GridData.CENTER); - gridData.horizontalSpan = 2; - cancel.setLayoutData( gridData); - cancel.setText( "Cancel"); - cancel.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - shell.dispose(); - } - }); - - - - line1.addKeyListener(new KeyListener() { - public void keyPressed(KeyEvent e) { - //Empty - } - - public void keyReleased (KeyEvent e) { - switch (e.character){ - case SWT.ESC: - - shell.dispose(); - break; - - case SWT.CR: - - if(line1.getText().equalsIgnoreCase("") || line1.getText().equalsIgnoreCase(" ")){ - MessageBox mb = new MessageBox(Plugin.getDisplay().getActiveShell(),SWT.ICON_ERROR); - mb.setText("Error"); - mb.setMessage("Please input the client name you wish to block."); - mb.open(); - break; - } - if(!choiceString.getSelection() && !choiceRegEx.getSelection()){ - MessageBox mb = new MessageBox(Plugin.getDisplay().getActiveShell(),SWT.ICON_ERROR); - mb.setText("Error"); - mb.setMessage("Please select whether this new client's name is a regular string or a regex expression."); - mb.open(); - break; - }else{ - if(choiceString.getSelection()){ - FileUtilities.writeNewClient(line1.getText(),"0","1","1","0","r"+labelcolor.getBackground().getRed() + "g" + labelcolor.getBackground().getGreen() + "b" + labelcolor.getBackground().getBlue()); - }else{ - FileUtilities.writeNewClient(line1.getText(),"1","1","1","0","r"+labelcolor.getBackground().getRed() + "g" + labelcolor.getBackground().getGreen() + "b" + labelcolor.getBackground().getBlue()); - } - loadClientTable(-1); - shell.dispose(); - } - break; - } - } - }); - - Utils.centerShellandOpen(shell); - - } - }); - } - }; - addNew_thread.run(); - - - - } - - - - public void loadClientTable(final int selection){ - final Thread load_client_list_thread = new Thread() { - public void run() { - - try { - if(Plugin.getDisplay()== null && Plugin.getDisplay().isDisposed()) - return; - - Plugin.getDisplay().syncExec(new Runnable (){ - public void run () { - if (Plugin.getTab2().getClientTable() != null && !Plugin.getTab2().getClientTable().isDisposed()){ - Control[] controls = Plugin.getTab2().getClientTable().getChildren(); - for(int i = 0; i < controls.length ; i++){ - - controls[i].dispose(); - controls[i] = null; - } - Plugin.getTab2().getClientTable().setEnabled(true); - Plugin.getTab2().getClientTable().removeAll(); - } - - - } - }); - - FileUtilities.readClientList(); - Iterator it = Plugin.clientBlock_set.getIterator(); - while(it.hasNext()){ - ClientBlock cb = (ClientBlock)it.next(); - addTableElement(String.valueOf(cb.getIndex()), - cb.getClientName(), - (cb.get_isRegEx() ? "1" : "0"), - (cb.get_isDownloading() ? "1" : "0"), - (cb.get_isUploading() ? "1" : "0"), - (cb.get_isSuperseeding() ? "1" : "0"), - cb.getColor(), - cb.getHitsThisSession()); - } - - Plugin.getDisplay().syncExec(new Runnable (){ - public void run () { - if (Plugin.getTab2().getClientTable() !=null && !Plugin.getTab2().getClientTable().isDisposed()){ - if(selection > -1){ - Plugin.getTab2().getClientTable().setSelection(selection); - } - } - } - }); - - - /*String[][] clientList = FileUtilities.getClientList(true); + Button cancel = new Button(backup_composite, SWT.PUSH); + gridData = new GridData(GridData.CENTER); + gridData.horizontalSpan = 2; + cancel.setLayoutData( gridData); + cancel.setText( "Cancel"); + cancel.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event e) { + shell.dispose(); + } + }); - for(int i = 0 ; i < 200 ; i++) { - if(clientList[i][0] != null){ - //add table element - addTableElement(clientList[i][0], - clientList[i][1], - clientList[i][2], - clientList[i][3], - clientList[i][4], - clientList[i][5], - clientList[i][6]); - } - - }*/ - - - } catch(Exception e) { - //Stop process and trace the exception - e.printStackTrace(); - } - } - }; - load_client_list_thread.setDaemon(true); - load_client_list_thread.start(); - - } - - - public void addTableElement(final String number, - final String name, - final String isRegEx, - final String isDownload, - final String isUpload, - final String isSuperSeed, - final String colorString, - final int hits){ - if(Plugin.getDisplay() == null || Plugin.getDisplay().isDisposed()) - return; - - Plugin.getDisplay().asyncExec( new Runnable() { - public void run() { - if(Plugin.getTab2().getClientTable() == null || Plugin.getTab2().getClientTable().isDisposed()) - return; - final int item_number = Plugin.getTab2().getClientTable().getItemCount(); - final TableItem item = new TableItem(Plugin.getTab2().getClientTable(),SWT.NULL); - if (Plugin.getTab2().getClientTable().getItemCount()%2==0) { - item.setBackground(ColorUtilities.getBackgroundColor()); - } - - //set the initial hits - item.setText(7, String.valueOf(hits)); - - //column one is the number - item.setText(0,stringNumberUpOne(number)); - - - // column two is the name - item.setText(1,name); - - - - //rule Columns - TableEditor editor = new TableEditor(Plugin.getTab2().getClientTable()); - final CCombo isRegEx_combo = new CCombo(Plugin.getTab2().getClientTable(),SWT.READ_ONLY); - final Button button_isDownload = new Button (Plugin.getTab2().getClientTable(), SWT.CHECK); - final Button button_isUpload = new Button (Plugin.getTab2().getClientTable(), SWT.CHECK); - final Button button_isSuperSeed = new Button (Plugin.getTab2().getClientTable(), SWT.CHECK); - final Label colorLabel = new Label (Plugin.getTab2().getClientTable(),SWT.BORDER); - - - - editor = new TableEditor(Plugin.getTab2().getClientTable()); - isRegEx_combo.add("String"); - isRegEx_combo.add("RegEx"); - isRegEx_combo.pack (); - isRegEx_combo.setBackground(item.getBackground()); - - - editor.grabHorizontal = true; - editor.setEditor (isRegEx_combo, item, 2); - if(isRegEx.equalsIgnoreCase("1")){ - isRegEx_combo.select(1); - isRegEx_combo.clearSelection(); - }else{ - isRegEx_combo.select(0); - isRegEx_combo.clearSelection(); - } - isRegEx_combo.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - Plugin.getTab2().getClientTable().setSelection(item_number); - String position = item.getText(0); - position = stringNumberDownOne(position); - String clientName = item.getText(1); - String[] oldRules = FileUtilities.getRules(position); - if(isRegEx_combo.getSelectionIndex() == 0){ - FileUtilities.changeClientRules(position,clientName,"0",oldRules[1],oldRules[2],oldRules[3],oldRules[4]); - isRegEx_combo.clearSelection(); - }else{ - try{ - Pattern p = Pattern.compile(item.getText(1)); - Matcher m = p.matcher("Test"); - m.find(); - FileUtilities.changeClientRules(position,clientName,"1",oldRules[1],oldRules[2],oldRules[3],oldRules[4]); - isRegEx_combo.clearSelection(); - }catch(PatternSyntaxException f){ - f.printStackTrace(); - String errorText = ("Java is reporting that your RegEx is incorrectly formed, please correct this. \n\n" + - "For further information and examples, check the readme at \n\n" + - "http://azcvsupdater.sourceforge.net/stuffer/readme.txt \n\n" + - "Also check http://www.regular-expressions.info for more information\n\n" + - "Java is reporting the following problem with the expression: \n" - + f.getDescription()) + " at position " + f.getIndex() + " in the rule"; - openErrorMessageBox("Error",errorText); - isRegEx_combo.select(0); - isRegEx_combo.clearSelection(); - } - - - - - } - - } - }); - - - editor = new TableEditor(Plugin.getTab2().getClientTable()); - button_isDownload.pack (); - button_isDownload.setBackground(item.getBackground()); - editor.minimumWidth = button_isDownload.getSize ().x; - editor.horizontalAlignment = SWT.CENTER; - editor.setEditor (button_isDownload, item, 3); - if(isDownload.equalsIgnoreCase("1")){ - button_isDownload.setSelection(true); - }else{ - button_isDownload.setSelection(false); - } - button_isDownload.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - Plugin.getTab2().getClientTable().setSelection(item_number); - String position = item.getText(0); - position = stringNumberDownOne(position); - String clientName = item.getText(1); - String[] oldRules = FileUtilities.getRules(position); - if(button_isDownload.getSelection()){ - button_isSuperSeed.setSelection(false); - FileUtilities.changeClientRules(position,clientName,oldRules[0],"1",oldRules[2],"0",oldRules[4]); - - }else{ - FileUtilities.changeClientRules(position,clientName,oldRules[0],"0",oldRules[2],oldRules[3],oldRules[4]); - } - } - }); - - // Column three is isupload - editor = new TableEditor(Plugin.getTab2().getClientTable()); - //button_isUpload = new Button (Tab2.clientTable, SWT.CHECK); - button_isUpload.pack (); - button_isUpload.setBackground(item.getBackground()); - editor.minimumWidth = button_isUpload.getSize ().x; - editor.horizontalAlignment = SWT.CENTER; - editor.setEditor (button_isUpload, item, 4); - if(isUpload.equalsIgnoreCase("1")){ - button_isUpload.setSelection(true); - }else{ - button_isUpload.setSelection(false); - } - - button_isUpload.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - Plugin.getTab2().getClientTable().setSelection(item_number); - String position = item.getText(0); - position = stringNumberDownOne(position); - String clientName = item.getText(1); - String[] oldRules = FileUtilities.getRules(position); - if(button_isUpload.getSelection()){ - button_isSuperSeed.setSelection(false); - FileUtilities.changeClientRules(position,clientName,oldRules[0],oldRules[1],"1","0",oldRules[4]); - - }else{ - FileUtilities.changeClientRules(position,clientName,oldRules[0],oldRules[1],"0",oldRules[3],oldRules[4]); - } - - } - }); - - //Column four is isSuperSeed - editor = new TableEditor(Plugin.getTab2().getClientTable()); - button_isSuperSeed.pack (); - button_isSuperSeed.setBackground(item.getBackground()); - editor.minimumWidth = button_isSuperSeed.getSize ().x; - editor.horizontalAlignment = SWT.CENTER; - editor.setEditor (button_isSuperSeed, item, 5); - if(isSuperSeed.equalsIgnoreCase("1")){ - button_isSuperSeed.setSelection(true); - }else{ - button_isSuperSeed.setSelection(false); - } - button_isSuperSeed.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - Plugin.getTab2().getClientTable().setSelection(item_number); - String position = item.getText(0); - position = stringNumberDownOne(position); - String clientName = item.getText(1); - String[] oldRules = FileUtilities.getRules(position); - if(button_isSuperSeed.getSelection()){ - button_isDownload.setSelection(false); - button_isUpload.setSelection(false); - FileUtilities.changeClientRules(position,clientName,oldRules[0],"0","0","1",oldRules[4]); - - }else{ - FileUtilities.changeClientRules(position,clientName,oldRules[0],oldRules[1],oldRules[2],"0",oldRules[4]); - } - - } - }); - - - - - //Column six is color - editor = new TableEditor(Plugin.getTab2().getClientTable()); - colorLabel.pack (); - colorLabel.setToolTipText("Double-click to change color"); - Color temp_color = new Color(Plugin.getDisplay(),Utils.getRGB(colorString)); - colorLabel.setBackground(temp_color); - temp_color.dispose(); - editor.minimumWidth = 20; - editor.horizontalAlignment = SWT.CENTER; - editor.setEditor (colorLabel, item, 6); - colorLabel.addListener(SWT.MouseDown, new Listener() { - public void handleEvent(Event e) { - - Plugin.getTab2().getClientTable().setSelection(item_number); - } - }); - - colorLabel.addListener(SWT.MouseDoubleClick, new Listener() { - public void handleEvent(Event e) { - //Choose color - Plugin.getTab2().getClientTable().setSelection(item_number); - ColorDialog colorDialog1 = new ColorDialog(colorLabel.getShell()); - colorDialog1.setText("Choose Color for Client"); - colorDialog1.setRGB(colorLabel.getBackground().getRGB()); - RGB selectedColor = colorDialog1.open(); - - if(selectedColor != null){ - String position = item.getText(0); - position = stringNumberDownOne(position); - String clientName = item.getText(1); - String[] oldRules = FileUtilities.getRules(position); - Color color = new Color(Plugin.getDisplay(), - selectedColor.red, - selectedColor.green, - selectedColor.blue); - colorLabel.setBackground(color); - color.dispose(); - FileUtilities.changeClientRules(position,clientName,oldRules[0],oldRules[1],oldRules[2],oldRules[3], - "r"+colorLabel.getBackground().getRed() + "g" + colorLabel.getBackground().getGreen() + "b" + colorLabel.getBackground().getBlue()); - } - - } - }); - - - - } - }); - } - - - - /** - * Checks for view, and if present opens a message box - * @param title - * @param Message - */ - public void openErrorMessageBox(final String title, final String message){ - final Thread errorbox_thread = new Thread() { - public void run() { - if(Plugin.getDisplay() == null && Plugin.getDisplay().isDisposed()) - return; - Plugin.getDisplay().asyncExec( new Runnable() { - public void run() { - - if(errorShell != null && !errorShell.isDisposed()){ - if(errorShell.isVisible()) - return; - } - - - - errorShell = new Shell(Plugin.getDisplay(),SWT.DIALOG_TRIM); - - //Grid Layout - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - errorShell.setLayout(layout); - - - //shell title - errorShell.setText(title); - - - //Text Line 1 - Text text = new Text(errorShell, SWT.MULTI | SWT.BORDER); - GridData gridData = new GridData(GridData.FILL_BOTH); - text.setLayoutData( gridData ); - text.setText(message); - text.pack(); - - // OK Button - Button ok = new Button(errorShell, SWT.PUSH); - gridData = new GridData(GridData.HORIZONTAL_ALIGN_END); - gridData.horizontalSpan = 2; - ok.setLayoutData( gridData); - ok.setText( " OK "); - ok.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - errorShell.dispose(); - } - }); - - - //Center and open box - Utils.centerShellandOpen(errorShell); - } - }); - - } - }; - errorbox_thread.setDaemon(true); - errorbox_thread.start(); - } - - - - public String stringNumberDownOne(String position){ - try{ - int numberOfPosition = Integer.valueOf(position).intValue(); - numberOfPosition--; - return String.valueOf(numberOfPosition); - - - }catch(Exception e){ - e.printStackTrace(); - return position; - } - } - - public String stringNumberUpOne(String number){ - try{ - int numberOfPosition = Integer.valueOf(number).intValue(); - numberOfPosition++; - String newNumber =String.valueOf(numberOfPosition); - //System.out.println(numberOfPosition + ":" + newNumber); - return newNumber; - - - }catch(Exception e){ - e.printStackTrace(); - return number; - } - } - - + line1.addKeyListener(new KeyListener() { + public void keyPressed(KeyEvent e) { + //Empty + } + + public void keyReleased (KeyEvent e) { + switch (e.character){ + case SWT.ESC: + + shell.dispose(); + break; + + case SWT.CR: + + if(line1.getText().equalsIgnoreCase("") || line1.getText().equalsIgnoreCase(" ")){ + MessageBox mb = new MessageBox(Plugin.getDisplay().getActiveShell(),SWT.ICON_ERROR); + mb.setText("Error"); + mb.setMessage("Please input the client name you wish to block."); + mb.open(); + break; + } + if(!choiceString.getSelection() && !choiceRegEx.getSelection()){ + MessageBox mb = new MessageBox(Plugin.getDisplay().getActiveShell(),SWT.ICON_ERROR); + mb.setText("Error"); + mb.setMessage("Please select whether this new client's name is a regular string or a regex expression."); + mb.open(); + break; + }else{ + if(choiceString.getSelection()){ + FileUtilities.writeNewClient(line1.getText(),"0","1","1","0","r"+labelcolor.getBackground().getRed() + "g" + labelcolor.getBackground().getGreen() + "b" + labelcolor.getBackground().getBlue()); + }else{ + FileUtilities.writeNewClient(line1.getText(),"1","1","1","0","r"+labelcolor.getBackground().getRed() + "g" + labelcolor.getBackground().getGreen() + "b" + labelcolor.getBackground().getBlue()); + } + loadClientTable(-1); + shell.dispose(); + } + break; + } + } + }); + + Utils.centerShellandOpen(shell); + + } + }); + } + }; + addNew_thread.run(); + + + + } + + + + public void loadClientTable(final int selection){ + final Thread load_client_list_thread = new Thread() { + public void run() { + + try { + if(Plugin.getDisplay()== null && Plugin.getDisplay().isDisposed()) + return; + + Plugin.getDisplay().syncExec(new Runnable (){ + public void run () { + if (Plugin.getTab2().getClientTable() != null && !Plugin.getTab2().getClientTable().isDisposed()){ + Control[] controls = Plugin.getTab2().getClientTable().getChildren(); + for(int i = 0; i < controls.length ; i++){ + + controls[i].dispose(); + controls[i] = null; + } + Plugin.getTab2().getClientTable().setEnabled(true); + Plugin.getTab2().getClientTable().removeAll(); + } + + + } + }); + + FileUtilities.readClientList(); + Iterator it = Plugin.clientBlock_set.getIterator(); + while(it.hasNext()){ + ClientBlock cb = (ClientBlock)it.next(); + addTableElement(String.valueOf(cb.getIndex()), + cb.getClientName(), + (cb.get_isRegEx() ? "1" : "0"), + (cb.get_isDownloading() ? "1" : "0"), + (cb.get_isUploading() ? "1" : "0"), + (cb.get_isSuperseeding() ? "1" : "0"), + cb.getColor(), + cb.getHitsThisSession()); + } + + Plugin.getDisplay().syncExec(new Runnable (){ + public void run () { + if (Plugin.getTab2().getClientTable() !=null && !Plugin.getTab2().getClientTable().isDisposed()){ + if(selection > -1){ + Plugin.getTab2().getClientTable().setSelection(selection); + } + } + } + }); + + + /*String[][] clientList = FileUtilities.getClientList(true); + + for(int i = 0 ; i < 200 ; i++) { + if(clientList[i][0] != null){ + //add table element + addTableElement(clientList[i][0], + clientList[i][1], + clientList[i][2], + clientList[i][3], + clientList[i][4], + clientList[i][5], + clientList[i][6]); + } + + }*/ + + + } catch(Exception e) { + //Stop process and trace the exception + e.printStackTrace(); + } + } + }; + load_client_list_thread.setDaemon(true); + load_client_list_thread.start(); + + } + + + public void addTableElement(final String number, + final String name, + final String isRegEx, + final String isDownload, + final String isUpload, + final String isSuperSeed, + final String colorString, + final int hits){ + if(Plugin.getDisplay() == null || Plugin.getDisplay().isDisposed()) + return; + + Plugin.getDisplay().asyncExec( new Runnable() { + public void run() { + if(Plugin.getTab2().getClientTable() == null || Plugin.getTab2().getClientTable().isDisposed()) + return; + final int item_number = Plugin.getTab2().getClientTable().getItemCount(); + final TableItem item = new TableItem(Plugin.getTab2().getClientTable(),SWT.NULL); + if (Plugin.getTab2().getClientTable().getItemCount()%2==0) { + item.setBackground(ColorUtilities.getBackgroundColor()); + } + + //set the initial hits + item.setText(7, String.valueOf(hits)); + + //column one is the number + item.setText(0,stringNumberUpOne(number)); + + + // column two is the name + item.setText(1,name); + + + + //rule Columns + TableEditor editor = new TableEditor(Plugin.getTab2().getClientTable()); + + final Combo isRegEx_combo = new Combo(Plugin.getTab2().getClientTable(),SWT.READ_ONLY); + final Button button_isDownload = new Button (Plugin.getTab2().getClientTable(), SWT.CHECK); + final Button button_isUpload = new Button (Plugin.getTab2().getClientTable(), SWT.CHECK); + final Button button_isSuperSeed = new Button (Plugin.getTab2().getClientTable(), SWT.CHECK); + final Label colorLabel = new Label (Plugin.getTab2().getClientTable(),SWT.BORDER); + + + + editor = new TableEditor(Plugin.getTab2().getClientTable()); + isRegEx_combo.add("String"); + isRegEx_combo.add("RegEx"); + isRegEx_combo.pack (); + isRegEx_combo.setBackground(item.getBackground()); + + + editor.grabHorizontal = true; + editor.setEditor (isRegEx_combo, item, 2); + if(isRegEx.equalsIgnoreCase("1")){ + isRegEx_combo.select(1); + isRegEx_combo.clearSelection(); + }else{ + isRegEx_combo.select(0); + isRegEx_combo.clearSelection(); + } + isRegEx_combo.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event e) { + Plugin.getTab2().getClientTable().setSelection(item_number); + String position = item.getText(0); + position = stringNumberDownOne(position); + String clientName = item.getText(1); + String[] oldRules = FileUtilities.getRules(position); + if(isRegEx_combo.getSelectionIndex() == 0){ + FileUtilities.changeClientRules(position,clientName,"0",oldRules[1],oldRules[2],oldRules[3],oldRules[4]); + isRegEx_combo.clearSelection(); + }else{ + try{ + Pattern p = Pattern.compile(item.getText(1)); + Matcher m = p.matcher("Test"); + m.find(); + FileUtilities.changeClientRules(position,clientName,"1",oldRules[1],oldRules[2],oldRules[3],oldRules[4]); + isRegEx_combo.clearSelection(); + }catch(PatternSyntaxException f){ + f.printStackTrace(); + String errorText = ("Java is reporting that your RegEx is incorrectly formed, please correct this. \n\n" + + "For further information and examples, check the readme at \n\n" + + "http://azcvsupdater.sourceforge.net/stuffer/readme.txt \n\n" + + "Also check http://www.regular-expressions.info for more information\n\n" + + "Java is reporting the following problem with the expression: \n" + + f.getDescription()) + " at position " + f.getIndex() + " in the rule"; + openErrorMessageBox("Error",errorText); + isRegEx_combo.select(0); + isRegEx_combo.clearSelection(); + } + + + + + } + + } + }); + + + editor = new TableEditor(Plugin.getTab2().getClientTable()); + button_isDownload.pack (); + button_isDownload.setBackground(item.getBackground()); + editor.minimumWidth = button_isDownload.getSize ().x; + editor.horizontalAlignment = SWT.CENTER; + editor.setEditor (button_isDownload, item, 3); + if(isDownload.equalsIgnoreCase("1")){ + button_isDownload.setSelection(true); + }else{ + button_isDownload.setSelection(false); + } + button_isDownload.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event e) { + Plugin.getTab2().getClientTable().setSelection(item_number); + String position = item.getText(0); + position = stringNumberDownOne(position); + String clientName = item.getText(1); + String[] oldRules = FileUtilities.getRules(position); + if(button_isDownload.getSelection()){ + button_isSuperSeed.setSelection(false); + FileUtilities.changeClientRules(position,clientName,oldRules[0],"1",oldRules[2],"0",oldRules[4]); + + }else{ + FileUtilities.changeClientRules(position,clientName,oldRules[0],"0",oldRules[2],oldRules[3],oldRules[4]); + } + } + }); + + // Column three is isupload + editor = new TableEditor(Plugin.getTab2().getClientTable()); + //button_isUpload = new Button (Tab2.clientTable, SWT.CHECK); + button_isUpload.pack (); + button_isUpload.setBackground(item.getBackground()); + editor.minimumWidth = button_isUpload.getSize ().x; + editor.horizontalAlignment = SWT.CENTER; + editor.setEditor (button_isUpload, item, 4); + if(isUpload.equalsIgnoreCase("1")){ + button_isUpload.setSelection(true); + }else{ + button_isUpload.setSelection(false); + } + + button_isUpload.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event e) { + Plugin.getTab2().getClientTable().setSelection(item_number); + String position = item.getText(0); + position = stringNumberDownOne(position); + String clientName = item.getText(1); + String[] oldRules = FileUtilities.getRules(position); + if(button_isUpload.getSelection()){ + button_isSuperSeed.setSelection(false); + FileUtilities.changeClientRules(position,clientName,oldRules[0],oldRules[1],"1","0",oldRules[4]); + + }else{ + FileUtilities.changeClientRules(position,clientName,oldRules[0],oldRules[1],"0",oldRules[3],oldRules[4]); + } + + } + }); + + //Column four is isSuperSeed + editor = new TableEditor(Plugin.getTab2().getClientTable()); + button_isSuperSeed.pack (); + button_isSuperSeed.setBackground(item.getBackground()); + editor.minimumWidth = button_isSuperSeed.getSize ().x; + editor.horizontalAlignment = SWT.CENTER; + editor.setEditor (button_isSuperSeed, item, 5); + if(isSuperSeed.equalsIgnoreCase("1")){ + button_isSuperSeed.setSelection(true); + }else{ + button_isSuperSeed.setSelection(false); + } + button_isSuperSeed.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event e) { + Plugin.getTab2().getClientTable().setSelection(item_number); + String position = item.getText(0); + position = stringNumberDownOne(position); + String clientName = item.getText(1); + String[] oldRules = FileUtilities.getRules(position); + if(button_isSuperSeed.getSelection()){ + button_isDownload.setSelection(false); + button_isUpload.setSelection(false); + FileUtilities.changeClientRules(position,clientName,oldRules[0],"0","0","1",oldRules[4]); + + }else{ + FileUtilities.changeClientRules(position,clientName,oldRules[0],oldRules[1],oldRules[2],"0",oldRules[4]); + } + + } + }); + + + + + //Column six is color + editor = new TableEditor(Plugin.getTab2().getClientTable()); + colorLabel.pack (); + colorLabel.setToolTipText("Double-click to change color"); + Color temp_color = new Color(Plugin.getDisplay(),Utils.getRGB(colorString)); + colorLabel.setBackground(temp_color); + temp_color.dispose(); + editor.minimumWidth = 20; + editor.horizontalAlignment = SWT.CENTER; + editor.setEditor (colorLabel, item, 6); + colorLabel.addListener(SWT.MouseDown, new Listener() { + public void handleEvent(Event e) { + + Plugin.getTab2().getClientTable().setSelection(item_number); + } + }); + + colorLabel.addListener(SWT.MouseDoubleClick, new Listener() { + public void handleEvent(Event e) { + //Choose color + Plugin.getTab2().getClientTable().setSelection(item_number); + ColorDialog colorDialog1 = new ColorDialog(colorLabel.getShell()); + colorDialog1.setText("Choose Color for Client"); + colorDialog1.setRGB(colorLabel.getBackground().getRGB()); + RGB selectedColor = colorDialog1.open(); + + if(selectedColor != null){ + String position = item.getText(0); + position = stringNumberDownOne(position); + String clientName = item.getText(1); + String[] oldRules = FileUtilities.getRules(position); + Color color = new Color(Plugin.getDisplay(), + selectedColor.red, + selectedColor.green, + selectedColor.blue); + colorLabel.setBackground(color); + color.dispose(); + FileUtilities.changeClientRules(position,clientName,oldRules[0],oldRules[1],oldRules[2],oldRules[3], + "r"+colorLabel.getBackground().getRed() + "g" + colorLabel.getBackground().getGreen() + "b" + colorLabel.getBackground().getBlue()); + } + + } + }); + + + + } + }); + } + + + + /** + * Checks for view, and if present opens a message box + * @param title + * @param Message + */ + public void openErrorMessageBox(final String title, final String message){ + final Thread errorbox_thread = new Thread() { + public void run() { + if(Plugin.getDisplay() == null && Plugin.getDisplay().isDisposed()) + return; + Plugin.getDisplay().asyncExec( new Runnable() { + public void run() { + + if(errorShell != null && !errorShell.isDisposed()){ + if(errorShell.isVisible()) + return; + } + + + + errorShell = new Shell(Plugin.getDisplay(),SWT.DIALOG_TRIM); + + //Grid Layout + GridLayout layout = new GridLayout(); + layout.numColumns = 1; + errorShell.setLayout(layout); + + + //shell title + errorShell.setText(title); + + + //Text Line 1 + Text text = new Text(errorShell, SWT.MULTI | SWT.BORDER); + GridData gridData = new GridData(GridData.FILL_BOTH); + text.setLayoutData( gridData ); + text.setText(message); + text.pack(); + + // OK Button + Button ok = new Button(errorShell, SWT.PUSH); + gridData = new GridData(GridData.HORIZONTAL_ALIGN_END); + gridData.horizontalSpan = 2; + ok.setLayoutData( gridData); + ok.setText( " OK "); + ok.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event e) { + errorShell.dispose(); + } + }); + + + //Center and open box + Utils.centerShellandOpen(errorShell); + } + }); + + } + }; + errorbox_thread.setDaemon(true); + errorbox_thread.start(); + + } + + + + public String stringNumberDownOne(String position){ + try{ + int numberOfPosition = Integer.valueOf(position).intValue(); + numberOfPosition--; + return String.valueOf(numberOfPosition); + + + }catch(Exception e){ + e.printStackTrace(); + return position; + } + } + + public String stringNumberUpOne(String number){ + try{ + int numberOfPosition = Integer.valueOf(number).intValue(); + numberOfPosition++; + String newNumber =String.valueOf(numberOfPosition); + //System.out.println(numberOfPosition + ":" + newNumber); + return newNumber; + + + }catch(Exception e){ + e.printStackTrace(); + return number; + } + } + + /* public void renumberMOD_BAD(final boolean MOD, final boolean BAD){ - if(Plugin.getDisplay() == null || Plugin.getDisplay().isDisposed()){ - return; - } - - Plugin.getDisplay().asyncExec(new Runnable (){ - public void run () { - if(MOD){ - if(Tab2.MOD_block_num != null || !Tab2.MOD_block_num.isDisposed()){ - Tab2.MOD_block_num.setText(String.valueOf(Constants.MOD_CLIENT_BLOCKS)); - Tab2.MOD_block_num.getParent().layout(); - } - } - - if(BAD){ - if(Tab2.BAD_block_num != null || !Tab2.BAD_block_num.isDisposed()){ - Tab2.BAD_block_num.setText(String.valueOf(Constants.BAD_CLIENT_BLOCKS)); - Tab2.BAD_block_num.getParent().layout(); - } - } - - - - } - }); - }*/ - - /** - * Change the number of Hits for a given client at index - * @param index - * @param state (0 for Change to 0, 1 for increase, 2 for decrease) - */ - public void changeHits(final int index, final int state, final ClientBlock cb){ - try{ - - if(Plugin.getDisplay() != null && !Plugin.getDisplay().isDisposed()){ - Plugin.getDisplay().asyncExec(new Runnable (){ - public void run () { - if(Plugin.getTab2().getClientTable() == null || Plugin.getTab2().getClientTable().isDisposed()) - return; - TableItem[] items = Plugin.getTab2().getClientTable().getItems(); - items[index].setText(7, String.valueOf(cb.getHitsThisSession())); - } - }); - } - - - }catch(Exception e){ - e.printStackTrace(); - } - } - + if(Plugin.getDisplay() == null || Plugin.getDisplay().isDisposed()){ + return; + } + + Plugin.getDisplay().asyncExec(new Runnable (){ + public void run () { + if(MOD){ + if(Tab2.MOD_block_num != null || !Tab2.MOD_block_num.isDisposed()){ + Tab2.MOD_block_num.setText(String.valueOf(Constants.MOD_CLIENT_BLOCKS)); + Tab2.MOD_block_num.getParent().layout(); + } + } + + if(BAD){ + if(Tab2.BAD_block_num != null || !Tab2.BAD_block_num.isDisposed()){ + Tab2.BAD_block_num.setText(String.valueOf(Constants.BAD_CLIENT_BLOCKS)); + Tab2.BAD_block_num.getParent().layout(); + } + } + + + + } + }); + }*/ + + /** + * Change the number of Hits for a given client at index + * @param index + * @param state (0 for Change to 0, 1 for increase, 2 for decrease) + */ + public void changeHits(final int index, final int state, final ClientBlock cb){ + try{ + + if(Plugin.getDisplay() != null && !Plugin.getDisplay().isDisposed()){ + Plugin.getDisplay().asyncExec(new Runnable (){ + public void run () { + if(Plugin.getTab2().getClientTable() == null || Plugin.getTab2().getClientTable().isDisposed()) + return; + TableItem[] items = Plugin.getTab2().getClientTable().getItems(); + items[index].setText(7, String.valueOf(cb.getHitsThisSession())); + } + }); + } + + + }catch(... [truncated message content] |
From: <oms...@us...> - 2007-07-20 16:52:22
|
Revision: 987 http://svn.sourceforge.net/azcvsupdater/?rev=987&view=rev Author: omschaub Date: 2007-07-20 09:52:19 -0700 (Fri, 20 Jul 2007) Log Message: ----------- Stuffer tweaks for the86734573845385734853847 Modified Paths: -------------- trunk/omschaub/omschaub/stuffer/containers/TotalPeerSetUtils.java trunk/omschaub/omschaub/stuffer/main/DownloadImp.java trunk/omschaub/omschaub/stuffer/main/Plugin.java trunk/omschaub/omschaub/stuffer/main/Tab3.java trunk/omschaub/omschaub/stuffer/main/Utils.java trunk/omschaub/omschaub/stuffer/main/View.java Modified: trunk/omschaub/omschaub/stuffer/containers/TotalPeerSetUtils.java =================================================================== --- trunk/omschaub/omschaub/stuffer/containers/TotalPeerSetUtils.java 2007-05-10 16:55:01 UTC (rev 986) +++ trunk/omschaub/omschaub/stuffer/containers/TotalPeerSetUtils.java 2007-07-20 16:52:19 UTC (rev 987) @@ -97,7 +97,7 @@ return map.size(); } - public Listener sortByIP(){ +/* public Listener sortByIP(){ Listener sortListener = new Listener() { public void handleEvent(Event e) { @@ -111,6 +111,6 @@ } }; return sortListener; - } + }*/ } Modified: trunk/omschaub/omschaub/stuffer/main/DownloadImp.java =================================================================== --- trunk/omschaub/omschaub/stuffer/main/DownloadImp.java 2007-05-10 16:55:01 UTC (rev 986) +++ trunk/omschaub/omschaub/stuffer/main/DownloadImp.java 2007-07-20 16:52:19 UTC (rev 987) @@ -153,6 +153,12 @@ e.printStackTrace(); failedCommands(); } + + public void reportAmountComplete(ResourceDownloader arg0, + long arg1) { + // TODO Auto-generated method stub + + } }; rd_t.addListener(rdl); Modified: trunk/omschaub/omschaub/stuffer/main/Plugin.java =================================================================== --- trunk/omschaub/omschaub/stuffer/main/Plugin.java 2007-05-10 16:55:01 UTC (rev 986) +++ trunk/omschaub/omschaub/stuffer/main/Plugin.java 2007-07-20 16:52:19 UTC (rev 987) @@ -66,9 +66,9 @@ //The main Tab2 private static Tab2 MainTab2; private static Tab2Utilities tab2Utilities; - +/* //The main Tab3 - private static Tab3 MainTab3; + private static Tab3 MainTab3;*/ public void initialize(final PluginInterface pluginInterface) { this.pluginInterface = pluginInterface; @@ -129,7 +129,7 @@ MainTab1 = new Tab1(); MainTab2 = new Tab2(); tab2Utilities = new Tab2Utilities(); - MainTab3 = new Tab3(); + // MainTab3 = new Tab3(); }//End of Initialize @@ -159,10 +159,10 @@ public static Tab2 getTab2(){ return MainTab2; } - +/* public static Tab3 getTab3(){ return MainTab3; - } + }*/ public static Tab2Utilities getTab2Utilities(){ return tab2Utilities; @@ -367,7 +367,7 @@ } - public static void startTPCRuleRun(){ + /* public static void startTPCRuleRun(){ UTTimer peer_timer=pi.getUtilities().createTimer("stuffer_tpc_timer"); peer_timer.addPeriodicEvent(1000*6, new UTTimerEventPerformer() @@ -407,8 +407,8 @@ }); } +*/ - public static Display getDisplay(){ return display; } Modified: trunk/omschaub/omschaub/stuffer/main/Tab3.java =================================================================== --- trunk/omschaub/omschaub/stuffer/main/Tab3.java 2007-05-10 16:55:01 UTC (rev 986) +++ trunk/omschaub/omschaub/stuffer/main/Tab3.java 2007-07-20 16:52:19 UTC (rev 987) @@ -2,7 +2,7 @@ * Created on Sep 30, 2005 * Created by omschaub * - */ + package omschaub.stuffer.main; @@ -295,3 +295,4 @@ }//EOF +*/ \ No newline at end of file Modified: trunk/omschaub/omschaub/stuffer/main/Utils.java =================================================================== --- trunk/omschaub/omschaub/stuffer/main/Utils.java 2007-05-10 16:55:01 UTC (rev 986) +++ trunk/omschaub/omschaub/stuffer/main/Utils.java 2007-07-20 16:52:19 UTC (rev 987) @@ -199,8 +199,8 @@ }//End of Peer for loop - //pop the tab3 table - Plugin.getTab3().resetTable(); + /*//pop the tab3 table + Plugin.getTab3().resetTable();*/ }// End of if peer != null Modified: trunk/omschaub/omschaub/stuffer/main/View.java =================================================================== --- trunk/omschaub/omschaub/stuffer/main/View.java 2007-05-10 16:55:01 UTC (rev 986) +++ trunk/omschaub/omschaub/stuffer/main/View.java 2007-07-20 16:52:19 UTC (rev 987) @@ -114,11 +114,11 @@ CTabItem tab1 = new CTabItem(tab,SWT.NONE); CTabItem tab2 = new CTabItem(tab,SWT.NONE); - CTabItem tab3 = new CTabItem(tab,SWT.NONE); + //CTabItem tab3 = new CTabItem(tab,SWT.NONE); tab1.setText("Activity"); tab2.setText("Settings"); - tab3.setText("Data Mining"); + //tab3.setText("Data Mining"); //composite for tab1 @@ -159,13 +159,13 @@ //open for tab2 Plugin.getTab2().open(composite_for_tab2); - //open for tab3 + /* //open for tab3 Plugin.getTab3().open(composite_for_tab3); - + */ //tab controls tab1.setControl(composite_for_tab1); tab2.setControl(composite_for_tab2); - tab3.setControl(composite_for_tab3); + // tab3.setControl(composite_for_tab3); parent.pack(); parent.layout(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <oms...@us...> - 2007-05-10 16:55:00
|
Revision: 986 http://svn.sourceforge.net/azcvsupdater/?rev=986&view=rev Author: omschaub Date: 2007-05-10 09:55:01 -0700 (Thu, 10 May 2007) Log Message: ----------- Adding unimplemented new features of Azureus to fix the code Modified Paths: -------------- trunk/omschaub/omschaub/azcvsupdater/utilities/download/DownloadImp.java trunk/omschaub/omschaub/aztrackerfind/main/Downloader.java trunk/omschaub/omschaub/aztrackerfind/main/TorrentUtils.java Modified: trunk/omschaub/omschaub/azcvsupdater/utilities/download/DownloadImp.java =================================================================== --- trunk/omschaub/omschaub/azcvsupdater/utilities/download/DownloadImp.java 2007-01-13 03:53:27 UTC (rev 985) +++ trunk/omschaub/omschaub/azcvsupdater/utilities/download/DownloadImp.java 2007-05-10 16:55:01 UTC (rev 986) @@ -173,6 +173,12 @@ e.printStackTrace(); failedCommands(); } + + public void reportAmountComplete(ResourceDownloader arg0, + long arg1) { + // TODO Auto-generated method stub + + } }; rd_t.addListener(rdl); Modified: trunk/omschaub/omschaub/aztrackerfind/main/Downloader.java =================================================================== --- trunk/omschaub/omschaub/aztrackerfind/main/Downloader.java 2007-01-13 03:53:27 UTC (rev 985) +++ trunk/omschaub/omschaub/aztrackerfind/main/Downloader.java 2007-05-10 16:55:01 UTC (rev 986) @@ -155,6 +155,12 @@ } + public void reportAmountComplete( + ResourceDownloader arg0, long arg1) { + // TODO Auto-generated method stub + + } + }); @@ -238,6 +244,12 @@ System.out.println(e); } + + public void reportAmountComplete( + ResourceDownloader arg0, long arg1) { + // TODO Auto-generated method stub + + } }); rd_t.asyncDownload(); Modified: trunk/omschaub/omschaub/aztrackerfind/main/TorrentUtils.java =================================================================== --- trunk/omschaub/omschaub/aztrackerfind/main/TorrentUtils.java 2007-01-13 03:53:27 UTC (rev 985) +++ trunk/omschaub/omschaub/aztrackerfind/main/TorrentUtils.java 2007-05-10 16:55:01 UTC (rev 986) @@ -258,6 +258,12 @@ } read_torrent_dir(pluginInterface,"",type_to_sort); } + + public void reportAmountComplete(ResourceDownloader arg0, + long arg1) { + // TODO Auto-generated method stub + + } }); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <oms...@us...> - 2007-01-13 03:53:27
|
Revision: 985 http://svn.sourceforge.net/azcvsupdater/?rev=985&view=rev Author: omschaub Date: 2007-01-12 19:53:27 -0800 (Fri, 12 Jan 2007) Log Message: ----------- Fixing issue with new Azureus3 name so that it shows in the list Modified Paths: -------------- trunk/omschaub/omschaub/azcvsupdater/main/Tab1Utils.java Modified: trunk/omschaub/omschaub/azcvsupdater/main/Tab1Utils.java =================================================================== --- trunk/omschaub/omschaub/azcvsupdater/main/Tab1Utils.java 2006-12-13 19:04:45 UTC (rev 984) +++ trunk/omschaub/omschaub/azcvsupdater/main/Tab1Utils.java 2007-01-13 03:53:27 UTC (rev 985) @@ -1,7 +1,7 @@ /* * Created on Feb 6, 2005 * Created by omschaub - * + * */ package omschaub.azcvsupdater.main; @@ -30,10 +30,10 @@ */ public class Tab1Utils { - - + + /** Delete the Selected File - * + * * @param filetodie * @param name */ @@ -45,30 +45,30 @@ ButtonStatus.set(true, true, false, true,true); return; } - Thread deleteFileThread = new Thread() + Thread deleteFileThread = new Thread() { - public void run() - { - + public void run() + { + final File timetodie = new File(filetodie); if (timetodie.isDirectory() == true) { StatusBoxUtils.mainStatusAdd(" You seem to have chosen a directory.. Action Cancelled",2); return; } - + if (timetodie.isFile() == false) { StatusBoxUtils.mainStatusAdd("Please select a file first",2); return; } - + if(View.getDisplay()==null && View.getDisplay().isDisposed()) return; - + View.DML_BOOLEAN = false; View.getDisplay().asyncExec(new Runnable (){ - public void run () + public void run () { Shell shell = new Shell(View.getDisplay()); MessageBox messageBox = new MessageBox(shell, SWT.ICON_QUESTION | SWT.NO | SWT.YES); @@ -84,7 +84,7 @@ { timetodie.delete(); //System.out.println("AZCVSUPDATER: dml_boolean is false.. straight delete"); - + } StatusBoxUtils.mainStatusAdd(" Deleted file " + timetodie,0); File checkdir = new File(DirectoryUtils.getBackupDirectory() + System.getProperty("file.separator") + "comments"); @@ -94,13 +94,13 @@ { comment_delete(inFile); } - + } catch (Exception e) { e.printStackTrace() ; } - + loadDirectory(View.getPluginInterface().getPluginconfig().getPluginIntParameter("Azureus_TableSort",2)); Tab6Utils.refreshLists(); //StatusBoxUtils.mainStatusAdd(" File Deleted"); @@ -127,7 +127,7 @@ deleteFileThread.setDaemon(true); deleteFileThread.start(); } - + public static void delete_multiple_files(TableItem[] list_item){ String label_files=""; String fileName; @@ -136,9 +136,9 @@ TableItem item = list_item[i]; fileName = item.getText(0); label_files=label_files + fileName + "\n"; - + } - + Shell shell = new Shell(); MessageBox messageBox = new MessageBox(shell, SWT.ICON_QUESTION | SWT.NO | SWT.YES); messageBox.setText("Delete Confirmation"); @@ -150,9 +150,9 @@ for (int i = 0; i< list_item.length; i++){ TableItem item = list_item[i]; fileName = item.getText(0); - + File timetodie = new File(backup_dir + System.getProperty("file.separator") + fileName); - + if (timetodie == null){ if (Tab1.listTable != null && !Tab1.listTable.isDisposed()){ Tab1.listTable.deselectAll(); @@ -160,18 +160,18 @@ ButtonStatus.set(true, true, false, true, true); return; } - - - + + + if (timetodie.isDirectory() == true){ - + StatusBoxUtils.mainStatusAdd(" You seem to have chosen a directory.. Action Cancelled",2); - + return; } - + if (timetodie.isFile() == false){ - + StatusBoxUtils.mainStatusAdd(" Error.. File to delete does not seem to be an actual file",2); return; @@ -179,65 +179,65 @@ MainCVSGet.removeDownload(fileName,View.getPluginInterface()); if(!View.DML_BOOLEAN); { - timetodie.delete(); + timetodie.delete(); } - + StatusBoxUtils.mainStatusAdd(" Deleted file " + timetodie,0); - + //check for comment file File checkdir = new File(backup_dir + System.getProperty("file.separator") + "comments"); File inFile = new File(checkdir + System.getProperty("file.separator") + fileName+".txt"); //String commentFile = new String(checkdir + System.getProperty("file.separator") + fileName+".txt"); if (inFile.isFile()){ comment_delete(inFile); - + } } - + } catch (Exception e){ e.printStackTrace() ; } - + StatusBoxUtils.mainStatusAdd(" Multiple Files Deleted",0); - + shell.dispose(); loadDirectory(View.getPluginInterface().getPluginconfig().getPluginIntParameter("Azureus_TableSort",2)); Tab6Utils.refreshLists(); break; case SWT.NO: - + StatusBoxUtils.mainStatusAdd(" Multiple File Deletion Cancelled",0); - + shell.dispose(); break; } } - - - + + + public static void loadDirectory(final int type) { if(View.LOAD_DIR){ View.LOAD_DIR = false; return; } - + View.LOAD_DIR = true; //String installdirectory = DirectoryUtils.getInstallDirectory(); final Thread load_directory_thread = new Thread() { public void run() { try { - + if(View.getDisplay()== null && View.getDisplay().isDisposed()) return; - + View.getDisplay().syncExec(new Runnable (){ public void run () { if (Tab1.listTable !=null && !Tab1.listTable.isDisposed()){ /*Control[] controls = Tab1.listTable.getChildren(); for(int i = 0; i < controls.length ; i++){ - + controls[i].dispose(); controls[i] = null; }*/ @@ -258,14 +258,14 @@ Tab1.downloadVisible(false,false); } } - + } }); File [] files = fileDateSort(type); for(int i = 0 ; i < files.length ; i++) { String fileName = files[i].getName(); - if(!fileName.startsWith("Azureus2")) + if(!fileName.startsWith("Azureus")) continue; int fileSizeInKB = 0; try { @@ -281,10 +281,10 @@ //urlMap.put(fileName,fileURL); addTableElement(fileName,fileSizeInKB,lastModified,Tab1.listTable); } - + //We also need to re-enable the browse button ButtonStatus.set(true, true, false, true, true); - + View.LOAD_DIR = false; } catch(Exception e) { @@ -293,14 +293,14 @@ } } }; - + //Before starting our Thread, we remove all elements in the table if(View.getDisplay()==null && View.getDisplay().isDisposed()) return; View.getDisplay().asyncExec(new Runnable (){ public void run () { if (Tab1.listTable !=null && !Tab1.listTable.isDisposed()){ - + Tab1.listTable.removeAll(); Tab1.listTable.redraw(); Tab1.listTable.setEnabled(true); @@ -309,11 +309,11 @@ load_directory_thread.start(); } }); - - + + } - - + + public static void comment_delete(File commentFiletoDie){ Shell shell = new Shell(); MessageBox messageBox = new MessageBox(shell, SWT.ICON_QUESTION | SWT.NO | SWT.YES); @@ -329,23 +329,23 @@ shell.dispose(); break; case SWT.NO: - + //this.mainStatus.setText(" Idle..."); shell.dispose(); break; } - + } public static void addTableElement(final String fileName,final int fileSizeInKb,final long lastModified, final Table table_to_add /*,final String fileURL*/) { if(View.getDisplay() == null || View.getDisplay().isDisposed()) return; - + View.getDisplay().asyncExec( new Runnable() { public void run() { if(table_to_add == null || table_to_add.isDisposed()) - return; + return; TableItem item = new TableItem(table_to_add,SWT.NULL); if (table_to_add.getItemCount()%2==0) { item.setBackground(ColorUtilities.getBackgroundColor()); @@ -364,23 +364,23 @@ } else { - sdf = new SimpleDateFormat("MM/dd/yyy hh:mm:ss aa" ); + sdf = new SimpleDateFormat("MM/dd/yyy hh:mm:ss aa" ); } - + sdf.setTimeZone(TimeZone.getDefault()); String date = sdf.format(when); - + item.setText(2,date); - + String textTemp; textTemp = CommentMaker.commentFirstLine(fileName); item.setText(3,textTemp); - - - } + + + } }); - - + + } public static File[] fileDateSort(int type){ @@ -392,28 +392,28 @@ *type = 4 is Size ascending *type = 5 is Size descending **/ - + File f = new File(DirectoryUtils.getBackupDirectory()); File[] files = f.listFiles(); int filesLength = files.length; long[] fileModified = new long[ filesLength ]; long[] fileSize = new long[ filesLength]; - + // Parsing for ( int i = 0; i < filesLength; i++ ){ - fileModified[i] = files[i].lastModified(); + fileModified[i] = files[i].lastModified(); fileSize[i] = files[i].length(); } - + // Bubblesort - + //type 0 = Date of CVS Build ascending if (type==0){ for ( int i = 0; i < filesLength; i++ ){ for ( int j = 0; j < filesLength - 1; j++ ){ // This does the actual comparison - if ( fileModified[j] < fileModified[j+1] || + if ( fileModified[j] < fileModified[j+1] || ( fileModified[j] == fileModified[j+1] && files[j].compareTo( files[j+1] ) > 0 ) ){ // Swapping fileModified[j] ^= fileModified[j+1]; @@ -424,14 +424,14 @@ files[j+1] = temp; } } - } + } } //type 1 = Date of CVS Build descending if (type==1){ for ( int i = 0; i < filesLength; i++ ){ for ( int j = 0; j < filesLength - 1; j++ ){ // This does the actual comparison - if ( fileModified[j] > fileModified[j+1] || + if ( fileModified[j] > fileModified[j+1] || ( fileModified[j] == fileModified[j+1] && files[j].compareTo( files[j+1] ) > 0 ) ){ // Swapping fileModified[j] ^= fileModified[j+1]; @@ -445,14 +445,14 @@ } } - + //type = 2 is File ascending if (type==2){ for ( int i = 0; i < filesLength; i++ ){ for ( int j = 0; j < filesLength - 1; j++ ){ // This does the actual comparison - if ( files[j].compareTo( files [j+1]) > 0 || + if ( files[j].compareTo( files [j+1]) > 0 || ( files[j].compareTo( files[j+1]) == 0 && fileModified[j] > fileModified[j+1]) ){ // Swapping fileModified[j] ^= fileModified[j+1]; @@ -463,16 +463,16 @@ files[j+1] = temp; } } - } + } } - + // type = 3 is File descending if (type==3){ for ( int i = 0; i < filesLength; i++ ){ for ( int j = 0; j < filesLength - 1; j++ ){ // This does the actual comparison - if ( files[j+1].compareTo( files [j]) > 0 || + if ( files[j+1].compareTo( files [j]) > 0 || ( files[j+1].compareTo( files[j]) == 0 && fileModified[j] > fileModified[j+1]) ){ // Swapping fileModified[j] ^= fileModified[j+1]; @@ -483,15 +483,15 @@ files[j+1] = temp; } } - } + } } - + //type = 4 is Size ascending if (type==4){ for ( int i = 0; i < filesLength; i++ ){ for ( int j = 0; j < filesLength - 1; j++ ){ // This does the actual comparison - if ( fileSize[j] < fileSize[j+1] || + if ( fileSize[j] < fileSize[j+1] || ( fileSize[j] == fileSize[j+1] && files[j].compareTo( files[j+1] ) > 0 ) ){ // Swapping fileSize[j] ^= fileSize[j+1]; @@ -502,7 +502,7 @@ files[j+1] = temp; } } - } + } } //type = 5 is Size descending @@ -510,7 +510,7 @@ for ( int i = 0; i < filesLength; i++ ){ for ( int j = 0; j < filesLength - 1; j++ ){ // This does the actual comparison - if ( fileSize[j] > fileSize[j+1] || + if ( fileSize[j] > fileSize[j+1] || ( fileSize[j] == fileSize[j+1] && files[j].compareTo( files[j+1] ) > 0 ) ){ // Swapping fileSize[j] ^= fileSize[j+1]; @@ -523,11 +523,11 @@ } } } - + return files; } - -/* + +/* public static String CVSurlGetter(String cvs_name) { String sourceFile = "mail_list.cache"; String sourceDir = View.getPluginInterface().getPluginDirectoryName() + System.getProperty("file.separator"); @@ -562,11 +562,11 @@ } in.close(); return "http://sourceforge.net/mailarchive/" + inputLine.substring(beginningIndex,endIndex); - + } - - - + + + } in.close(); return url; @@ -575,10 +575,10 @@ } return "empty"; }*/ - - + + public static boolean string_Contains(String inputLine, String searchLine){ - boolean answer = false; + boolean answer = false; //String tempHolder=""; int nPos = 0; while(true){ @@ -595,7 +595,7 @@ return answer; } - - - //EOF + + + //EOF } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mag...@us...> - 2006-12-13 19:28:29
|
Revision: 984 http://svn.sourceforge.net/azcvsupdater/?rev=984&view=rev Author: magebarf Date: 2006-12-13 11:04:45 -0800 (Wed, 13 Dec 2006) Log Message: ----------- Somewhat a fix for bug 1593005 - Bad recursive behaviour on change backup directory. Does not fix the source of the problem, but removes the bad consequences if bug were to occur. Modified Paths: -------------- trunk/omschaub/omschaub/azcvsupdater/utilities/DirectoryChanger.java Modified: trunk/omschaub/omschaub/azcvsupdater/utilities/DirectoryChanger.java =================================================================== --- trunk/omschaub/omschaub/azcvsupdater/utilities/DirectoryChanger.java 2006-12-13 18:58:55 UTC (rev 983) +++ trunk/omschaub/omschaub/azcvsupdater/utilities/DirectoryChanger.java 2006-12-13 19:04:45 UTC (rev 984) @@ -809,6 +809,12 @@ private static void copyFiles(final String oldDir_copy, final String newDir_copy){ + + if (newDir_copy.startsWith(oldDir_copy)) + { + return; + } + File oldDir_file = new File(oldDir_copy); String[] files = oldDir_file.list(); try{ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mag...@us...> - 2006-12-13 19:00:36
|
Revision: 983 http://svn.sourceforge.net/azcvsupdater/?rev=983&view=rev Author: magebarf Date: 2006-12-13 10:58:55 -0800 (Wed, 13 Dec 2006) Log Message: ----------- Fix for "bug" request-id: 1528298 - Wrong Changelog URL Modified Paths: -------------- trunk/omschaub/omschaub/azcvsupdater/main/Constants.java Modified: trunk/omschaub/omschaub/azcvsupdater/main/Constants.java =================================================================== --- trunk/omschaub/omschaub/azcvsupdater/main/Constants.java 2006-07-28 11:29:37 UTC (rev 982) +++ trunk/omschaub/omschaub/azcvsupdater/main/Constants.java 2006-12-13 18:58:55 UTC (rev 983) @@ -8,7 +8,7 @@ public final class Constants { //URL for Azureus Changelog - final static String AZUREUS_CHANGELOG_URL = "http://cvs.sourceforge.net/viewcvs.py/*checkout*/azureus/azureus2/ChangeLog.txt?rev=HEAD"; + final static String AZUREUS_CHANGELOG_URL = "http://azureus.cvs.sourceforge.net/azureus/azureus2/ChangeLog.txt?revision=HEAD"; //URL for Developmental Mail Archive final static String DEVELOPMENTAL_MAIL_ARCHIVE_URL = "http://sourceforge.net/mailarchive/forum.php?max_rows=25&offset=0&forum_id=40629"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dam...@us...> - 2006-07-28 11:29:43
|
Revision: 982 Author: damokles Date: 2006-07-28 04:29:37 -0700 (Fri, 28 Jul 2006) ViewCVS: http://svn.sourceforge.net/azcvsupdater/?rev=982&view=rev Log Message: ----------- changed the checking a bit like Vladimir suggested Modified Paths: -------------- trunk/AzCatDest/lbms/azcatdest/main/AzCatDestDownloadListener.java Modified: trunk/AzCatDest/lbms/azcatdest/main/AzCatDestDownloadListener.java =================================================================== --- trunk/AzCatDest/lbms/azcatdest/main/AzCatDestDownloadListener.java 2006-07-03 19:44:25 UTC (rev 981) +++ trunk/AzCatDest/lbms/azcatdest/main/AzCatDestDownloadListener.java 2006-07-28 11:29:37 UTC (rev 982) @@ -20,7 +20,7 @@ } public void stateChanged(final Download download, int old_state, int new_state) { - if (old_state == Download.ST_DOWNLOADING && new_state == Download.ST_SEEDING) { + if (old_state == Download.ST_DOWNLOADING && download.isComplete()) { String cat = download.getAttribute(ta); download.removeListener(instance); //remove listener so it wont be triggered twice if (cat != null) { //a Category was This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dam...@us...> - 2006-07-03 19:44:36
|
Revision: 981 Author: damokles Date: 2006-07-03 12:44:25 -0700 (Mon, 03 Jul 2006) ViewCVS: http://svn.sourceforge.net/azcvsupdater/?rev=981&view=rev Log Message: ----------- Delete the old project since it moved to AzSMRC Removed Paths: ------------- trunk/AZMultiUser/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dam...@us...> - 2006-07-03 19:44:00
|
Revision: 980 Author: damokles Date: 2006-07-03 12:43:52 -0700 (Mon, 03 Jul 2006) ViewCVS: http://svn.sourceforge.net/azcvsupdater/?rev=980&view=rev Log Message: ----------- small change upon request Modified Paths: -------------- trunk/AzCatDest/lbms/azcatdest/main/AzCatDestDownloadListener.java Modified: trunk/AzCatDest/lbms/azcatdest/main/AzCatDestDownloadListener.java =================================================================== --- trunk/AzCatDest/lbms/azcatdest/main/AzCatDestDownloadListener.java 2006-05-23 16:16:07 UTC (rev 979) +++ trunk/AzCatDest/lbms/azcatdest/main/AzCatDestDownloadListener.java 2006-07-03 19:43:52 UTC (rev 980) @@ -6,26 +6,26 @@ import org.gudy.azureus2.plugins.torrent.TorrentAttribute; public class AzCatDestDownloadListener implements org.gudy.azureus2.plugins.download.DownloadListener { - + static private AzCatDestDownloadListener instance = new AzCatDestDownloadListener(); static private TorrentAttribute ta = Plugin.getPluginInterface().getTorrentManager().getAttribute(TorrentAttribute.TA_CATEGORY); - + private AzCatDestDownloadListener() {} - + public static AzCatDestDownloadListener getInstance() { return instance; } - + public void positionChanged(Download download, int oldPosition, int newPosition) { } - + public void stateChanged(final Download download, int old_state, int new_state) { - if (new_state == Download.ST_SEEDING) { + if (old_state == Download.ST_DOWNLOADING && new_state == Download.ST_SEEDING) { String cat = download.getAttribute(ta); download.removeListener(instance); //remove listener so it wont be triggered twice - if (cat != null) { //a Category was + if (cat != null) { //a Category was try { - String dest = Plugin.getProperties().getProperty(cat, null); + String dest = Plugin.getProperties().getProperty(cat, null); if (dest!=null) { if(!dest.equalsIgnoreCase("")) { File destFile = new File(dest); @@ -37,7 +37,7 @@ // TODO Auto-generated catch block e.printStackTrace(); } - } + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <oms...@us...> - 2006-05-23 16:16:18
|
Revision: 979 Author: omschaub Date: 2006-05-23 09:16:07 -0700 (Tue, 23 May 2006) ViewCVS: http://svn.sourceforge.net/azcvsupdater/?rev=979&view=rev Log Message: ----------- Fixing this horrid string-y mess! Modified Paths: -------------- trunk/omschaub/omschaub/stuffer/main/Plugin.java trunk/omschaub/omschaub/stuffer/main/Tab1.java Modified: trunk/omschaub/omschaub/stuffer/main/Plugin.java =================================================================== --- trunk/omschaub/omschaub/stuffer/main/Plugin.java 2006-05-22 18:31:05 UTC (rev 978) +++ trunk/omschaub/omschaub/stuffer/main/Plugin.java 2006-05-23 16:16:07 UTC (rev 979) @@ -210,7 +210,7 @@ IPFilter ipf = new IPFilterImpl(); IPRange[] ipr = ipf.getRanges(); for(int i = 0; i < ipr.length; i++){ - if (ipr[i].getDescription().startsWith("Stuffer")){ + if (ipr[i].getDescription().startsWith("Stuffer") || ipr[i].getDescription().startsWith("stuffer")){ ipr[i].delete(); if(Plugin.getTab1() != null) Plugin.getTab1().addElementPeer(ipr[i].getDescription(), ipr[i].getStartIP(), "Interval"); @@ -275,7 +275,7 @@ IPFilter ipf = new IPFilterImpl(); IPRange[] ipr = ipf.getRanges(); for(int i = 0; i < ipr.length; i++){ - if (ipr[i].getDescription().startsWith("Stuffer")){ + if (ipr[i].getDescription().startsWith("Stuffer")|| ipr[i].getDescription().startsWith("stuffer")){ ipr[i].delete(); if(Plugin.getTab1() != null) Plugin.getTab1().addElementPeer(ipr[i].getDescription(), ipr[i].getStartIP(), "Interval"); @@ -303,7 +303,7 @@ IPFilter ipf = new IPFilterImpl(); IPRange[] ipr = ipf.getRanges(); for(int i = 0; i < ipr.length; i++){ - if (ipr[i].getDescription().startsWith("Stuffer")){ + if (ipr[i].getDescription().startsWith("Stuffer")|| ipr[i].getDescription().startsWith("stuffer")){ ipr[i].delete(); if(Plugin.getTab1() != null) Plugin.getTab1().addElementPeer(ipr[i].getDescription(), ipr[i].getStartIP(), "Manual"); Modified: trunk/omschaub/omschaub/stuffer/main/Tab1.java =================================================================== --- trunk/omschaub/omschaub/stuffer/main/Tab1.java 2006-05-22 18:31:05 UTC (rev 978) +++ trunk/omschaub/omschaub/stuffer/main/Tab1.java 2006-05-23 16:16:07 UTC (rev 979) @@ -57,11 +57,11 @@ * */ public class Tab1 { - + //Variables private Label timeNext; private Table table1, peer_remove; - + private int peers_count, purge_count; private int escPressed; private Button setting_table2; @@ -69,42 +69,42 @@ private String defaultPath; private TableColumnWidthUtility table1ColumnWidthUtility, table2ColumnWidthUtility; //private static int old_table1_index, old_peer_remove_index; - + public void open(Composite composite){ peers_count=1; purge_count=1; - + //Initialize the ColumnWidthUtilities table1ColumnWidthUtility = new TableColumnWidthUtility("table1ColumnWidths"); table2ColumnWidthUtility = new TableColumnWidthUtility("table2ColumnWidths"); - + //button composite Composite button_composite = new Composite(composite,SWT.NULL); GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END); button_composite.setLayoutData(gridData); GridLayout layout = new GridLayout(); layout.numColumns = 2; - + button_composite.setLayout(layout); - - + + // Rezero Button = Composite Button Bar Button rezero = new Button(button_composite, SWT.PUSH); rezero.setText("Re-Zero Counters"); rezero.pack(); rezero.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { - + Plugin.total_blocked=0; Plugin.total_removed=0; totalChange(); - + } }); - - - - + + + + // Clear List Button = Composite Button Bar Button restart = new Button(button_composite, SWT.PUSH); restart.setText("Clear All Lists"); @@ -113,23 +113,23 @@ public void handleEvent(final Event e) { peers_count = 1; purge_count = 1; - + Plugin.table1_set.clearSet(); Plugin.table2_set.clearSet(); - + if (table1 != null || !table1.isDisposed()) { table1.setItemCount(1); table1.clearAll(); } - + if (peer_remove != null || !peer_remove.isDisposed()) { peer_remove.setItemCount(1); peer_remove.clearAll(); } } - + }); - + //-----------Start of sash form------------------\\ final SashForm sash = new SashForm(composite, SWT.VERTICAL); layout = new GridLayout(); @@ -139,16 +139,16 @@ gridData.horizontalSpan = 2; gridData.verticalSpan = 5; sash.setLayoutData(gridData); - - - + + + //Start of Peer Filter Table/group int[] sash_array = {Plugin.config_getter.getPluginIntParameter("stuffer_sash1", 500), Plugin.config_getter.getPluginIntParameter("stuffer_sash2", 393)}; - - - + + + //Group for list 1 group1 = new Group(sash,SWT.BORDER); //group1.setTex("Client Blocking Information"); @@ -157,7 +157,7 @@ layout.numColumns = 1; layout.marginWidth = 0; group1.setLayout(layout); - + //Composite for tools Composite tool_comp = new Composite(group1,SWT.NULL); gridData = new GridData(GridData.FILL_HORIZONTAL); @@ -166,9 +166,9 @@ layout.numColumns = 6; layout.marginHeight = 0; tool_comp.setLayout(layout); - - - + + + final Button pause = new Button(tool_comp,SWT.TOGGLE); pause.setImage(ImageRepository.getImage("pause")); pause.setToolTipText("Pause ALL filtering rules"); @@ -178,13 +178,13 @@ Plugin.areRulesPaused = pause.getSelection(); if(Plugin.getDisplay()== null && Plugin.getDisplay().isDisposed()) return; - + Plugin.getDisplay().syncExec(new Runnable (){ public void run () { table1.setEnabled(!Plugin.areRulesPaused); } }); - + } }); Button clear_table1 = new Button(tool_comp, SWT.PUSH); @@ -196,39 +196,39 @@ public void handleEvent(Event e) { if(table1 != null || !table1.isDisposed()){ - + peers_count=1; Plugin.table1_set.clearSet(); - + if (table1 != null || !table1.isDisposed()){ table1.setItemCount(1); table1.clearAll(); } - + } - - + + } }); - + //draw table1 and add menus draw_table1(); - - - - - + + + + + // Group for list remove List - - + + peerRemoveGroup = new Group(sash,SWT.BORDER); peerRemoveGroup.setText("IPFilter Removal Information (Total Filters Purged: " + (Plugin.total_removed) + ")"); layout = new GridLayout(); layout.numColumns = 1; layout.marginWidth=0; peerRemoveGroup.setLayout(layout); - - + + //Composite for tools Composite tool_comp2 = new Composite(peerRemoveGroup,SWT.NULL); gridData = new GridData(GridData.FILL_HORIZONTAL); @@ -238,23 +238,23 @@ layout.marginHeight = 0; layout.marginWidth = 0; tool_comp2.setLayout(layout); - - + + //composite for setting and purge button final Composite settingComp = new Composite(tool_comp2,SWT.NULL); layout = new GridLayout(); layout.numColumns = 2; layout.marginHeight=0; - + settingComp.setLayout(layout); - + //Setting button setting_table2 = new Button(settingComp, SWT.TOGGLE); - + //Combo for changing the timer final Text timer = new Text(settingComp, SWT.BORDER); timer.setToolTipText("Duration between each automatic peer removal in minutes (range is between 1 and 10000)"); - + //Force only integers to be input timer.addVerifyListener(new VerifyListener(){ public void verifyText(VerifyEvent event){ @@ -262,7 +262,7 @@ || Character.isDigit(event.text.charAt(0)); } }); - + timer.addModifyListener(new ModifyListener(){ public void modifyText(ModifyEvent arg0) { if(timer.getText().equalsIgnoreCase("") || Integer.parseInt(timer.getText()) == 0){ @@ -275,25 +275,25 @@ Plugin.config_getter.setPluginParameter("stuffer_time_interval",Integer.parseInt(timer.getText())); Plugin.resetTimer(); } - + }); - + timer.setText(String.valueOf(Plugin.config_getter.getPluginIntParameter("stuffer_time_interval",10))); - + gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.widthHint = 30; timer.setLayoutData(gridData); - + final Button restart_timer = new Button(tool_comp2, SWT.PUSH); - + setting_table2.setImage(ImageRepository.getImage("turn_off")); - - + + boolean no_auto_peer_removal = Plugin.config_getter.getPluginBooleanParameter("stuffer_noauto",false); - + setting_table2.setSelection(no_auto_peer_removal); - - + + if(no_auto_peer_removal){ setting_table2.setToolTipText("Click to turn on automatic peer removal"); timer.setEnabled(false); @@ -301,11 +301,11 @@ else{ setting_table2.setToolTipText("Click to turn off automatic peer removal"); timer.setEnabled(true); - - + + } - - + + setting_table2.addListener(SWT.Selection, new Listener(){ public void handleEvent(Event e) { @@ -324,11 +324,11 @@ timeNext.setVisible(true); } //System.out.println(Plugin.config_getter.getPluginBooleanParameter("stuffer_noauto",false)); - + } }); - - + + restart_timer.setText("Restart Timer"); restart_timer.addListener(SWT.Selection, new Listener(){ public void handleEvent(Event e) @@ -336,9 +336,9 @@ Plugin.resetTimer(); } }); - - - + + + //Manual purge button final Button manualPurge = new Button(tool_comp2, SWT.PUSH); manualPurge.setImage(ImageRepository.getImage("trashcan")); @@ -353,8 +353,8 @@ //timeNext.setText("Next Auto Purge: "); timeNext.setText("Next Auto Purge: " + Utils.getNextRunTime((1000*60*Plugin.config_getter.getPluginIntParameter("stuffer_time_interval",10)), Plugin.config_getter.getPluginBooleanParameter("stuffer_military_time",false))); - - + + if(setting_table2.getSelection()){ restart_timer.setEnabled(false); timeNext.setVisible(false); @@ -362,9 +362,9 @@ timeNext.setVisible(true); restart_timer.setEnabled(true); } - - - + + + //Clear button for table 2 Button clear_table2 = new Button(tool_comp2, SWT.PUSH); gridData = new GridData(GridData.HORIZONTAL_ALIGN_END); @@ -375,24 +375,24 @@ public void handleEvent(Event e) { if(peer_remove != null || !peer_remove.isDisposed()){ - + purge_count=1; Plugin.table2_set.clearSet(); - + peer_remove.setItemCount(1); peer_remove.clearAll(); - + } - - + + } }); - + draw_peer_remove_table(); - - - - + + + + //sash memory sash.setWeights(sash_array); group1.addListener(SWT.Resize, new Listener() { @@ -406,14 +406,14 @@ Plugin.config_getter.setPluginParameter("stuffer_sash1",sash_weight_array[0]); Plugin.config_getter.setPluginParameter("stuffer_sash2",sash_weight_array[1]); //Plugin.config_getter.setPluginParameter("stuffer_sash3",sash_weight_array[2]); - + if(table1 == null || table1.isDisposed()) return; - + table1.setTopIndex(table1.getItemCount()-1); } }); } - + /** * Adds a item to the table in tab1 * @@ -424,7 +424,7 @@ * @param rgb */ public void addElement(final String peerIP, final String peerID, final String peerClient, final String downloadName, final String rgb){ - + //-- Non GUI Stuff --\\ //Add Data to the Set IP ip = new IP(peerIP); @@ -438,7 +438,7 @@ ip)); Plugin.total_blocked++; peers_count++; - + //--GUI Stuff--\\ if(Plugin.getDisplay() != null && !Plugin.getDisplay().isDisposed()) { @@ -447,56 +447,63 @@ if(table1 != null && !table1.isDisposed()) { try{ - + boolean scroll_seek = false; - + //System.out.println(table1.getVerticalBar().getSelection() + " : " + table1.getVerticalBar().getMaximum() + " : " + (table1.getVerticalBar().getMaximum() - (table1.getVerticalBar().getSelection() + table1.getVerticalBar().getThumb()))); if((table1.getVerticalBar().getMaximum() - (table1.getVerticalBar().getSelection() + table1.getVerticalBar().getThumb())) == 0){ scroll_seek = true; } - - - - - + + + + + if (table1.isDisposed()) return; table1.setItemCount(Plugin.table1_set.getNum()); table1.clearAll(); - - + + totalChange(); - + if(scroll_seek){ table1.setTopIndex(table1.getItemCount() - 1); } - + }catch(Exception e){ e.printStackTrace(); } - + } } }); } - - + + } - + public void addElementPeer(final String iprDescription, final String iprStartIP, final String type){ //--non gui stuff--\\ - Plugin.table2_set.addToSet(new Table2Container( + String subString; + if(iprDescription.startsWith("Stuffer")) + subString = iprDescription.substring(iprDescription.indexOf("Stuffer - ") + 10,iprDescription.indexOf("Killed")); + else if(iprDescription.startsWith("stuffer")) + subString = iprDescription.substring(iprDescription.indexOf("stuffer - ") + 10,iprDescription.indexOf("killed")); + else + subString = "Error Decoding Title"; + Plugin.table2_set.addToSet(new Table2Container( Plugin.table2_set.getNum()+1, Utils.getCurrentTime(), type, - iprDescription.substring(iprDescription.indexOf("Stuffer - ") + 10,iprDescription.indexOf("Killed")), + subString, new IP(iprStartIP), iprDescription)); - + purge_count++; - + //--gui stuff--\\ - + if(Plugin.getDisplay() != null && !Plugin.getDisplay().isDisposed()) { Plugin.getDisplay().asyncExec( new Runnable() { @@ -504,38 +511,38 @@ if(peer_remove != null && !peer_remove.isDisposed()) { boolean scroll_seek = false; - + if((peer_remove.getVerticalBar().getMaximum() - (peer_remove.getVerticalBar().getSelection() + peer_remove.getVerticalBar().getThumb())) == 0){ scroll_seek = true; } - - - - + + + + if (peer_remove.isDisposed()) return; peer_remove.setItemCount(Plugin.table2_set.getNum()); peer_remove.clearAll(); - - - - + + + + if(scroll_seek){ - + peer_remove.setTopIndex(peer_remove.getItemCount() - 1); - + } - - + + } } }); } - - + + } - - + + public void removeAll(final List list){ if(Plugin.getDisplay() != null && !Plugin.getDisplay().isDisposed()) { @@ -548,10 +555,10 @@ } }); } - - + + } - + public void totalChange(){ if(Plugin.getPluginInterface().getUtilities().isOSX()) return; if(Plugin.getDisplay() != null && !Plugin.getDisplay().isDisposed()) @@ -563,20 +570,20 @@ { group1.setText("Client Blocking Information (Total Blocks: " + (Plugin.total_blocked) + ")"); peerRemoveGroup.setText("IPFilter Removal Information (Total Filters Purged: " + (Plugin.total_removed) + ")"); - + } }catch (Exception e){ e.printStackTrace(); } - + } }); } - - + + } - - + + public void draw_table1(){ if(Plugin.getDisplay() != null && !Plugin.getDisplay().isDisposed()) { @@ -585,47 +592,47 @@ if(table1 != null && !table1.isDisposed()){ table1.dispose(); } - - + + table1 = new Table(group1,SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.VIRTUAL| SWT.FULL_SELECTION | SWT.MULTI); - + GridData gridData = new GridData(GridData.FILL_BOTH ); gridData.horizontalSpan = 1; gridData.verticalSpan = 5; table1.setLayoutData(gridData); - - + + // Columns for table1 table1.setHeaderVisible(true); - + final TableColumn number = new TableColumn(table1,SWT.CENTER); number.setText("#"); number.setWidth(50); - - + + final TableColumn date = new TableColumn(table1,SWT.LEFT); date.setText("Time"); date.setWidth(130); - - + + final TableColumn peer_IP = new TableColumn(table1,SWT.LEFT); peer_IP.setText("IP"); peer_IP.setWidth(100); - - + + final TableColumn peer_clientName = new TableColumn(table1,SWT.LEFT); peer_clientName.setText("Client"); peer_clientName.setWidth(150); - + final TableColumn peer_ID = new TableColumn (table1, SWT.LEFT); peer_ID.setText("ID"); peer_ID.setWidth(100); - - + + final TableColumn download = new TableColumn(table1, SWT.LEFT); download.setText("Torrent"); download.setWidth(200); - + try{ //pull previous settings if they are there for column widths HashMap map = table1ColumnWidthUtility.getMap(); @@ -643,35 +650,35 @@ }else{ columns[i].pack(); } - + } - + } } }catch(Exception e) { e.printStackTrace(); } - - - + + + if(!Plugin.getPluginInterface().getPluginconfig().getPluginBooleanParameter("Stuffer_T1_Numbers", true)){ number.dispose(); } - + if(!Plugin.getPluginInterface().getPluginconfig().getPluginBooleanParameter("Stuffer_T1_Time", true)){ date.dispose(); } - + if(!Plugin.getPluginInterface().getPluginconfig().getPluginBooleanParameter("Stuffer_T1_Client", true)){ peer_clientName.dispose(); } - + if(!Plugin.getPluginInterface().getPluginconfig().getPluginBooleanParameter("Stuffer_T1_Client_id", false)){ peer_ID.dispose(); } - + if(!Plugin.getPluginInterface().getPluginconfig().getPluginBooleanParameter("Stuffer_T1_Torrent", true)){ download.dispose(); } - + Plugin.getDisplay().syncExec(new Runnable() { public void run() { if (table1.isDisposed()) @@ -680,8 +687,8 @@ table1.clearAll(); } }); - - + + //add sort listeners into all active columns TableColumn[] table_columns = table1.getColumns(); for(int i = 0; i < table_columns.length; i++){ @@ -698,11 +705,11 @@ }else if(table_columns[i].getText().equalsIgnoreCase("ID")){ table_columns[i].addListener(SWT.Selection, Plugin.table1_set.sortTable1ByID()); } - + // add in resize listener to catch new column widths table_columns[i].addControlListener(getResizeListener(1)); } - + table1.addListener(SWT.SetData, new Listener() { public void handleEvent(Event e) { try{ @@ -713,13 +720,13 @@ } if(table1 == null || table1.isDisposed()) return; - + TableColumn[] columns = table1.getColumns(); String[] stringItems; try{ stringItems = Plugin.table1_set.getTable1ContainerArray()[index].getTableItemsAsString(); }catch(ArrayIndexOutOfBoundsException e2){ return; } - + for(int i = 0; i< columns.length; i++){ String columnName = columns[i].getText(); if(columnName.equalsIgnoreCase("#")){ @@ -741,7 +748,7 @@ item.setText(i, stringItems[5]); } } - + Color temp_color = new Color(Plugin.getDisplay(),Utils.getRGB(stringItems[6])); item.setForeground(temp_color); temp_color.dispose(); @@ -750,22 +757,22 @@ } } }); - + table1.addMouseListener(new MouseAdapter() { public void mouseDown(MouseEvent e) { if(e.button == 1) { if(table1.getItem(new Point(e.x,e.y))==null){ table1.deselectAll(); } - + } } }); - + //menu for table 1 - + Menu popupmenu_table = new Menu(group1); - + final MenuItem dump = new MenuItem(popupmenu_table, SWT.PUSH); dump.setText("Save table contents to a file"); dump.setEnabled(false); @@ -780,8 +787,8 @@ messageBox.open(); return; } - - + + FileDialog fileDialog = new FileDialog(group1.getShell(), SWT.SAVE); fileDialog.setText("Please choose a file to save the information to"); String[] filterExtensions = {"*.txt","*.log","*.*"}; @@ -793,7 +800,7 @@ String selectedFile = fileDialog.open(); if(selectedFile != null){ final File fileToSave = new File(selectedFile); - + defaultPath = fileToSave.getParent(); if(fileToSave.exists()){ if(!fileToSave.canWrite()){ @@ -803,7 +810,7 @@ messageBox.open(); return; } - + final Shell shell = new Shell(SWT.DIALOG_TRIM); shell.setLayout(new GridLayout(3,false)); shell.setText("File Exists"); @@ -815,7 +822,7 @@ GridData gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.horizontalSpan = 3; message.setLayoutData(gridData); - + Button overwrite = new Button(shell,SWT.PUSH); overwrite.setText("Overwrite"); overwrite.addListener(SWT.Selection, new Listener(){ @@ -826,11 +833,11 @@ FileUtilities.writeToLog(Plugin.table1_set,fileToSave,false); } }); - + gridData = new GridData(GridData.HORIZONTAL_ALIGN_END); overwrite.setLayoutData(gridData); - - + + Button append = new Button(shell,SWT.PUSH); append.setText("Append"); append.addListener(SWT.Selection, new Listener(){ @@ -841,7 +848,7 @@ FileUtilities.writeToLog(Plugin.table1_set,fileToSave,true); } }); - + Button cancel = new Button(shell,SWT.PUSH); cancel.setText("Cancel"); cancel.addListener(SWT.Selection, new Listener(){ @@ -851,39 +858,39 @@ shell.dispose(); } }); - + gridData = new GridData(GridData.HORIZONTAL_ALIGN_END); cancel.setLayoutData(gridData); overwrite.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { switch (e.character){ case SWT.ESC: escPressed=1;break; - + } - + } public void keyReleased (KeyEvent e) { if (escPressed == 1){ - + escPressed = 0; shell.close(); shell.dispose(); } - + } }); - - + + Utils.centerShellandOpen(shell); }else{ fileToSave.createNewFile(); FileUtilities.writeToLog(Plugin.table1_set,fileToSave,true); } - - + + } - - + + }catch (Exception f){ f.printStackTrace(); MessageBox messageBox = new MessageBox(group1.getShell(), SWT.ICON_ERROR | SWT.OK); @@ -893,7 +900,7 @@ } } }); - + final MenuItem copyClip = new MenuItem(popupmenu_table, SWT.PUSH); copyClip.setText("Copy selected line(s) to clipboard"); copyClip.setEnabled(false); @@ -919,14 +926,14 @@ } catch (UIException e1) { e1.printStackTrace(); } - + } }); - - + + MenuItem seperator = new MenuItem(popupmenu_table,SWT.SEPARATOR); seperator.setText("null"); - + MenuItem setup = new MenuItem(popupmenu_table, SWT.PUSH); setup.setText("Table Setup"); setup.addListener(SWT.Selection, new Listener() { @@ -934,47 +941,47 @@ try { Tab1Customization tab1cust = new Tab1Customization(); tab1cust.clientBlockingCustomizationOpen(); - + } catch (Exception e1) { e1.printStackTrace(); } - + } }); - - + + table1.setMenu(popupmenu_table); - + popupmenu_table.addMenuListener(new MenuListener(){ public void menuHidden(MenuEvent arg0) { - - + + } - + public void menuShown(MenuEvent arg0) { dump.setEnabled(false); copyClip.setEnabled(false); - + TableItem[] item = table1.getSelection(); if(item.length > 0){ copyClip.setEnabled(true); } - + if(table1.getItemCount() > 0){ dump.setEnabled(true); } } }); - + group1.layout(); - - - + + + } }); } } - + public void draw_peer_remove_table(){ if(Plugin.getDisplay() != null && !Plugin.getDisplay().isDisposed()) { @@ -983,43 +990,43 @@ if(peer_remove != null && !peer_remove.isDisposed()){ peer_remove.dispose(); } - - - + + + peer_remove = new Table(peerRemoveGroup,SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.VIRTUAL | SWT.FULL_SELECTION | SWT.MULTI); - + GridData gridData = new GridData(GridData.FILL_BOTH ); gridData.horizontalSpan = 1; gridData.verticalSpan = 5; peer_remove.setLayoutData(gridData); - - + + // Columns for table1 peer_remove.setHeaderVisible(true); - + final TableColumn number = new TableColumn(peer_remove,SWT.CENTER); number.setText("#"); number.setWidth(50); - - + + final TableColumn date = new TableColumn(peer_remove,SWT.LEFT); date.setText("Time"); date.setWidth(130); - - + + final TableColumn type = new TableColumn(peer_remove,SWT.LEFT); type.setText("Type"); type.setWidth(100); - - + + final TableColumn peer_clientName = new TableColumn(peer_remove,SWT.LEFT); peer_clientName.setText("Client"); peer_clientName.setWidth(150); - + final TableColumn peer_IP = new TableColumn (peer_remove, SWT.LEFT); peer_IP.setText("IP"); peer_IP.setWidth(100); - + try{ //pull previous settings if they are there for column widths HashMap map = table2ColumnWidthUtility.getMap(); @@ -1034,29 +1041,29 @@ }else{ columns[i].setWidth(150); } - + } } }catch(Exception e) { e.printStackTrace(); } - + if(!Plugin.getPluginInterface().getPluginconfig().getPluginBooleanParameter("Stuffer_T2_Numbers", true)){ number.dispose(); } - + if(!Plugin.getPluginInterface().getPluginconfig().getPluginBooleanParameter("Stuffer_T2_Time", true)){ date.dispose(); } - + if(!Plugin.getPluginInterface().getPluginconfig().getPluginBooleanParameter("Stuffer_T2_Manual", true)){ type.dispose(); } - + if(!Plugin.getPluginInterface().getPluginconfig().getPluginBooleanParameter("Stuffer_T2_Client_ip", true)){ peer_IP.dispose(); } - - - + + + Plugin.getDisplay().syncExec(new Runnable() { public void run() { if (peer_remove.isDisposed()) @@ -1065,7 +1072,7 @@ peer_remove.clearAll(); } }); - + //add sort listeners into all active columns TableColumn[] table_columns = peer_remove.getColumns(); for(int i = 0; i < table_columns.length; i++){ @@ -1082,18 +1089,18 @@ } table_columns[i].addControlListener(getResizeListener(2)); } - + peer_remove.addMouseListener(new MouseAdapter() { public void mouseDown(MouseEvent e) { if(e.button == 1) { if(peer_remove.getItem(new Point(e.x,e.y))==null){ peer_remove.deselectAll(); } - + } } }); - + peer_remove.addListener(SWT.SetData, new Listener() { public void handleEvent(Event e) { TableItem item = (TableItem)e.item; @@ -1123,16 +1130,16 @@ item.setText(i,itemString[4]); } } - + Color temp_color = new Color(Plugin.getDisplay(),Utils.getRGBfromHex(itemString[5])); item.setForeground(temp_color); temp_color.dispose(); - - + + } }); - - + + /*peer_remove.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { @@ -1143,11 +1150,11 @@ old_peer_remove_index = peer_remove.getSelectionIndex(); } });*/ - + //menu for table 1 - + Menu popupmenu_table = new Menu(peerRemoveGroup); - + final MenuItem dump = new MenuItem(popupmenu_table, SWT.PUSH); dump.setText("Save table contents to a file"); dump.setEnabled(false); @@ -1162,8 +1169,8 @@ messageBox.open(); return; } - - + + FileDialog fileDialog = new FileDialog(group1.getShell(), SWT.SAVE); fileDialog.setText("Please choose a file to save the information to"); String[] filterExtensions = {"*.txt","*.log","*.*"}; @@ -1175,7 +1182,7 @@ String selectedFile = fileDialog.open(); if(selectedFile != null){ final File fileToSave = new File(selectedFile); - + defaultPath = fileToSave.getParent(); if(fileToSave.exists()){ if(!fileToSave.canWrite()){ @@ -1185,7 +1192,7 @@ messageBox.open(); return; } - + final Shell shell = new Shell(SWT.DIALOG_TRIM); shell.setLayout(new GridLayout(3,false)); shell.setText("File Exists"); @@ -1197,7 +1204,7 @@ GridData gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.horizontalSpan = 3; message.setLayoutData(gridData); - + Button overwrite = new Button(shell,SWT.PUSH); overwrite.setText("Overwrite"); overwrite.addListener(SWT.Selection, new Listener(){ @@ -1208,11 +1215,11 @@ FileUtilities.writeToLog(Plugin.table2_set,fileToSave,false); } }); - + gridData = new GridData(GridData.HORIZONTAL_ALIGN_END); overwrite.setLayoutData(gridData); - - + + Button append = new Button(shell,SWT.PUSH); append.setText("Append"); append.addListener(SWT.Selection, new Listener(){ @@ -1223,7 +1230,7 @@ FileUtilities.writeToLog(Plugin.table2_set,fileToSave,true); } }); - + Button cancel = new Button(shell,SWT.PUSH); cancel.setText("Cancel"); cancel.addListener(SWT.Selection, new Listener(){ @@ -1233,39 +1240,39 @@ shell.dispose(); } }); - + gridData = new GridData(GridData.HORIZONTAL_ALIGN_END); cancel.setLayoutData(gridData); overwrite.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { switch (e.character){ case SWT.ESC: escPressed=1;break; - + } - + } public void keyReleased (KeyEvent e) { if (escPressed == 1){ - + escPressed = 0; shell.close(); shell.dispose(); } - + } }); - - + + Utils.centerShellandOpen(shell); }else{ fileToSave.createNewFile(); FileUtilities.writeToLog(Plugin.table2_set,fileToSave,true); } - - + + } - - + + }catch (Exception f){ f.printStackTrace(); MessageBox messageBox = new MessageBox(group1.getShell(), SWT.ICON_ERROR | SWT.OK); @@ -1275,7 +1282,7 @@ } } }); - + final MenuItem copyClip = new MenuItem(popupmenu_table, SWT.PUSH); copyClip.setText("Copy selected line(s) to clipboard"); copyClip.setEnabled(false); @@ -1298,18 +1305,18 @@ } //System.out.println(item_text); Plugin.getPluginInterface().getUIManager().copyToClipBoard(item_text); - + } catch (UIException e1) { e1.printStackTrace(); } - + } }); - - + + MenuItem seperator = new MenuItem(popupmenu_table,SWT.SEPARATOR); seperator.setText("null"); - + MenuItem setup = new MenuItem(popupmenu_table, SWT.PUSH); setup.setText("Table Setup"); setup.addListener(SWT.Selection, new Listener() { @@ -1317,57 +1324,57 @@ try { Tab1Customization tab1cust = new Tab1Customization(); tab1cust.ipFilterRemovalInformationCustomizationOpen(); - + } catch (Exception e1) { e1.printStackTrace(); } - + } }); - - + + peer_remove.setMenu(popupmenu_table); - + popupmenu_table.addMenuListener(new MenuListener(){ public void menuHidden(MenuEvent arg0) { - - + + } - + public void menuShown(MenuEvent arg0) { dump.setEnabled(false); copyClip.setEnabled(false); - + TableItem[] item = peer_remove.getSelection(); if(item.length > 0){ copyClip.setEnabled(true); } - + if(peer_remove.getItemCount() > 0){ dump.setEnabled(true); } } }); - + peerRemoveGroup.layout(); - - - + + + } }); } } - - - + + + public ControlListener getResizeListener(final int table_num){ ControlListener cl = new ControlListener(){ public void controlMoved(ControlEvent arg0) { //Nothing to do here } - + public void controlResized(ControlEvent arg0) { - + if(table_num == 1){ if(table1 != null || !table1.isDisposed()){ TableColumn[] columns_for_table1 = table1.getColumns(); @@ -1382,8 +1389,8 @@ } //System.out.println(total); table1ColumnWidthUtility.setPluginConfigVariable(total); - - + + } }else if (table_num == 2){ if(peer_remove != null || !peer_remove.isDisposed()){ @@ -1402,13 +1409,13 @@ } } } - + }; - + return cl; - + } - + public void setTimeNextLabel(final String text){ if(Plugin.getDisplay() != null && !Plugin.getDisplay().isDisposed()) { @@ -1420,13 +1427,13 @@ }); } } - - + + public Table getTable1(){ return table1; } - - + + /** * Gets the peer_remove table. * @return peer_remove @@ -1434,6 +1441,6 @@ public Table getPeerRemoveTable() { return peer_remove; } - + //EOF } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <oms...@us...> - 2006-05-22 18:31:11
|
Revision: 978 Author: omschaub Date: 2006-05-22 11:31:05 -0700 (Mon, 22 May 2006) ViewCVS: http://svn.sourceforge.net/azcvsupdater/?rev=978&view=rev Log Message: ----------- One more place in Stuffer that was messed up with capitalization Modified Paths: -------------- trunk/omschaub/omschaub/stuffer/main/Tab1.java Modified: trunk/omschaub/omschaub/stuffer/main/Tab1.java =================================================================== --- trunk/omschaub/omschaub/stuffer/main/Tab1.java 2006-05-22 17:11:48 UTC (rev 977) +++ trunk/omschaub/omschaub/stuffer/main/Tab1.java 2006-05-22 18:31:05 UTC (rev 978) @@ -489,7 +489,7 @@ Plugin.table2_set.getNum()+1, Utils.getCurrentTime(), type, - iprDescription.substring(iprDescription.indexOf("stuffer - ") + 10,iprDescription.indexOf("killed")), + iprDescription.substring(iprDescription.indexOf("Stuffer - ") + 10,iprDescription.indexOf("Killed")), new IP(iprStartIP), iprDescription)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <oms...@us...> - 2006-05-22 17:11:51
|
Revision: 977 Author: omschaub Date: 2006-05-22 10:11:48 -0700 (Mon, 22 May 2006) ViewCVS: http://svn.sourceforge.net/azcvsupdater/?rev=977&view=rev Log Message: ----------- Fix for the case sensitivity issues that have made Stuffer unusable Modified Paths: -------------- trunk/omschaub/omschaub/stuffer/main/Plugin.java Modified: trunk/omschaub/omschaub/stuffer/main/Plugin.java =================================================================== --- trunk/omschaub/omschaub/stuffer/main/Plugin.java 2006-03-20 20:49:37 UTC (rev 976) +++ trunk/omschaub/omschaub/stuffer/main/Plugin.java 2006-05-22 17:11:48 UTC (rev 977) @@ -33,78 +33,78 @@ * @author omschaub * * Stuffer -- Client Killer Plugin for Azureus - * + * */ public class Plugin implements UnloadablePlugin { - + //new API startup code UISWTInstance swtInstance = null; UISWTViewEventListener myView = null; private static Display display; - + //open up the Sets for use public static SetUtils table1_set; public static SetUtils table2_set; public static TotalPeerSetUtils totalPeer_set; public static ClientBlockSet clientBlock_set; - + //publically used static holders public static int total_blocked, total_removed; public static boolean areRulesPaused; private static UTTimer timer; - + // THE plugin Interface PluginInterface pluginInterface; private static PluginInterface pi; - + //pluginconfig public static PluginConfig config_getter; - + //The main Tab1 private static Tab1 MainTab1; - + //The main Tab2 private static Tab2 MainTab2; private static Tab2Utilities tab2Utilities; - + //The main Tab3 private static Tab3 MainTab3; - + public void initialize(final PluginInterface pluginInterface) { this.pluginInterface = pluginInterface; pi=pluginInterface; UIManager ui_manager = pluginInterface.getUIManager(); BasicPluginConfigModel config_model = ui_manager.createBasicPluginConfigModel( "plugins", "plugin.stuffer"); - + config_model.addBooleanParameter2("stuffer_military_time","stuffer.military.time",false); config_model.addBooleanParameter2("stuffer_auto_open","stuffer.auto.open",true); - + config_getter = pluginInterface.getPluginconfig(); - + //initialize strings areRulesPaused = false; total_removed = 0; total_blocked = 0; - + //Setup of the main Set for holding all of the table data table1_set = new SetUtils(); table1_set.SetUtilsforTable1(); table2_set = new SetUtils(); table2_set.SetUtilsforTable2(); totalPeer_set = new TotalPeerSetUtils(); - + clientBlock_set = new ClientBlockSet(); clientBlock_set.Initialize(); FileUtilities.readClientList(); - + BlockIPUtils.startMainClientCheck(); - + purgeCheck(); startPeerPurge(); - + //new API initializer - + pluginInterface.getUIManager().addUIListener(new UIManagerListener() { public void UIAttached(UIInstance instance) { if (instance instanceof UISWTInstance) { @@ -124,17 +124,17 @@ } } }); - + //initialize the tabs MainTab1 = new Tab1(); MainTab2 = new Tab2(); tab2Utilities = new Tab2Utilities(); MainTab3 = new Tab3(); - + }//End of Initialize - - - + + + public void unload() throws PluginException { if (swtInstance == null || myView == null) return; @@ -143,27 +143,27 @@ myView = null; } - - - + + + public static PluginInterface getPluginInterface(){ return pi; } - + public static Tab1 getTab1(){ - return MainTab1; + return MainTab1; } - + public static Tab2 getTab2(){ return MainTab2; } - + public static Tab3 getTab3(){ return MainTab3; } - + public static Tab2Utilities getTab2Utilities(){ return tab2Utilities; } @@ -171,82 +171,82 @@ private synchronized void purgeCheck() { if(Plugin.getTab1() != null){ - Plugin.getTab1().setTimeNextLabel("Next Auto Purge: " + - Utils.getNextRunTime((1000*60*config_getter.getPluginIntParameter("stuffer_time_interval",10)), - Plugin.config_getter.getPluginBooleanParameter("stuffer_military_time",false))); + Plugin.getTab1().setTimeNextLabel("Next Auto Purge: " + + Utils.getNextRunTime((1000*60*config_getter.getPluginIntParameter("stuffer_time_interval",10)), + Plugin.config_getter.getPluginBooleanParameter("stuffer_military_time",false))); } - + timer=pluginInterface.getUtilities().createTimer("stuffer_created_timer"); timer.addPeriodicEvent(1000*60*config_getter.getPluginIntParameter("stuffer_time_interval",10), - - - + + + new UTTimerEventPerformer() - + { - + public void - + perform( - + UTTimerEvent ev2 ) - + { - + try { if(Plugin.getTab1() != null){ - Plugin.getTab1().setTimeNextLabel("Next Auto Purge: " + - Utils.getNextRunTime((1000*60*config_getter.getPluginIntParameter("stuffer_time_interval",10)), - Plugin.config_getter.getPluginBooleanParameter("stuffer_military_time",false))); + Plugin.getTab1().setTimeNextLabel("Next Auto Purge: " + + Utils.getNextRunTime((1000*60*config_getter.getPluginIntParameter("stuffer_time_interval",10)), + Plugin.config_getter.getPluginBooleanParameter("stuffer_military_time",false))); } - - - - + + + + if(!Plugin.config_getter.getPluginBooleanParameter("stuffer_noauto",false)) { - + IPFilter ipf = new IPFilterImpl(); IPRange[] ipr = ipf.getRanges(); for(int i = 0; i < ipr.length; i++){ - if (ipr[i].getDescription().startsWith("stuffer")){ + if (ipr[i].getDescription().startsWith("Stuffer")){ ipr[i].delete(); if(Plugin.getTab1() != null) Plugin.getTab1().addElementPeer(ipr[i].getDescription(), ipr[i].getStartIP(), "Interval"); - + total_removed++; if(Plugin.getTab1() != null) Plugin.getTab1().totalChange(); } - } + } } - + }catch(Exception f) { System.out.println("Error in scanning IPFilter list"); - f.printStackTrace(); + f.printStackTrace(); } - + } - + }); - + } - - + + public static void resetTimer(){ if(timer != null){ timer.destroy(); - + } - + if(Plugin.getTab1() != null){ - Plugin.getTab1().setTimeNextLabel("Next Auto Purge: " - + Utils.getNextRunTime((1000*60*config_getter.getPluginIntParameter("stuffer_time_interval",10)), - Plugin.config_getter.getPluginBooleanParameter("stuffer_military_time",false))); + Plugin.getTab1().setTimeNextLabel("Next Auto Purge: " + + Utils.getNextRunTime((1000*60*config_getter.getPluginIntParameter("stuffer_time_interval",10)), + Plugin.config_getter.getPluginBooleanParameter("stuffer_military_time",false))); } - - + + timer=pi.getUtilities().createTimer("stuffer_created_timer"); timer.addPeriodicEvent(1000 * 60 * config_getter.getPluginIntParameter("stuffer_time_interval",10), new UTTimerEventPerformer() @@ -263,47 +263,47 @@ try { if(Plugin.getTab1() != null){ - Plugin.getTab1().setTimeNextLabel("Next Auto Purge: " - + Utils.getNextRunTime((1000*60*config_getter.getPluginIntParameter("stuffer_time_interval",10)), - Plugin.config_getter.getPluginBooleanParameter("stuffer_military_time",false))); + Plugin.getTab1().setTimeNextLabel("Next Auto Purge: " + + Utils.getNextRunTime((1000*60*config_getter.getPluginIntParameter("stuffer_time_interval",10)), + Plugin.config_getter.getPluginBooleanParameter("stuffer_military_time",false))); } - + if(!Plugin.config_getter.getPluginBooleanParameter("stuffer_noauto",false)) { - + IPFilter ipf = new IPFilterImpl(); IPRange[] ipr = ipf.getRanges(); for(int i = 0; i < ipr.length; i++){ - if (ipr[i].getDescription().startsWith("stuffer")){ - ipr[i].delete(); - if(Plugin.getTab1() != null) + if (ipr[i].getDescription().startsWith("Stuffer")){ + ipr[i].delete(); + if(Plugin.getTab1() != null) Plugin.getTab1().addElementPeer(ipr[i].getDescription(), ipr[i].getStartIP(), "Interval"); //System.out.println("Interval Deleting Stuffit IP Rule: " + ipr[i].getDescription() + " " + ipr[i].getStartIP()); total_removed++; if(Plugin.getTab1() != null) Plugin.getTab1().totalChange(); } - } + } } - + }catch(Exception f) { System.out.println("Error in scanning IPFilter list"); - f.printStackTrace(); + f.printStackTrace(); } - + } }); } - - + + public static void manualPurge(){ try { IPFilter ipf = new IPFilterImpl(); IPRange[] ipr = ipf.getRanges(); for(int i = 0; i < ipr.length; i++){ - if (ipr[i].getDescription().startsWith("stuffer")){ + if (ipr[i].getDescription().startsWith("Stuffer")){ ipr[i].delete(); if(Plugin.getTab1() != null) Plugin.getTab1().addElementPeer(ipr[i].getDescription(), ipr[i].getStartIP(), "Manual"); @@ -311,16 +311,16 @@ if(Plugin.getTab1() != null) Plugin.getTab1().totalChange(); } - } - - + } + + }catch(Exception f) { System.out.println("Error in scanning IPFilter list"); - f.printStackTrace(); + f.printStackTrace(); } } - - + + public static void startPeerPurge(){ UTTimer peer_timer=pi.getUtilities().createTimer("stuffer_purge_timer"); peer_timer.addPeriodicEvent(1000*6, @@ -337,36 +337,36 @@ { try { - + Utils.killConnectedPeers(); - - + + /*//System.out.println("Peers in TotalPeerSet: " + totalPeer_set.getSize()); Runtime runTime = Runtime.getRuntime(); float used = (runTime.totalMemory()-runTime.freeMemory())/1024/1024; float max = runTime.totalMemory() / 1024 / 1024; Tab3.setMemoryLabel(used, max); - + TotalPeerContainer[] tpc = Plugin.totalPeer_set.getAllTotalPeerContainers(); for(int i = 0; i < tpc.length; i++){ - + if(tpc[i].getTotalConnectionTime() > 5*60*1000 && tpc[i].getPercentDone() > 900){ //System.out.println(tpc[i].getIP().getAsString() + " failed with " + tpc[i].getPercentDone()); } } - + */ - + }catch(Exception e){ e.printStackTrace(); } } - + }); - + } - - + + public static void startTPCRuleRun(){ UTTimer peer_timer=pi.getUtilities().createTimer("stuffer_tpc_timer"); peer_timer.addPeriodicEvent(1000*6, @@ -383,39 +383,39 @@ { try { - + Runtime runTime = Runtime.getRuntime(); float used = (runTime.totalMemory()-runTime.freeMemory())/1024/1024; float max = runTime.totalMemory() / 1024 / 1024; MainTab3.setMemoryLabel(used, max); - + TotalPeerContainer[] tpc = Plugin.totalPeer_set.getAllTotalPeerContainers(); for(int i = 0; i < tpc.length; i++){ - + if(tpc[i].getTotalConnectionTime() > 5*60*1000 && tpc[i].getPercentDone() > 900){ //System.out.println(tpc[i].getIP().getAsString() + " failed with " + tpc[i].getPercentDone()); } } - - - + + + }catch(Exception e){ e.printStackTrace(); } } - + }); - + } - - + + public static Display getDisplay(){ return display; } public static void setDisplay(Display new_display){ display=new_display; } - + //EOF - + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <oms...@us...> - 2006-03-20 20:49:48
|
Revision: 976 Author: omschaub Date: 2006-03-20 12:49:37 -0800 (Mon, 20 Mar 2006) ViewCVS: http://svn.sourceforge.net/azcvsupdater/?rev=976&view=rev Log Message: ----------- last commit before we switch to the new SVN system Modified Paths: -------------- trunk/AZMultiUser/lbms/azmultiuser/remote/client/firefrog/DownloadManagerShell.java Modified: trunk/AZMultiUser/lbms/azmultiuser/remote/client/firefrog/DownloadManagerShell.java =================================================================== --- trunk/AZMultiUser/lbms/azmultiuser/remote/client/firefrog/DownloadManagerShell.java 2006-03-20 00:55:22 UTC (rev 975) +++ trunk/AZMultiUser/lbms/azmultiuser/remote/client/firefrog/DownloadManagerShell.java 2006-03-20 20:49:37 UTC (rev 976) @@ -1283,20 +1283,12 @@ //--------------------Center/Open Shell-------------------\\ - //In case we need to do anything on disposal, set up a listener - DOWNLOAD_MANAGER_SHELL.addListener(SWT.Dispose, new Listener(){ - public void handleEvent(Event e) { - } - }); DOWNLOAD_MANAGER_SHELL.addShellListener(new ShellListener(){ - public void shellActivated(ShellEvent arg0) { - // TODO Auto-generated method stub + public void shellActivated(ShellEvent arg0) {} - } - public void shellClosed(ShellEvent arg0) { FireFrogMain.getFFM().updateTimer(false); FireFrogMain.getFFM().getClient().removeSpeedUpdateListener(sul); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dam...@us...> - 2006-03-20 00:55:40
|
Revision: 975 Author: damokles Date: 2006-03-19 16:55:22 -0800 (Sun, 19 Mar 2006) ViewCVS: http://svn.sourceforge.net/azcvsupdater/?rev=975&view=rev Log Message: ----------- added btn "Hide All" and killShell(); Modified Paths: -------------- trunk/AZMultiUser/lbms/azmultiuser/remote/client/firefrog/dialogs/MessageDialog.java Modified: trunk/AZMultiUser/lbms/azmultiuser/remote/client/firefrog/dialogs/MessageDialog.java =================================================================== --- trunk/AZMultiUser/lbms/azmultiuser/remote/client/firefrog/dialogs/MessageDialog.java 2006-03-20 00:21:06 UTC (rev 974) +++ trunk/AZMultiUser/lbms/azmultiuser/remote/client/firefrog/dialogs/MessageDialog.java 2006-03-20 00:55:22 UTC (rev 975) @@ -5,6 +5,9 @@ */ package lbms.azmultiuser.remote.client.firefrog.dialogs; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import java.util.StringTokenizer; import lbms.azmultiuser.remote.client.firefrog.FireFrogMain; @@ -37,6 +40,7 @@ private Display display; private int steps; private Image popupImage; + private static List<MessageDialog> messageDiags = Collections.synchronizedList(new ArrayList<MessageDialog>()); TimerEvent timerEvent; /** @@ -51,11 +55,12 @@ public MessageDialog(final Display display, final boolean bautoclose, final int timeToClose, final int steps, final String title, final String message){ - if(!Boolean.parseBoolean(FireFrogMain.getFFM().getProperties().getProperty("popups_enabled", "true"))) - return; + if(!Boolean.parseBoolean(FireFrogMain.getFFM().getProperties().getProperty("popups_enabled", "true"))) + return; - this.display = display; + this.display = display; this.steps = steps; + messageDiags.add(this); display.asyncExec(new Runnable (){ public void run() { @@ -88,8 +93,8 @@ gc.drawText(title, 10, 8, true); titleFont.dispose(); gc.setFont(messageFont); - Rectangle rect = new Rectangle(60,45,150,150); - printString(gc,message,rect); + Rectangle rect = new Rectangle(60,45,150,150); + printString(gc,message,rect); messageFont.dispose(); @@ -99,16 +104,24 @@ Button btnOK = new Button(splash, SWT.PUSH); btnOK.setText("OK"); + Button btnHideAll = new Button(splash, SWT.PUSH); + btnHideAll.setText("Hide All"); + Label lblImage = new Label(splash,SWT.NULL); lblImage.setImage(popupImage); FormData formData; formData = new FormData(); - formData.right = new FormAttachment(100,-5); + formData.right = new FormAttachment(100,-60); formData.bottom = new FormAttachment(100,-5); btnOK.setLayoutData(formData); formData = new FormData(); + formData.right = new FormAttachment(100,-5); + formData.bottom = new FormAttachment(100,-5); + btnHideAll.setLayoutData(formData); + + formData = new FormData(); formData.left = new FormAttachment(0,0); formData.top = new FormAttachment(0,0); lblImage.setLayoutData(formData); @@ -123,12 +136,20 @@ } }); - btnOK.addListener(SWT.Selection, new Listener(){ + btnOK.addListener(SWT.Selection, new Listener(){ public void handleEvent(Event arg0) { hideShell(); } }); - showShell(); + btnHideAll.addListener(SWT.Selection, new Listener(){ + public void handleEvent(Event arg0) { + MessageDialog[] list = messageDiags.toArray(new MessageDialog[] {}); + for (MessageDialog md:list) { + md.killShell(); + } + } + }); + showShell(); } }); } @@ -173,7 +194,7 @@ public void hideShell() { if (timerEvent != null) timerEvent.cancel(); - + messageDiags.remove(this); display.asyncExec(new Runnable() { public void run() { Rectangle splashRect = splash.getBounds(); @@ -208,81 +229,92 @@ }); } - public static boolean printString(GC gc,String string,Rectangle printArea) { - int x0 = printArea.x; - int y0 = printArea.y; - int height = 0; - Rectangle oldClipping = gc.getClipping(); + public void killShell() { + if (timerEvent != null) timerEvent.cancel(); + messageDiags.remove(this); + display.asyncExec(new Runnable() { + public void run() { + splash.close(); + popupImage.dispose(); + } + }); + } - //Protect the GC from drawing outside the drawing area - gc.setClipping(printArea); + public static boolean printString(GC gc,String string,Rectangle printArea) { + int x0 = printArea.x; + int y0 = printArea.y; + int height = 0; + Rectangle oldClipping = gc.getClipping(); - //We need to add some cariage return ... - String sTabsReplaced = string.replaceAll("\t", " "); + //Protect the GC from drawing outside the drawing area + gc.setClipping(printArea); - StringBuffer outputLine = new StringBuffer(); + //We need to add some cariage return ... + String sTabsReplaced = string.replaceAll("\t", " "); - // Process string line by line - StringTokenizer stLine = new StringTokenizer(sTabsReplaced,"\n"); - while(stLine.hasMoreElements()) { - int iLineHeight = 0; - String sLine = stLine.nextToken(); - if (gc.stringExtent(sLine).x > printArea.width) { - //System.out.println("Line: "+ sLine); - StringTokenizer stWord = new StringTokenizer(sLine, " "); - String space = ""; - int iLineLength = 0; - iLineHeight = gc.stringExtent(" ").y; + StringBuffer outputLine = new StringBuffer(); - // Process line word by word - while(stWord.hasMoreElements()) { - String word = stWord.nextToken(); + // Process string line by line + StringTokenizer stLine = new StringTokenizer(sTabsReplaced,"\n"); + while(stLine.hasMoreElements()) { + int iLineHeight = 0; + String sLine = stLine.nextToken(); + if (gc.stringExtent(sLine).x > printArea.width) { + //System.out.println("Line: "+ sLine); + StringTokenizer stWord = new StringTokenizer(sLine, " "); + String space = ""; + int iLineLength = 0; + iLineHeight = gc.stringExtent(" ").y; - // check if word is longer than our print area, and split it - Point ptWordSize = gc.stringExtent(word + " "); - while (ptWordSize.x > printArea.width) { - int endIndex = word.length() - 1; - do { - endIndex--; - ptWordSize = gc.stringExtent(word.substring(0, endIndex) + " "); - } while (endIndex > 3 && ptWordSize.x + iLineLength > printArea.width); - // append part that will fit - outputLine.append(space) - .append(word.substring(0, endIndex)) - .append("\n"); - height += ptWordSize.y; + // Process line word by word + while(stWord.hasMoreElements()) { + String word = stWord.nextToken(); - // setup word as the remaining part that didn't fit - word = word.substring(endIndex); - ptWordSize = gc.stringExtent(word + " "); - iLineLength = 0; - } - iLineLength += ptWordSize.x; - //System.out.println(outputLine + " : " + word + " : " + iLineLength); - if(iLineLength > printArea.width) { - iLineLength = ptWordSize.x; - height += iLineHeight; - iLineHeight = ptWordSize.y; - space = "\n"; - } - if (iLineHeight < ptWordSize.y) - iLineHeight = ptWordSize.y; + // check if word is longer than our print area, and split it + Point ptWordSize = gc.stringExtent(word + " "); + while (ptWordSize.x > printArea.width) { + int endIndex = word.length() - 1; + do { + endIndex--; + ptWordSize = gc.stringExtent(word.substring(0, endIndex) + " "); + } while (endIndex > 3 && ptWordSize.x + iLineLength > printArea.width); + // append part that will fit + outputLine.append(space) + .append(word.substring(0, endIndex)) + .append("\n"); + height += ptWordSize.y; - outputLine.append(space).append(word); - space = " "; - } - } else { - outputLine.append(sLine); - iLineHeight = gc.stringExtent(sLine).y; - } - outputLine.append("\n"); - height += iLineHeight; - } + // setup word as the remaining part that didn't fit + word = word.substring(endIndex); + ptWordSize = gc.stringExtent(word + " "); + iLineLength = 0; + } + iLineLength += ptWordSize.x; + //System.out.println(outputLine + " : " + word + " : " + iLineLength); + if(iLineLength > printArea.width) { + iLineLength = ptWordSize.x; + height += iLineHeight; + iLineHeight = ptWordSize.y; + space = "\n"; + } + if (iLineHeight < ptWordSize.y) + iLineHeight = ptWordSize.y; - String sOutputLine = outputLine.toString(); - gc.drawText(sOutputLine,x0,y0,true); - gc.setClipping(oldClipping); - return height <= printArea.height; - } + outputLine.append(space).append(word); + space = " "; + } + } else { + outputLine.append(sLine); + iLineHeight = gc.stringExtent(sLine).y; + } + outputLine.append("\n"); + height += iLineHeight; + } + String sOutputLine = outputLine.toString(); + gc.drawText(sOutputLine,x0,y0,true); + gc.setClipping(oldClipping); + return height <= printArea.height; + } + }//EOF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dam...@us...> - 2006-03-20 00:21:12
|
Revision: 974 Author: damokles Date: 2006-03-19 16:21:06 -0800 (Sun, 19 Mar 2006) ViewCVS: http://svn.sourceforge.net/azcvsupdater/?rev=974&view=rev Log Message: ----------- save updatefile if all files are already there Modified Paths: -------------- trunk/AZMultiUser/lbms/tools/updater/Updater.java Modified: trunk/AZMultiUser/lbms/tools/updater/Updater.java =================================================================== --- trunk/AZMultiUser/lbms/tools/updater/Updater.java 2006-03-20 00:10:34 UTC (rev 973) +++ trunk/AZMultiUser/lbms/tools/updater/Updater.java 2006-03-20 00:21:06 UTC (rev 974) @@ -239,32 +239,31 @@ failed = true; } } - if (failed) { - callListenerUpdateFailed(); - } else { - if (currentUpdates != null) { - OutputStream os = null; - try { - if (currentUpdates.getName().endsWith(".gz")) { - os = new GZIPOutputStream(new FileOutputStream(currentUpdates)); - } else { - os = new FileOutputStream(currentUpdates); - } - new XMLOutputter(Format.getCompactFormat()).output(remoteUpdate.toDocument(), os); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } finally { - if (os!=null) - try { - os.close(); - } catch (IOException e) {} + } + if (failed) { + callListenerUpdateFailed(); + } else { + if (currentUpdates != null) { + OutputStream os = null; + try { + if (currentUpdates.getName().endsWith(".gz")) { + os = new GZIPOutputStream(new FileOutputStream(currentUpdates)); + } else { + os = new FileOutputStream(currentUpdates); } + new XMLOutputter(Format.getCompactFormat()).output(remoteUpdate.toDocument(), os); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (os!=null) + try { + os.close(); + } catch (IOException e) {} } - - callListenerUpdateFinished(); } + callListenerUpdateFinished(); } } }); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dam...@us...> - 2006-03-20 00:10:45
|
Revision: 973 Author: damokles Date: 2006-03-19 16:10:34 -0800 (Sun, 19 Mar 2006) ViewCVS: http://svn.sourceforge.net/azcvsupdater/?rev=973&view=rev Log Message: ----------- added UpdateList Modified Paths: -------------- trunk/AZMultiUser/lbms/tools/updater/Update.java Added Paths: ----------- trunk/AZMultiUser/lbms/tools/updater/UpdateList.java Modified: trunk/AZMultiUser/lbms/tools/updater/Update.java =================================================================== --- trunk/AZMultiUser/lbms/tools/updater/Update.java 2006-03-19 13:10:39 UTC (rev 972) +++ trunk/AZMultiUser/lbms/tools/updater/Update.java 2006-03-20 00:10:34 UTC (rev 973) @@ -15,8 +15,8 @@ public static final int LV_FEATURE = 20; public static final int LV_LOW = 1; - public static final int TYPE_BETA = 1; - public static final int TYPE_STABLE = 2; + public static final int TYPE_BETA = 1; + public static final int TYPE_STABLE = 2; public static final int TYPE_MAINTENANCE = 3; private List<UpdateFile> fileList = new ArrayList<UpdateFile>(); @@ -91,6 +91,14 @@ else return true; } + public boolean isStable() { + return (type >= TYPE_STABLE); + } + + public boolean isBeta() { + return (type == TYPE_BETA); + } + public int compareTo(Update o) { return version.compareTo(o.version); } Added: trunk/AZMultiUser/lbms/tools/updater/UpdateList.java =================================================================== --- trunk/AZMultiUser/lbms/tools/updater/UpdateList.java (rev 0) +++ trunk/AZMultiUser/lbms/tools/updater/UpdateList.java 2006-03-20 00:10:34 UTC (rev 973) @@ -0,0 +1,71 @@ +package lbms.tools.updater; + +import java.util.List; +import java.util.Comparator; +import java.util.Iterator; +import java.util.SortedSet; +import java.util.TreeSet; + +import org.jdom.Document; +import org.jdom.Element; + + + +public class UpdateList { + private SortedSet<Update> uSet = new TreeSet<Update>(new Comparator<Update>() { + public int compare(Update o1, Update o2) { + return o1.compareTo(o2)*-1; //We need Descending order to speed things up + } + }); + + public UpdateList() { + + } + + public UpdateList(Document xml) { + Element root = xml.getRootElement(); + List<Element> updates = root.getChildren("Update"); + for (Element u:updates) { + uSet.add(new Update(u)); + } + } + + public Document toDocument() { + Document doc = new Document(); + Element root = new Element ("Updates"); + Iterator<Update> it = uSet.iterator(); + Update result = null; + while (it.hasNext()) { + root.addContent(it.next().toElement()); + } + doc.addContent(root); + return doc; + } + + public Update getLatest () { + return uSet.first(); + } + + public Update getLatestStable() { + Iterator<Update> it = uSet.iterator(); + Update result = null; + while (it.hasNext()) { + result = it.next(); + if (result.isStable()) break; + result = null; + } + return result; + } + + public SortedSet<Update> getUpdateSet () { + return uSet; + } + + protected void addUpdate (Update u) { + uSet.add(u); + } + + protected void removeUpdate (Update u) { + uSet.remove(u); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dam...@us...> - 2006-03-19 13:10:46
|
Revision: 972 Author: damokles Date: 2006-03-19 05:10:39 -0800 (Sun, 19 Mar 2006) ViewCVS: http://svn.sourceforge.net/azcvsupdater/?rev=972&view=rev Log Message: ----------- added info when checking for updates Modified Paths: -------------- trunk/AZMultiUser/lbms/azmultiuser/remote/client/firefrog/FireFrogMain.java Modified: trunk/AZMultiUser/lbms/azmultiuser/remote/client/firefrog/FireFrogMain.java =================================================================== --- trunk/AZMultiUser/lbms/azmultiuser/remote/client/firefrog/FireFrogMain.java 2006-03-19 01:09:12 UTC (rev 971) +++ trunk/AZMultiUser/lbms/azmultiuser/remote/client/firefrog/FireFrogMain.java 2006-03-19 13:10:39 UTC (rev 972) @@ -538,6 +538,10 @@ } }); if (Boolean.parseBoolean(properties.getProperty("update.autocheck", "true"))) { + if (mainWindow != null) { + mainWindow.setStatusBarText("Checking for Updates"); + } + normalLogger.info("Checking for Updates"); updater.checkForUpdates(); } timer = new Timer("Main Timer",5); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <oms...@us...> - 2006-03-19 01:09:19
|
Revision: 971 Author: omschaub Date: 2006-03-18 17:09:12 -0800 (Sat, 18 Mar 2006) ViewCVS: http://svn.sourceforge.net/azcvsupdater/?rev=971&view=rev Log Message: ----------- Added output Changelog to file feature Modified Paths: -------------- trunk/AZMultiUser/lbms/tools/updater/UpdateCreatorGUI.java Modified: trunk/AZMultiUser/lbms/tools/updater/UpdateCreatorGUI.java =================================================================== --- trunk/AZMultiUser/lbms/tools/updater/UpdateCreatorGUI.java 2006-03-19 01:06:55 UTC (rev 970) +++ trunk/AZMultiUser/lbms/tools/updater/UpdateCreatorGUI.java 2006-03-19 01:09:12 UTC (rev 971) @@ -130,6 +130,7 @@ private File updateCreatorFile; private File currentDir; private Changelog log = new Changelog(); + private JButton writeChangelog; private JScrollPane chTreeScrollPane; private JButton chRemove; private JTree chTree; @@ -1079,7 +1080,7 @@ chRemove = new JButton(); jPanel3.add(chRemove); chRemove.setText("Remove Selected"); - chRemove.setBounds(35, 315, 147, 28); + chRemove.setBounds(35, 312, 147, 28); chRemove.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent arg0) { @@ -1127,7 +1128,40 @@ chTree.setPreferredSize(new java.awt.Dimension(612, 309)); //END << chTree //END << chTreeScrollPane + //START >> writeChangelog + writeChangelog = new JButton(); + jPanel3.add(writeChangelog); + writeChangelog.setText("Write Changelog to File"); + writeChangelog.setBounds(399, 313, 210, 28); + writeChangelog.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent arg0) { + final JFileChooser fc = new JFileChooser(); + fc.setName("Choose Changelog File Save Location"); + if (currentDirFile != null) + fc.setCurrentDirectory(currentDirFile); + else + fc.setCurrentDirectory(new File(".")); + int returnVal = fc.showSaveDialog(jPanel2); + if (returnVal == JFileChooser.APPROVE_OPTION) { + File changelogFile = fc.getSelectedFile(); + + try { + updateCreator.generateChanglogTxt(changelogFile); + } catch (IOException e) { + e.printStackTrace(); + } + + + + + } + + } + + }); + //END << writeChangelog + } } @@ -1149,46 +1183,8 @@ newPackage.setText("New Package"); newPackage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { + clearAll(); - //Remake the elements - updateCreator = new UpdateCreator(); - update = updateCreator.getUpdate(); - log = new Changelog(); - currentDirFile = null; - updateCreatorFile = null; - - //Clear 1st tab - UpdateCreatorName.setText("Not Selected Yet"); - UpdateCreatorDir.setText("Not Selected Yet"); - UpdateCreatorCompressed.setSelected(false); - - UpdaterImportance.setSelectedIndex(0); - UpdaterType.setSelectedIndex(0); - updaterURL.setText(""); - updateVersion.setText(""); - - //Clear 2nd tab - currentUF = null; - fileListModel.removeAllElements(); - name.setText(""); - path.setText(""); - version.setText(""); - url.setText(""); - hash.setText(""); - TypeCombo.setSelectedIndex(0); - size.setText(""); - - //Clear 3rd Tab - chArea.setText(""); - bugNode = new DefaultMutableTreeNode("BugFixes"); - changeNode = new DefaultMutableTreeNode("Changes"); - featureNode = new DefaultMutableTreeNode("Features"); - rootNode = new DefaultMutableTreeNode("Changelog"); - rootNode.add(bugNode); - rootNode.add(changeNode); - rootNode.add(featureNode); - treeModel = new DefaultTreeModel(rootNode); - chTree.setModel(treeModel); } }); { @@ -1215,4 +1211,46 @@ } } + public void clearAll(){ + //Remake the elements + updateCreator = new UpdateCreator(); + update = updateCreator.getUpdate(); + log = new Changelog(); + currentDirFile = null; + updateCreatorFile = null; + + //Clear 1st tab + UpdateCreatorName.setText("Not Selected Yet"); + UpdateCreatorDir.setText("Not Selected Yet"); + UpdateCreatorCompressed.setSelected(false); + + UpdaterImportance.setSelectedIndex(0); + UpdaterType.setSelectedIndex(0); + updaterURL.setText(""); + updateVersion.setText(""); + + //Clear 2nd tab + currentUF = null; + fileListModel.removeAllElements(); + name.setText(""); + path.setText(""); + version.setText(""); + url.setText(""); + hash.setText(""); + TypeCombo.setSelectedIndex(0); + size.setText(""); + + //Clear 3rd Tab + chArea.setText(""); + bugNode = new DefaultMutableTreeNode("BugFixes"); + changeNode = new DefaultMutableTreeNode("Changes"); + featureNode = new DefaultMutableTreeNode("Features"); + rootNode = new DefaultMutableTreeNode("Changelog"); + rootNode.add(bugNode); + rootNode.add(changeNode); + rootNode.add(featureNode); + treeModel = new DefaultTreeModel(rootNode); + chTree.setModel(treeModel); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dam...@us...> - 2006-03-19 01:07:04
|
Revision: 970 Author: damokles Date: 2006-03-18 17:06:55 -0800 (Sat, 18 Mar 2006) ViewCVS: http://svn.sourceforge.net/azcvsupdater/?rev=970&view=rev Log Message: ----------- another small fix for local copy Modified Paths: -------------- trunk/AZMultiUser/lbms/tools/updater/Updater.java Modified: trunk/AZMultiUser/lbms/tools/updater/Updater.java =================================================================== --- trunk/AZMultiUser/lbms/tools/updater/Updater.java 2006-03-19 00:59:35 UTC (rev 969) +++ trunk/AZMultiUser/lbms/tools/updater/Updater.java 2006-03-19 01:06:55 UTC (rev 970) @@ -6,6 +6,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; @@ -242,18 +243,22 @@ callListenerUpdateFailed(); } else { if (currentUpdates != null) { - GZIPOutputStream gos = null; + OutputStream os = null; try { - gos = new GZIPOutputStream(new FileOutputStream(currentUpdates)); - new XMLOutputter(Format.getCompactFormat()).output(remoteUpdate.toDocument(), gos); + if (currentUpdates.getName().endsWith(".gz")) { + os = new GZIPOutputStream(new FileOutputStream(currentUpdates)); + } else { + os = new FileOutputStream(currentUpdates); + } + new XMLOutputter(Format.getCompactFormat()).output(remoteUpdate.toDocument(), os); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { - if (gos!=null) + if (os!=null) try { - gos.close(); + os.close(); } catch (IOException e) {} } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dam...@us...> - 2006-03-19 00:59:44
|
Revision: 969 Author: damokles Date: 2006-03-18 16:59:35 -0800 (Sat, 18 Mar 2006) ViewCVS: http://svn.sourceforge.net/azcvsupdater/?rev=969&view=rev Log Message: ----------- fixed local copy save Modified Paths: -------------- trunk/AZMultiUser/lbms/tools/updater/Updater.java Modified: trunk/AZMultiUser/lbms/tools/updater/Updater.java =================================================================== --- trunk/AZMultiUser/lbms/tools/updater/Updater.java 2006-03-19 00:53:17 UTC (rev 968) +++ trunk/AZMultiUser/lbms/tools/updater/Updater.java 2006-03-19 00:59:35 UTC (rev 969) @@ -242,19 +242,18 @@ callListenerUpdateFailed(); } else { if (currentUpdates != null) { - FileOutputStream fos = null; + GZIPOutputStream gos = null; try { - fos = new FileOutputStream(currentUpdates); - GZIPOutputStream gos = new GZIPOutputStream(fos); + gos = new GZIPOutputStream(new FileOutputStream(currentUpdates)); new XMLOutputter(Format.getCompactFormat()).output(remoteUpdate.toDocument(), gos); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { - if (fos!=null) + if (gos!=null) try { - fos.close(); + gos.close(); } catch (IOException e) {} } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <oms...@us...> - 2006-03-19 00:53:21
|
Revision: 968 Author: omschaub Date: 2006-03-18 16:53:17 -0800 (Sat, 18 Mar 2006) ViewCVS: http://svn.sourceforge.net/azcvsupdater/?rev=968&view=rev Log Message: ----------- working with the scrolledcomp Modified Paths: -------------- trunk/AZMultiUser/lbms/azmultiuser/remote/client/firefrog/tabs/PreferencesTab.java Modified: trunk/AZMultiUser/lbms/azmultiuser/remote/client/firefrog/tabs/PreferencesTab.java =================================================================== --- trunk/AZMultiUser/lbms/azmultiuser/remote/client/firefrog/tabs/PreferencesTab.java 2006-03-19 00:51:40 UTC (rev 967) +++ trunk/AZMultiUser/lbms/azmultiuser/remote/client/firefrog/tabs/PreferencesTab.java 2006-03-19 00:53:17 UTC (rev 968) @@ -500,7 +500,7 @@ public void controlResized(ControlEvent e) { Rectangle r = scrolledComposite.getClientArea(); System.out.println(r.width + " : " + parent.computeSize(r.width,SWT.DEFAULT)); - scrolledComposite.setMinSize(parentTab.computeSize(r.width, SWT.DEFAULT)); + scrolledComposite.setMinSize(parent.computeSize(r.width, SWT.DEFAULT)); } }); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <oms...@us...> - 2006-03-19 00:51:44
|
Revision: 967 Author: omschaub Date: 2006-03-18 16:51:40 -0800 (Sat, 18 Mar 2006) ViewCVS: http://svn.sourceforge.net/azcvsupdater/?rev=967&view=rev Log Message: ----------- working with the scrolledcomp Modified Paths: -------------- trunk/AZMultiUser/lbms/azmultiuser/remote/client/firefrog/tabs/PreferencesTab.java Modified: trunk/AZMultiUser/lbms/azmultiuser/remote/client/firefrog/tabs/PreferencesTab.java =================================================================== --- trunk/AZMultiUser/lbms/azmultiuser/remote/client/firefrog/tabs/PreferencesTab.java 2006-03-19 00:37:41 UTC (rev 966) +++ trunk/AZMultiUser/lbms/azmultiuser/remote/client/firefrog/tabs/PreferencesTab.java 2006-03-19 00:51:40 UTC (rev 967) @@ -43,12 +43,18 @@ private Button autoOpen, autoConnect, autoUpdateCheck, autoUpdate; private Button trayMinimize, trayExit, popupsEnabled, autoClipboard, autoConsole; - public PreferencesTab(CTabFolder parentTab){ + public PreferencesTab(final CTabFolder parentTab){ final CTabItem prefsTab = new CTabItem(parentTab, SWT.CLOSE); prefsTab.setText("Preferences"); - final Composite parent = new Composite(parentTab, SWT.NULL); + //ScrollComp on shell + final ScrolledComposite scrolledComposite = new ScrolledComposite(parentTab, SWT.V_SCROLL); + scrolledComposite.setExpandVertical(true); + scrolledComposite.setExpandHorizontal(true); + + + final Composite parent = new Composite(scrolledComposite, SWT.NULL); parent.setLayout(new GridLayout(1,false)); GridData gridData = new GridData(GridData.FILL_BOTH); gridData.grabExcessHorizontalSpace = true; @@ -204,13 +210,10 @@ }); - //ScrollComp on shell - final ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL); - scrolledComposite.setExpandVertical(true); - scrolledComposite.setExpandHorizontal(true); - final Composite comp = new Composite(scrolledComposite,SWT.NULL); + + final Composite comp = new Composite(parent,SWT.NULL); gridData = new GridData(GridData.FILL_BOTH); comp.setLayoutData(gridData); @@ -490,19 +493,20 @@ }); - //comp.pack(); - scrolledComposite.setContent(comp); + scrolledComposite.setContent(parent); + scrolledComposite.addControlListener(new ControlAdapter() { public void controlResized(ControlEvent e) { Rectangle r = scrolledComposite.getClientArea(); - scrolledComposite.setMinSize(parent.computeSize(r.width, SWT.DEFAULT)); + System.out.println(r.width + " : " + parent.computeSize(r.width,SWT.DEFAULT)); + scrolledComposite.setMinSize(parentTab.computeSize(r.width, SWT.DEFAULT)); } }); - prefsTab.setControl(parent); + prefsTab.setControl(scrolledComposite); parentTab.setSelection(prefsTab); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <oms...@us...> - 2006-03-19 00:37:44
|
Revision: 966 Author: omschaub Date: 2006-03-18 16:37:41 -0800 (Sat, 18 Mar 2006) ViewCVS: http://svn.sourceforge.net/azcvsupdater/?rev=966&view=rev Log Message: ----------- working with the scrolledcomp Modified Paths: -------------- trunk/AZMultiUser/lbms/azmultiuser/remote/client/firefrog/tabs/PreferencesTab.java Modified: trunk/AZMultiUser/lbms/azmultiuser/remote/client/firefrog/tabs/PreferencesTab.java =================================================================== --- trunk/AZMultiUser/lbms/azmultiuser/remote/client/firefrog/tabs/PreferencesTab.java 2006-03-19 00:15:17 UTC (rev 965) +++ trunk/AZMultiUser/lbms/azmultiuser/remote/client/firefrog/tabs/PreferencesTab.java 2006-03-19 00:37:41 UTC (rev 966) @@ -48,9 +48,9 @@ final CTabItem prefsTab = new CTabItem(parentTab, SWT.CLOSE); prefsTab.setText("Preferences"); - final Composite parent = new Composite(parentTab, SWT.NONE); + final Composite parent = new Composite(parentTab, SWT.NULL); parent.setLayout(new GridLayout(1,false)); - GridData gridData = new GridData(GridData.GRAB_HORIZONTAL); + GridData gridData = new GridData(GridData.FILL_BOTH); gridData.grabExcessHorizontalSpace = true; gridData.horizontalSpan = 1; parent.setLayoutData(gridData); @@ -205,13 +205,13 @@ //ScrollComp on shell - final ScrolledComposite SC1 = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL); - SC1.setExpandVertical(true); - SC1.setExpandHorizontal(true); + final ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL); + scrolledComposite.setExpandVertical(true); + scrolledComposite.setExpandHorizontal(true); - final Composite comp = new Composite(SC1,SWT.BORDER); - //gridData = new GridData(GridData.FILL_HORIZONTAL); + final Composite comp = new Composite(scrolledComposite,SWT.NULL); + gridData = new GridData(GridData.FILL_BOTH); comp.setLayoutData(gridData); gridLayout = new GridLayout(); @@ -321,17 +321,7 @@ } - //popupsEnabled - popupsEnabled = new Button(gMW,SWT.CHECK); - gridData = new GridData(GridData.GRAB_HORIZONTAL); - gridData.horizontalSpan = 2; - popupsEnabled.setLayoutData(gridData); - popupsEnabled.setText("Popup Alerts Enabled"); - if (Boolean.parseBoolean(properties.getProperty("popups_enabled","true"))) { - popupsEnabled.setSelection(true); - }else - popupsEnabled.setSelection(false); //Tray options trayMinimize = new Button(gMW,SWT.CHECK); @@ -361,8 +351,34 @@ + + + //---------------------- Misc Preferences -------------------\\ + + Group gMisc = new Group(comp,SWT.NULL); + gMisc.setText("Miscellaneous Preferences"); + gridData = new GridData(GridData.FILL_HORIZONTAL); + gMisc.setLayoutData(gridData); + + gridLayout = new GridLayout(); + gridLayout.numColumns = 2; + gridLayout.marginWidth = 0; + gMisc.setLayout(gridLayout); + + //popupsEnabled + popupsEnabled = new Button(gMisc,SWT.CHECK); + gridData = new GridData(GridData.GRAB_HORIZONTAL); + gridData.horizontalSpan = 2; + popupsEnabled.setLayoutData(gridData); + popupsEnabled.setText("Popup Alerts Enabled"); + + if (Boolean.parseBoolean(properties.getProperty("popups_enabled","true"))) { + popupsEnabled.setSelection(true); + }else + popupsEnabled.setSelection(false); + //AutoClipboard - autoClipboard = new Button(gMW,SWT.CHECK); + autoClipboard = new Button(gMisc,SWT.CHECK); gridData = new GridData(GridData.GRAB_HORIZONTAL); gridData.horizontalSpan = 2; autoClipboard.setLayoutData(gridData); @@ -372,9 +388,6 @@ autoClipboard.setSelection(true); } - - - //---------------------- Update Preferences -------------------\\ @@ -477,13 +490,13 @@ }); + //comp.pack(); + scrolledComposite.setContent(comp); - SC1.setContent(comp); - - SC1.addControlListener(new ControlAdapter() { + scrolledComposite.addControlListener(new ControlAdapter() { public void controlResized(ControlEvent e) { - Rectangle r = SC1.getClientArea(); - SC1.setMinSize(comp.computeSize(r.width, SWT.DEFAULT)); + Rectangle r = scrolledComposite.getClientArea(); + scrolledComposite.setMinSize(parent.computeSize(r.width, SWT.DEFAULT)); } }); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |