Source Code Cross Referenced for VALinkGnome.java in  » Installer » VAInstall » com » memoire » vainstall » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Installer » VAInstall » com.memoire.vainstall 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * $RCSfile: VALinkGnome.java,v $
003:         * @creation     28/03/00
004:         * @modification $Date: 2005/03/30 19:42:44 $
005:         * Bug-fixing and additional features by Antonio Petrelli
006:         */package com.memoire.vainstall;
007:
008:        import java.io.File;
009:        import java.io.FileNotFoundException;
010:        import java.io.FileOutputStream;
011:        import java.io.IOException;
012:        import java.io.PrintWriter;
013:        import java.util.Date;
014:        import java.util.Set;
015:
016:        /**
017:         * @version $Id: VALinkGnome.java,v 1.7 2005/03/30 19:42:44 deniger Exp $
018:         * @author  Guillaume Desnoix
019:         */
020:
021:        public class VALinkGnome {
022:            private static String getIcon(String _name) {
023:                File common_icon = null;
024:                if ((VAGlobals.LINK_ENTRY_ICON != null)
025:                        && (VAGlobals.LINK_ENTRY_ICON.length() > 0)) {
026:                    common_icon = new File(VAGlobals.DEST_PATH,
027:                            VAGlobals.LINK_ENTRY_ICON.replace('/',
028:                                    File.separatorChar)
029:                                    + ".png");
030:                    VAGlobals.printDebug("common_icon=" + common_icon);
031:                }
032:                File script_icon = null;
033:                if (common_icon != null)
034:                    script_icon = new File(common_icon.getParentFile(), _name
035:                            + ".png");
036:                else
037:                    script_icon = new File(VAGlobals.DEST_PATH, _name + ".png");
038:                VAGlobals.printDebug("script_icon=" + script_icon);
039:
040:                if (script_icon.exists())
041:                    return script_icon.getAbsolutePath();
042:                if (common_icon.exists())
043:                    return common_icon.getAbsolutePath();
044:                return null;
045:            }
046:
047:            private static void writeEntry(String _name, File _file)
048:                    throws FileNotFoundException {
049:                writeEntry(_name, _file, _name, _name);
050:            }
051:
052:            private static void writeEntry(String _name, File _file,
053:                    String shortcutName, String shortcutIconName)
054:                    throws FileNotFoundException {
055:                PrintWriter out = new PrintWriter(new FileOutputStream(_file));
056:
057:                out.println("[Desktop Entry]");
058:
059:                out.println("Name=" + shortcutName);
060:                out.println("Comment=" + VAGlobals.APP_NAME + " "
061:                        + VAGlobals.APP_VERSION);
062:                out.println("Exec="
063:                        + new File(VAGlobals.DEST_PATH, _name + ".sh")
064:                                .getAbsolutePath());
065:
066:                out.println("Icon=" + getIcon(shortcutIconName));
067:                out.println("Terminal=0");
068:                out.println("Type=Application");
069:                out.println("Categories=Application;");
070:
071:                out.println("");
072:                out.println("# Gnome Config File");
073:                out.println("# for " + _name + " (" + VAGlobals.APP_NAME + " "
074:                        + VAGlobals.APP_VERSION + ")");
075:                out.println("# produced by VAInstall on " + new Date());
076:
077:                out.flush();
078:                out.close();
079:
080:                // needed for Nautilus
081:                _file.setLastModified(System.currentTimeMillis() + 5000l);
082:            }
083:
084:            public static boolean delete(String _name) throws IOException {
085:                boolean r = false;
086:
087:                File f = new File(System.getProperty("user.home")
088:                        + System.getProperty("file.separator") + ".gnome"
089:                        + System.getProperty("file.separator") + "apps");
090:
091:                if (f.canWrite()) {
092:                    f = new File(f, _name + ".desktop");
093:                    if (f.exists()) {
094:                        f.delete();
095:                        r = true;
096:                    }
097:                }
098:
099:                f = new File(System.getProperty("user.home")
100:                        + System.getProperty("file.separator")
101:                        + ".gnome-desktop");
102:
103:                if (f.canWrite()) {
104:                    f = new File(f, _name + ".desktop");
105:                    if (f.exists()) {
106:                        f.delete();
107:                    }
108:                }
109:
110:                return r;
111:            }
112:
113:            public static boolean create(String _name, Set shortcuts)
114:                    throws IOException {
115:                return create(_name, shortcuts, System.getProperty("user.home")
116:                        + File.separator + ".gnome" + File.separator + "apps"
117:                        + File.separator, true);
118:            }
119:
120:            public static boolean create(String _name, Set shortcuts,
121:                    String shortcutDir, boolean appendAppDirName)
122:                    throws IOException {
123:                boolean r = false;
124:                File tempFile;
125:
126:                // MENU
127:
128:                File f = new File(shortcutDir);
129:                if (appendAppDirName)
130:                    tempFile = new java.io.File(f, VAGlobals.LINK_SECTION_NAME);
131:                else
132:                    tempFile = f;
133:                if (!tempFile.exists()) {
134:                    if (tempFile.mkdirs()) {
135:                        shortcuts.add(tempFile.getAbsolutePath());
136:                        f = tempFile;
137:                    }
138:                } else if (tempFile.isDirectory()) {
139:                    f = tempFile;
140:                    shortcuts.add(tempFile.getAbsolutePath());
141:                }
142:
143:                // MENU
144:
145:                if (f.canWrite()) {
146:                    f = new File(f, _name + ".desktop");
147:                    // System.err.println(""+f);
148:                    shortcuts.add(f.getAbsolutePath());
149:                    try {
150:                        writeEntry(_name, f);
151:                        r = true;
152:                    } catch (FileNotFoundException ex) {
153:                    }
154:                }
155:
156:                // DESKTOP
157:
158:                f = new File(System.getProperty("user.home") + File.separator
159:                        + ".gnome-desktop");
160:
161:                if (f.canWrite()) {
162:                    f = new File(f, _name + ".desktop");
163:                    shortcuts.add(f.getAbsolutePath());
164:                    // System.err.println(""+f);
165:                    try {
166:                        writeEntry(_name, f);
167:                    } catch (FileNotFoundException ex) {
168:                    }
169:                }
170:
171:                return r;
172:            }
173:
174:            public static boolean createUninstallShortcut(Set shortcuts)
175:                    throws IOException {
176:                return createUninstallShortcut(shortcuts, System
177:                        .getProperty("user.home")
178:                        + File.separator
179:                        + ".gnome"
180:                        + File.separator
181:                        + "apps"
182:                        + File.separator, true);
183:            }
184:
185:            public static boolean createUninstallShortcut(Set shortcuts,
186:                    String shortcutDir, boolean appendAppDirName)
187:                    throws IOException {
188:                boolean r = false;
189:                File tempFile;
190:                String uninstallName;
191:
192:                // MENU
193:
194:                File f = new File(shortcutDir);
195:                if (appendAppDirName)
196:                    tempFile = new java.io.File(f, VAGlobals.LINK_SECTION_NAME);
197:                else
198:                    tempFile = f;
199:                if (!tempFile.exists()) {
200:                    if (tempFile.mkdirs()) {
201:                        shortcuts.add(tempFile.getAbsolutePath());
202:                        f = tempFile;
203:                    }
204:                } else if (tempFile.isDirectory()) {
205:                    f = tempFile;
206:                    shortcuts.add(tempFile.getAbsolutePath());
207:                }
208:
209:                // MENU
210:
211:                if (f.canWrite()) {
212:                    uninstallName = "uninstall_" + VAGlobals.APP_NAME + "_"
213:                            + VAGlobals.APP_VERSION;
214:                    f = new File(f, uninstallName + ".desktop");
215:                    // System.err.println(""+f);
216:                    shortcuts.add(f.getAbsolutePath());
217:                    try {
218:                        writeEntry(uninstallName, f, "Uninstall "
219:                                + VAGlobals.APP_NAME, "uninstall");
220:                        r = true;
221:                    } catch (FileNotFoundException ex) {
222:                    }
223:                }
224:                return r;
225:            }
226:
227:            public static boolean createAll(Object[] _launchparams,
228:                    Set shortCuts) throws IOException {
229:                boolean r = true;
230:                String gnome2dir;
231:
232:                gnome2dir = System.getProperty("user.home") + File.separator
233:                        + ".gnome2" + File.separator + "vfolders"
234:                        + File.separator + "applications" + File.separator;
235:                if (_launchparams != null)
236:                    for (int i = 0; i < _launchparams.length; i++) {
237:                        r &= create((String) ((Object[]) _launchparams[i])[0],
238:                                shortCuts);
239:                        r &= create((String) ((Object[]) _launchparams[i])[0],
240:                                shortCuts, gnome2dir, false);
241:                    }
242:                if (VAGlobals.CREATE_UNINSTALL_SHORTCUT) {
243:                    r &= createUninstallShortcut(shortCuts);
244:                    r &= createUninstallShortcut(shortCuts, gnome2dir, false);
245:                }
246:                return r;
247:            }
248:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.