Changeset 953ed23fed4eda5a6fd19c7ca7f4b67533e9af62

Show
Ignore:
Timestamp:
11/18/07 13:20:58 (1 year ago)
Author:
Christopher Jung <bktheg@web.de>
git-committer:
Christopher Jung <bktheg@web.de> 1195388458 +0100
git-parent:

[e7425e3612a5e766af750af41f3cb3e31b4fc85f]

git-author:
Christopher Jung <bktheg@web.de> 1195388458 +0100
Message:

Zweiter Teil Merge Menueleiste

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • db/updates.xml

    rf082126 r953ed23  
    427427                UPDATE ships SET modules=(SELECT id FROM ships_modules WHERE ships_modules.id=ships.id); 
    428428        ]]></update> 
     429        <update type="structure" datum="2007-11-11"><![CDATA[ 
     430                CREATE TABLE `gui_help` ( 
     431                  `page` varchar(30) NOT NULL, 
     432                  `text` text, 
     433                  PRIMARY KEY  (`page`) 
     434                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;  
     435        ]]></update> 
    429436</updates> 
  • src/net/driftingsouls/ds2/server/AdminCommands.java

    r8f9e522 r953ed23  
    6060 
    6161import org.apache.commons.lang.StringUtils; 
     62import org.apache.commons.lang.math.NumberUtils; 
    6263 
    6364/** 
     
    129130                org.hibernate.Session db = context.getDB(); 
    130131                 
     132                if( !NumberUtils.isNumber(command[1]) ) { 
     133                        return "Ungueltige Schiffs-ID"; 
     134                } 
     135                 
    131136                int sid = Integer.parseInt(command[1]); 
    132137                 
     
    137142                 
    138143                if( command[2].equals("heat") ) { 
     144                        if( !NumberUtils.isNumber(command[3]) ) { 
     145                                return "Ueberhitzung ungueltig"; 
     146                        } 
    139147                        ship.setHeat(Integer.parseInt(command[3])); 
    140148                }        
    141149                else if( command[2].equals("e") ) { 
     150                        if( !NumberUtils.isNumber(command[3]) ) { 
     151                                return "Energie ungueltig"; 
     152                        } 
    142153                        ship.setEnergy(Integer.parseInt(command[3])); 
    143154                } 
     
    158169                } 
    159170                else if( command[2].equals("hull") ) { 
     171                        if( !NumberUtils.isNumber(command[3]) ) { 
     172                                return "Huelle ungueltig"; 
     173                        } 
    160174                        ship.setHull(Integer.parseInt(command[3])); 
    161175                } 
    162176                else if( command[2].equals("shields") ) { 
     177                        if( !NumberUtils.isNumber(command[3]) ) { 
     178                                return "Schilde ungueltig"; 
     179                        } 
    163180                        ship.setShields(Integer.parseInt(command[3])); 
    164181                } 
    165182                else if( command[2].equals("crew") ) { 
     183                        if( !NumberUtils.isNumber(command[3]) ) { 
     184                                return "Crew ungueltig"; 
     185                        } 
    166186                        ship.setCrew(Integer.parseInt(command[3])); 
    167187                } 
     
    188208                } 
    189209                else if( command[2].equals("additemmodule") ) { 
     210                        if( !NumberUtils.isNumber(command[3]) ) { 
     211                                return "Slot ungueltig"; 
     212                        } 
    190213                        int slot = Integer.parseInt(command[3]); 
     214                         
     215                        if( !NumberUtils.isNumber(command[3]) ) { 
     216                                return "Item-ID ungueltig"; 
     217                        } 
    191218                        int item = Integer.parseInt(command[4]); 
    192219                         
     
    240267                 
    241268                String oid = command[1]; 
    242                 ResourceID resid = Resources.fromString(command[2]); 
     269                ResourceID resid = null; 
     270                try { 
     271                        Resources.fromString(command[2]); 
     272                } 
     273                catch( RuntimeException e ) { 
     274                        return "Die angegebene Resource ist ungueltig"; 
     275                } 
     276                 
     277                if( !NumberUtils.isNumber(command[3]) ) { 
     278                        return "Menge ungueltig"; 
     279                } 
    243280                long count = Long.parseLong(command[3]); 
    244281                 
    245282                org.hibernate.Session db = context.getDB(); 
     283                 
     284                if( !NumberUtils.isNumber(oid.substring(1)) ) { 
     285                        return "ID ungueltig"; 
     286                } 
    246287                 
    247288                Cargo cargo = null; 
  • src/net/driftingsouls/ds2/server/framework/pipeline/generators/DSGenerator.java

    ra65fe41 r953ed23  
    4545        protected static abstract class OutputHelper { 
    4646                private Context context = null; 
    47                 private Map<String,String> attributes = new HashMap<String,String>(); 
     47                private Map<String,Object> attributes = new HashMap<String,Object>(); 
    4848                 
    4949                /** 
     
    7676                 * @param value Der Wert 
    7777                 */ 
    78                 public final void setAttribute(String key, String value) { 
     78                public final void setAttribute(String key, Object value) { 
    7979                        this.attributes.put(key, value); 
    8080                } 
     
    8585                 * @return Der Wert 
    8686                 */ 
    87                 public final String getAttribute(String key) { 
     87                public final Object getAttribute(String key) { 
    8888                        return this.attributes.get(key); 
    8989                } 
     
    103103         * <ul> 
    104104         * <li><code>header</code> - String mit weiteren Header-Text 
     105         * <li><code>module</code> - Das gerade ausgefuehrte Modul 
     106         * <li><code>pagetitle</code> - Der Titel der Seite 
     107         * <li><code>pagemenu</code> - Eine Liste von Menueeintraegen fuer die Seite 
    105108         * </ul> 
    106109         * 
     
    161164                        sb.append("}\n"); 
    162165                        sb.append("}\n"); 
     166                         
     167                        if( this.getAttribute("module") != null ) { 
     168                                sb.append("if( parent && parent.setCurrentPage ) {\n"); 
     169                                sb.append("parent.setCurrentPage('"+this.getAttribute("module")+"','"+this.getAttribute("pagetitle")+"');\n"); 
     170                                PageMenuEntry[] entries = (PageMenuEntry[])this.getAttribute("pagemenu"); 
     171                                if( (entries != null) && (entries.length > 0) ) { 
     172                                        for( int i=0; i < entries.length; i++ ) { 
     173                                                sb.append("parent.addPageMenuEntry('"+entries[i].title+"','"+entries[i].url.replace("&amp;", "&")+"');"); 
     174                                        } 
     175                                } 
     176                                sb.append("parent.completePage();"); 
     177                                sb.append("}\n"); 
     178                        } 
     179 
    163180                        sb.append("// -->\n"); 
    164181                        sb.append("</script>\n"); 
     
    219236        } 
    220237         
     238        private static class PageMenuEntry { 
     239                String title; 
     240                String url; 
     241                 
     242                PageMenuEntry(String title, String url) { 
     243                        this.title = title; 
     244                        this.url = url; 
     245                } 
     246        } 
     247         
    221248        private ActionType actionType; 
    222249        private OutputHelper actionTypeHandler; 
     
    231258        private String subParameter; 
    232259        private List<String> preloadUserValues; 
     260        private String pageTitle; 
     261        private List<PageMenuEntry> pageMenuEntries; 
     262        private boolean disablePageMenu; 
    233263         
    234264        /** 
     
    239269                super(context); 
    240270                 
    241                 parameter = new HashMap<String,Object>(); 
    242                 subParameter = ""; 
     271                this.parameter = new HashMap<String,Object>(); 
     272                this.subParameter = ""; 
    243273                 
    244274                parameterString("sess"); 
     
    247277                parameterString("_style"); 
    248278                 
    249                 startTime = System.currentTimeMillis(); 
    250                  
    251                 disableDebugOutput = false; 
    252                 requireValidSession = true; 
    253                 disableDefaultCSS = false; 
    254                  
    255                 onLoadFunctions = new ArrayList<String>(); 
    256                 bodyParameters = new HashMap<String,String>(); 
    257                  
    258                 preloadUserValues = new ArrayList<String>(); 
    259                 preloadUserValues.add("id"); 
     279                this.startTime = System.currentTimeMillis(); 
     280                 
     281                this.disableDebugOutput = false; 
     282                this.requireValidSession = true; 
     283                this.disableDefaultCSS = false; 
     284                 
     285                this.onLoadFunctions = new ArrayList<String>(); 
     286                this.bodyParameters = new HashMap<String,String>(); 
     287                 
     288                this.preloadUserValues = new ArrayList<String>(); 
     289                this.preloadUserValues.add("id"); 
     290                 
     291                this.pageTitle = null; 
     292                this.pageMenuEntries = new ArrayList<PageMenuEntry>(); 
     293                this.disablePageMenu = false; 
    260294 
    261295                setActionType(ActionType.DEFAULT); 
     
    500534                } 
    501535                 
     536                if( !this.disablePageMenu ) { 
     537                        actionTypeHandler.setAttribute("module", getString("module")); 
     538                        actionTypeHandler.setAttribute("pagetitle", this.pageTitle); 
     539                        actionTypeHandler.setAttribute("pagemenu", this.pageMenuEntries.toArray(new PageMenuEntry[this.pageMenuEntries.size()])); 
     540                } 
    502541                actionTypeHandler.printHeader(); 
    503542                 
     
    514553         
    515554        protected void printHeader( String action ) { 
     555                if( !this.disablePageMenu ) { 
     556                        actionTypeHandler.setAttribute("module", getString("module")); 
     557                        actionTypeHandler.setAttribute("pagetitle", this.pageTitle); 
     558                        actionTypeHandler.setAttribute("pagemenu", this.pageMenuEntries.toArray(new PageMenuEntry[this.pageMenuEntries.size()])); 
     559                } 
     560                 
    516561                actionTypeHandler.printHeader(); 
    517562        } 
     
    560605        public boolean getDisableDefaultCSS() { 
    561606                return disableDefaultCSS;        
     607        } 
     608         
     609        /** 
     610         * Setzt die Bezeichnung der aktuellen Seite 
     611         * @param title Die Bezeichnung 
     612         */ 
     613        public void setPageTitle(String title) { 
     614                this.pageTitle = title; 
     615        } 
     616         
     617        /** 
     618         * Fuegt dem Seitenmenue einen Eintrag hinzu 
     619         * @param title Die Titel des Eintrags 
     620         * @param url Die URL 
     621         */ 
     622        public void addPageMenuEntry(String title, String url) { 
     623                this.pageMenuEntries.add(new PageMenuEntry(title, url)); 
     624        } 
     625         
     626        /** 
     627         * Setzt, ob das Seitenmenue nicht verwendet werden soll 
     628         * @param value <code>true</code>, falls es nicht verwendet werden soll 
     629         */ 
     630        public void setDisablePageMenu(boolean value) { 
     631                this.disablePageMenu = value; 
    562632        } 
    563633         
  • src/net/driftingsouls/ds2/server/modules/ActivateAllController.java

    r7375108 r953ed23  
    5252                parameterNumber("col"); 
    5353                parameterNumber("deaconly"); 
     54                 
     55                setPageTitle("Alles Aktivieren"); 
    5456        } 
    5557         
  • src/net/driftingsouls/ds2/server/modules/AdminController.java

    refe50c3 r953ed23  
    127127                 
    128128                if( this.getInteger("cleanpage") > 0 ) { 
    129                         this.setDisableDebugOutput(true);        
     129                        this.setDisableDebugOutput(true); 
     130                        this.setDisablePageMenu(true); 
    130131                } 
    131132                 
    132133                return true; 
     134        } 
     135         
     136        /** 
     137         * Fuehrt ein Admin-Plugin aus 
     138         */ 
     139        @Action(ActionType.AJAX) 
     140        public void ajaxAction() { 
     141                int act = getInteger("act"); 
     142                String page = getString("page"); 
     143                String namedplugin = getString("namedplugin"); 
     144                 
     145                if( page.length() > 0 || namedplugin.length() > 0 ) { 
     146                        if( act > 0 ) { 
     147                                callPlugin(page, act); 
     148                        } 
     149                        else if( (namedplugin.length() > 0) && (validPlugins.contains(namedplugin)) ) { 
     150                                callNamedPlugin(namedplugin); 
     151                        } 
     152                } 
    133153        } 
    134154 
     
    184204                        } 
    185205                        if( act > 0 ) { 
    186                                 if( this.menu.containsKey(page) && (this.menu.get(page).actions.size() > 0) ) { 
    187                                         List<MenuEntry> actions = this.menu.get(page).actions; 
    188                                         if( act <= actions.size() ) { 
    189                                                 Class<? extends AdminPlugin> cls = actions.get(act-1).cls; 
    190                                                 try { 
    191                                                         AdminPlugin plugin; 
    192                                                         plugin = cls.newInstance(); 
    193                                                         plugin.output(this, page, act); 
    194                                                 } 
    195                                                 catch( InstantiationException e ) { 
    196                                                         addError("Fehler beim Aufruf des Admin-Plugins: "+e); 
    197                                                 } 
    198                                                 catch( IllegalAccessException e ) { 
    199                                                         addError("Fehler beim Aufruf des Admin-Plugins: "+e); 
    200                                                 } 
    201                                         } 
    202                                 } 
     206                                callPlugin(page, act); 
    203207                        } 
    204208                        else if( (namedplugin.length() > 0) && (validPlugins.contains(namedplugin)) ) { 
    205                                 try { 
    206                                         Class<? extends AdminPlugin> aClass = null; 
    207                                         for( String aPage : this.menu.keySet() ) { 
    208                                                 List<MenuEntry> actions = this.menu.get(aPage).actions; 
    209                                                 for( int aAction=0; aAction < actions.size(); aAction++ ) { 
    210                                                         if( actions.get(aAction).cls.getName().equals(namedplugin) ) { 
    211                                                                 aClass = actions.get(aAction).cls; 
    212                                                                 page = aPage; 
    213                                                                 act = aAction+1; 
    214                                                                 break; 
    215                                                         } 
    216                                                 } 
    217                                         } 
    218  
    219                                         AdminPlugin plugin = aClass.newInstance(); 
    220                                         plugin.output(this, page, act); 
    221                                 } 
    222                                 catch( Exception e ) { 
    223                                         addError("Fehler beim Aufruf des Admin-Plugins: "+e); 
    224                                         e.printStackTrace(); 
    225                                 } 
     209                                callNamedPlugin(namedplugin); 
    226210                        } 
    227211 
     
    231215                } 
    232216        } 
     217 
     218        private void callNamedPlugin(String namedplugin) { 
     219                try { 
     220                        int act = 0; 
     221                        String page = ""; 
     222                         
     223                        Class<? extends AdminPlugin> aClass = null; 
     224                        for( String aPage : this.menu.keySet() ) { 
     225                                List<MenuEntry> actions = this.menu.get(aPage).actions; 
     226                                for( int aAction=0; aAction < actions.size(); aAction++ ) { 
     227                                        if( actions.get(aAction).cls.getName().equals(namedplugin) ) { 
     228                                                aClass = actions.get(aAction).cls; 
     229                                                page = aPage; 
     230                                                act = aAction+1; 
     231                                                break; 
     232                                        } 
     233                                } 
     234                        } 
     235 
     236                        AdminPlugin plugin = aClass.newInstance(); 
     237                        plugin.output(this, page, act); 
     238                } 
     239                catch( Exception e ) { 
     240                        addError("Fehler beim Aufruf des Admin-Plugins: "+e); 
     241                        e.printStackTrace(); 
     242                } 
     243        } 
     244 
     245        private void callPlugin(String page, int act) { 
     246                if( this.menu.containsKey(page) && (this.menu.get(page).actions.size() > 0) ) { 
     247                        List<MenuEntry> actions = this.menu.get(page).actions; 
     248                        if( act <= actions.size() ) { 
     249                                Class<? extends AdminPlugin> cls = actions.get(act-1).cls; 
     250                                try { 
     251                                        AdminPlugin plugin; 
     252                                        plugin = cls.newInstance(); 
     253                                        plugin.output(this, page, act); 
     254                                } 
     255                                catch( InstantiationException e ) { 
     256                                        addError("Fehler beim Aufruf des Admin-Plugins: "+e); 
     257                                } 
     258                                catch( IllegalAccessException e ) { 
     259                                        addError("Fehler beim Aufruf des Admin-Plugins: "+e); 
     260                                } 
     261                        } 
     262                } 
     263        } 
    233264} 
  • src/net/driftingsouls/ds2/server/modules/AllyController.java

    rd9e8da0 r953ed23  
    7070                 
    7171                parameterString("show"); 
     72                 
     73                setPageTitle("Allianz"); 
    7274        } 
    7375         
  • src/net/driftingsouls/ds2/server/modules/AllyListController.java

    ra6d36b9 r953ed23  
    4848                 
    4949                setTemplate("allylist.html"); 
     50                 
     51                setPageTitle("Allianzliste"); 
    5052        } 
    5153         
  • src/net/driftingsouls/ds2/server/modules/AngriffController.java

    rd9e8da0 r953ed23  
    160160                 
    161161                setTemplate("angriff.html"); 
     162                 
     163                setPageTitle("Schlacht"); 
    162164        } 
    163165         
  • src/net/driftingsouls/ds2/server/modules/BaseController.java

    r7375108 r953ed23  
    6161                setTemplate("base.html"); 
    6262                 
    63                 parameterNumber("col");  
     63                parameterNumber("col"); 
     64                 
     65                setPageTitle("Basis"); 
    6466        } 
    6567         
     
    7880                 
    7981                base.getCargo().setOption( Cargo.Option.LINKCLASS, "schiffwaren" ); 
     82                 
     83                setPageTitle(Common._plaintitle(base.getName())); 
    8084                 
    8185                return true;     
  • src/net/driftingsouls/ds2/server/modules/BuildController.java

    r7375108 r953ed23  
    5858                parameterNumber("col"); 
    5959                parameterNumber("field"); 
     60                 
     61                setPageTitle("Bauen"); 
    6062        } 
    6163         
  • src/net/driftingsouls/ds2/server/modules/BuildingController.java

    r34f5892 r953ed23  
    5252                 
    5353                parameterNumber("col");  
    54                 parameterNumber("field");        
     54                parameterNumber("field"); 
     55                 
     56                setPageTitle("Geb&auml;ude"); 
    5557        } 
    5658                 
  • src/net/driftingsouls/ds2/server/modules/BuildingsController.java

    r7375108 r953ed23  
    5454                 
    5555                parameterNumber("col");  
    56                 parameterNumber("field");        
     56                parameterNumber("field"); 
     57                 
     58                setPageTitle("Geb&auml;ude"); 
    5759        } 
    5860         
  • src/net/driftingsouls/ds2/server/modules/ChoffController.java

    r7375108 r953ed23  
    4747                setTemplate("choff.html"); 
    4848                 
    49                 parameterNumber("off");          
     49                parameterNumber("off"); 
     50                 
     51                setPageTitle("Offizier"); 
    5052        } 
    5153         
  • src/net/driftingsouls/ds2/server/modules/ColonizeController.java

    r7375108 r953ed23  
    6464                parameterNumber("ship"); 
    6565                parameterNumber("col"); 
     66                 
     67                setPageTitle("Kolonisieren"); 
    6668        } 
    6769         
  • src/net/driftingsouls/ds2/server/modules/ComNetController.java

    r29c70d8 r953ed23  
    5959                setTemplate("comnet.html"); 
    6060                 
    61                 parameterNumber("channel");              
     61                parameterNumber("channel"); 
     62                 
     63                setPageTitle("Com-Net"); 
    6264        } 
    6365         
  • src/net/driftingsouls/ds2/server/modules/CommController.java

    r1a0c3f8 r953ed23  
    6565                 
    6666                setTemplate("comm.html"); 
     67                 
     68                setPageTitle("PMs"); 
     69                addPageMenuEntry("Neue Nachricht", Common.buildUrl("default", "to", 0)); 
     70                addPageMenuEntry("Posteingang", Common.buildUrl("showInbox")); 
     71                addPageMenuEntry("Postausgang", Common.buildUrl("showOutbox")); 
    6772        } 
    6873         
  • src/net/driftingsouls/ds2/server/modules/CoreController.java

    r7375108 r953ed23  
    5252                setTemplate("core.html"); 
    5353                 
    54                 parameterNumber("col");          
     54                parameterNumber("col"); 
     55                 
     56                setPageTitle("Core"); 
    5557        } 
    5658         
  • src/net/driftingsouls/ds2/server/modules/CrewtauschController.java

    r390f9f1 r953ed23  
    217217                parameterNumber("tar"); 
    218218                parameterString("mode"); 
     219                 
     220                setPageTitle("Crewtransfer"); 
    219221        } 
    220222         
  • src/net/driftingsouls/ds2/server/modules/DeutAllController.java

    rfda3b6d r953ed23  
    5454                 
    5555                setTemplate("deutall.html"); 
     56                 
     57                setPageTitle("Deut. sammeln"); 
    5658        } 
    5759         
  • src/net/driftingsouls/ds2/server/modules/DeutSammelnController.java

    r7375108 r953ed23  
    5555                 
    5656                parameterNumber("ship"); 
     57                 
     58                setPageTitle("Deut. sammeln"); 
    5759        } 
    5860         
  • src/net/driftingsouls/ds2/server/modules/ErsteigernController.java

    rf4821b7 r953ed23  
    387387                 
    388388                parameterNumber("faction"); 
     389                 
     390                setPageTitle("Fraktionen"); 
    389391        } 
    390392         
  • src/net/driftingsouls/ds2/server/modules/ForschinfoController.java

    r7375108 r953ed23  
    6363                 
    6464                parameterNumber("res"); 
     65                 
     66                setPageTitle("Forschung"); 
    6567        } 
    6668         
  • src/net/driftingsouls/ds2/server/modules/GtuZwischenLagerController.java

    r7375108 r953ed23  
    7575                 
    7676                parameterNumber("ship"); 
     77                 
     78<