java-forum.org
JBoss Seam
Alter Preis: 39,95 €
Jetzt: 0,00 €

zzgl. Versandkosten

Zurück   java-forum.org > Java - Programmierung > Plattformprogrammierung

Plattformprogrammierung OSGi, Eclipse RCP und Co.

Antwort     Ist dieses Thema erledigt?
Themen-Optionen Thema durchsuchen Ansicht
Alt 21.06.2010, 17:00   #21 (permalink)
Neuer Benutzer
Byte
Themenstarter
 
Registriert seit: 28.05.2010
Beiträge: 22
Abgegebene Danke: 1
Erhielt 0 Danke für 0 Beiträge
So, soweit klappt jetzt alles. Die Hilfe meldet sich und die Hilfe beendet sich MIT all dem ganzen restlichen Kram im Hintergrund. *freu*

Ich hab mal die DefaultHelpUI mal zur Seite gelassen und in der BaseHelpSystem eine Methode gefunden, die auch meine Help aufruft. Hier mal der Code zum ausprobieren und freuen fuer die Communitiy.

Java Code: Quelltext in neuem Fenster öffnen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
package com.xyz.help.bootstrap;
 
import java.io.File;
 
@SuppressWarnings("restriction")
public class XYZHelpApplication implements IApplication,
        IExecutableExtension {
 
    private static final String APPLICATION_LOCK_FILE = ".applicationlock"; //$NON-NLS-1$
    private static final int STATE_EXITING = 0;
    private static final int STATE_RUNNING = 1;
    private static final int STATE_RESTARTING = 2;
    private static int status = STATE_RUNNING;
    private File metadata;
    private FileLock lock;
 
    /*
     * (non-Javadoc) 
     * 
     * @seeorg.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.
     * IApplicationContext)
     */
    public synchronized Object start(IApplicationContext context)
            throws Exception {
        if (status == STATE_RESTARTING) {
            return EXIT_RESTART;
        }
 
        metadata = new File(Platform.getLocation().toFile(), ".metadata/"); //$NON-NLS-1$
        if (!metadata.exists() || !metadata.isDirectory()) {
            metadata.mkdirs();
        }
 
        if (!BaseHelpSystem.ensureWebappRunning()) {
            System.out.println(NLS.bind(
                    HelpBaseResources.HelpApplication_couldNotStart, Platform
                            .getLogFileLocation().toOSString()));
            return EXIT_OK;
        }
 
        if (status == STATE_RESTARTING) {
            return EXIT_RESTART;
        }
 
        writeHostAndPort();
        obtainLock();
 
        // try running UI loop if possible
        runUI();
        
        
        // run a headless loop;
        while (status == STATE_RUNNING) {
            try {
                Thread.sleep(100);
            } catch (InterruptedException ie) {
                break;
            }
        }
        releaseLock();
        if (status == STATE_RESTARTING) {
            return EXIT_RESTART;
        }
        return EXIT_OK;
    }
 
    private void runUI() throws BundleException {
        // TODO Auto-generated method stub
 
 
 
        if (BaseHelpSystem.MODE_STANDALONE == BaseHelpSystem.getMode()) {
            // UI loop may be sleeping if no SWT browser is up
            try {
                wakeupUI();
            } catch (BundleException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        
        XYZHelpUIEventLoop.run();
    }
 
    /*
     * (non-Javadoc)
     * 
     * @see org.eclipse.equinox.app.IApplication#stop()
     */
    public void stop() {
        stopHelp();
 
        // wait until start has finished
        synchronized (this) {
        }
        ;
    }
 
    /**
     * Causes help service to stop and exit
     */
    public static void stopHelp() {
        status = STATE_EXITING;
        if (BaseHelpSystem.MODE_STANDALONE == BaseHelpSystem.getMode()) {
            // UI loop may be sleeping if no SWT browser is up
            try {
                wakeupUI();
            } catch (BundleException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
 
    private static void wakeupUI() throws BundleException {
        // TODO Auto-generated method stub
        XYZHelpUIEventLoop.wakeup();
//        invoke("wakeup");
    }
 
    /**
     * Causes help service to exit and start again
     */
    public static void restartHelp() {
        if (status != STATE_EXITING) {
            status = STATE_RESTARTING;
        }
    }
 
    /*
     * (non-Javadoc)
     * 
     * @see
     * org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org
     * .eclipse.core.runtime.IConfigurationElement, java.lang.String,
     * java.lang.Object)
     */
    @SuppressWarnings("unchecked")
    public void setInitializationData(IConfigurationElement configElement,
            String propertyName, Object data) {
        String value = (String) ((Map) data).get("mode"); //$NON-NLS-1$
        if ("infocenter".equalsIgnoreCase(value)) { //$NON-NLS-1$
            BaseHelpSystem.setMode(BaseHelpSystem.MODE_INFOCENTER);
        } else if ("standalone".equalsIgnoreCase(value)) { //$NON-NLS-1$
            BaseHelpSystem.setMode(BaseHelpSystem.MODE_STANDALONE);
        }
    }
    
    private void writeHostAndPort() throws IOException {
        Properties p = new Properties();
        p.put("host", WebappManager.getHost()); //$NON-NLS-1$
        p.put("port", "" + WebappManager.getPort()); //$NON-NLS-1$ //$NON-NLS-2$
 
        File hostPortFile = new File(metadata, ".connection"); //$NON-NLS-1$
        hostPortFile.deleteOnExit();
        FileOutputStream out = null;
        try {
            out = new FileOutputStream(hostPortFile);
            p.store(out, null);
        } finally {
            if (out != null) {
                try {
                    out.close();
                } catch (IOException ioe2) {
                }
            }
        }
 
    }
 
    private void obtainLock() {
        File lockFile = new File(metadata, APPLICATION_LOCK_FILE);
        try {
            RandomAccessFile raf = new RandomAccessFile(lockFile, "rw"); //$NON-NLS-1$
            lock = raf.getChannel().lock();
        } catch (IOException ioe) {
            lock = null;
        }
    }
 
    private void releaseLock() {
        if (lock != null) {
            try {
                lock.channel().close();
            } catch (IOException ioe) {
            }
        }
    }
 
    public static boolean isRunning() {
        return status == STATE_RUNNING;
    }
}

Java Code: Quelltext in neuem Fenster öffnen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package com.xyz.help.bootstrap;
 
import org.eclipse.help.internal.base.BaseHelpSystem;
import org.eclipse.help.internal.base.HelpBasePlugin;
import org.eclipse.help.internal.server.WebappManager;
import org.eclipse.swt.widgets.Display;
 
@SuppressWarnings("restriction")
public class XYZHelpUIEventLoop {
    /**
     * Indicates whether run had a chance to execute and display got created
     */
    private static boolean started = false;
    /**
     * Indicates whether it is still running
     */
    private static boolean running = false;
    private static Display display;
    /**
     * Called by base in stand-alone help since it cannot run event loop
     */
    public static void run() {
        
        try {
            if (display == null)
                display = Display.getCurrent();
            if (display == null)
                display = new Display();
        } finally {
            started = true;
        }
        try {
            running = true;
            
///////////////////////////////////////////////////Aenderung-Start///////////////////////////////////////////////////////////////////////////////////////            
            
            XYZEmbeddedBrowserAdapter xyzEmbeddedBrowserAdapter = new XYZEmbeddedBrowserAdapter();
            BaseHelpSystem.getInstance().setBrowserInstance(xyzoEmbeddedBrowserAdapter);
            try {
                BaseHelpSystem.getHelpBrowser(true).displayURL(getBaseURL() + "index.jsp");
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            
            
///////////////////////////////////////////////////Aenderung-Ende////////////////////////////////////////////////////////////////////////////////////////
            
            while (XYZHelpApplication.isRunning()) {
                try {
                    if (!display.readAndDispatch()) {
                        display.sleep();
                    }
                } catch (Throwable t) {
                    HelpBasePlugin.logError(t.getMessage(), t);
                }
            }
            display.dispose();
            display = null;
        } finally {
            running = false;
        }
    }
    public static void wakeup() {
        Display d = display;
        if (d != null)
            try {
                d.wake();
            } catch (Exception e) {
            }
    }
    /**
     * Blocks until the loop is started (Display created)
     */
    public static void waitFor() {
        while (!started && XYZHelpApplication.isRunning()) {
            try {
                Thread.sleep(100);
            } catch (InterruptedException ie) {
            }
        }
    }
    /**
     * @return Returns if loop is running.
     */
    public static boolean isRunning() {
        return running;
    }
    
    private static String getBaseURL() {
        return "http://" //$NON-NLS-1$
                + WebappManager.getHost() + ":" //$NON-NLS-1$
                + WebappManager.getPort() + "/help/"; //$NON-NLS-1$
    }
}

Java Code: Quelltext in neuem Fenster öffnen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
package com.xyz.help.bootstrap;
 
import org.eclipse.help.ui.internal.browser.embedded.EmbeddedBrowser;
import org.eclipse.help.ui.internal.browser.embedded.EmbeddedBrowserAdapter;
import org.eclipse.swt.widgets.Display;
 
@SuppressWarnings("restriction")
public class XYZEmbeddedBrowserAdapter extends EmbeddedBrowserAdapter {
    private EmbeddedBrowser browser;
    // Thread to use in workbench mode on Windows
    private UIThread2 secondThread;
    class UIThread2 extends Thread {
        
        Display d;
        
        boolean runEventLoop = true;
 
        public UIThread2() {
            super();
            setDaemon(true);
            setName("Help Browser UI"); //$NON-NLS-1$
        }
 
        public void run() {
            d = new Display();
            while (runEventLoop) {
                if (!d.readAndDispatch()) {
                    d.sleep();
                }
            }
            d.dispose();
        }
        public Display getDisplay() {
            while (d == null && isAlive()) {
                try {
                    sleep(40);
                } catch (InterruptedException ie) {
                }
            }
            return d;
        }
        public void dispose() {
            runEventLoop = false;
        }
    }
    /**
     * Adapter constructor.
     */
    public XYZEmbeddedBrowserAdapter() {
        
    }
    public Display getBrowserDisplay() {
        return Display.getDefault();
    }
 
    public void browserClosed() {
        browser=null;
        if(secondThread!=null){
            secondThread.dispose();
            secondThread = null;
        }
        ///////////////////////////////////////////////////Aenderung-Start/////////////////////////////////////////////////////////////////////////////////////// 
        XYZHelpApplication.stopHelp();
       ///////////////////////////////////////////////////Aenderung-Ende/////////////////////////////////////////////////////////////////////////////////////// 
    }
    /*
     * @see IBrowser#displayURL(String)
     */
    public synchronized void displayURL(final String url) {
        close();
        if (getBrowserDisplay() == Display.getCurrent()) {
            uiDisplayURL(url);
        } else {
            getBrowserDisplay().asyncExec(new Runnable() {
                public void run() {
                    uiDisplayURL(url);
                }
            });
        }
    }
    /**
     * Must be run on UI thread
     * 
     * @param url
     */
    private void uiDisplayURL(final String url) {
        getBrowser().displayUrl(url);
    }
 
    /*
     * @see IBrowser#close()
     */
    public synchronized void close() {
        if (getBrowserDisplay() == Display.getCurrent()) {
            uiClose();
        } else {
            getBrowserDisplay().syncExec(new Runnable() {
                public void run() {
                    uiClose();
                }
            });
        }
    }
    /*
     * Must be run on UI thread
     */
    private void uiClose() {
        if (browser != null && !browser.isDisposed()){
            browser.close();
        }
        if(secondThread!=null){
            secondThread.dispose();
            secondThread=null;
        }
    }
    /**
     *  
     */
    private EmbeddedBrowser getBrowser() {
        if (browser == null || browser.isDisposed()) {
            browser = new EmbeddedBrowser();
            browser.addCloseListener(this);
        }
        return browser;
    }
    /*
     * @see IBrowser#isCloseSupported()
     */
    public boolean isCloseSupported() {
        return true;
    }
    /*
     * @see IBrowser#isSetLocationSupported()
     */
    public boolean isSetLocationSupported() {
        return true;
    }
    /*
     * @see IBrowser#isSetSizeSupported()
     */
    public boolean isSetSizeSupported() {
        return true;
    }
    /*
     * @see IBrowser#setLocation(int, int)
     */
    public synchronized void setLocation(final int x, final int y) {
        if (getBrowserDisplay() == Display.getCurrent()) {
            uiSetLocation(x, y);
        } else {
            getBrowserDisplay().asyncExec(new Runnable() {
                public void run() {
                    uiSetLocation(x, y);
                }
            });
        }
    }
    /*
     * Must be run on UI thread
     */
    private void uiSetLocation(int x, int y) {
        getBrowser().setLocation(x, y);
    }
    /*
     * @see IBrowser#setSize(int, int)
     */
    public synchronized void setSize(final int width, final int height) {
        if (getBrowserDisplay() == Display.getCurrent()) {
            uiSetSize(width, height);
        } else {
            getBrowserDisplay().asyncExec(new Runnable() {
                public void run() {
                    uiSetSize(width, height);
                }
            });
        }
    }
    /*
     * Must be run on UI thread
     */
    private void uiSetSize(int width, int height) {
        getBrowser().setSize(width, height);
    }
}

Fuer jeden Verbesserungsvorschlag bin ich jederzeit Ohr!
__________________
"Niemand! Niemand!" (Polyphemos)

Geändert von namenlos123 (21.06.2010 um 17:03 Uhr)
namenlos123 ist offline  
Bei Google nach dem markiertem Wort suchen Bei Wikipedia nach dem markiertem Wort suchen Im Forum nach dem markiertem Wort suchen
Mit Zitat antworten
Alt 22.06.2010, 18:34   #22 (permalink)
Neuer Benutzer
Byte
Themenstarter
 
Registriert seit: 28.05.2010
Beiträge: 22
Abgegebene Danke: 1
Erhielt 0 Danke für 0 Beiträge
Achso... verspaetet aber noch daran gedacht...

Danke Wildcard fuer deine Beitraege. Hat mir dieses Thema verstaendlicher gemacht.


Gruss,
namenlos.
__________________
"Niemand! Niemand!" (Polyphemos)
namenlos123 ist offline  
Bei Google nach dem markiertem Wort suchen Bei Wikipedia nach dem markiertem Wort suchen Im Forum nach dem markiertem Wort suchen
Mit Zitat antworten
Alt 29.06.2010, 15:35   #23 (permalink)
Neuer Benutzer
Byte
Themenstarter
 
Registriert seit: 28.05.2010
Beiträge: 22
Abgegebene Danke: 1
Erhielt 0 Danke für 0 Beiträge
Das Thema kann geschlossen werden, falls keiner noch Fragen oder Anmerkungen zu Eclipse Standalone Help hat.
__________________
"Niemand! Niemand!" (Polyphemos)
namenlos123 ist offline  
Bei Google nach dem markiertem Wort suchen Bei Wikipedia nach dem markiertem Wort suchen Im Forum nach dem markiertem Wort suchen
Mit Zitat antworten
Antwort     Ist dieses Thema erledigt?

Lesezeichen

Stichworte
eclipse , help , standalone

Latex Maths & Physics Editor ...

Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln
Es ist Ihnen erlaubt, neue Themen zu verfassen.
Es ist Ihnen erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are aus
Pingbacks are aus
Refbacks are aus


Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
jappy und diverse andere Chats kaputt? 12golgaa Deployment 6 03.11.2009 18:51
eclipse debugger startet neu wenn ich code ändere ARadauer IDEs und Tools 2 09.05.2007 12:51
eclipse: jdocs externer Bibs in andere Workspaces übertragen kartoffelsack IDEs und Tools 1 09.08.2006 12:14
Eclipse - Help Contents IDEs und Tools 3 28.07.2006 15:20
Eclipse - bisi benutzerunfreundlich thE_29 IDEs und Tools 34 11.02.2005 08:40


Alle Zeitangaben in WEZ +2. Es ist jetzt 18:53 Uhr.


Powered by vBulletin® Version 3.8.6 (Deutsch)
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
Thanks for Smilies by smilies.4-user.de