Mercurial > projects > dwt-addons
diff dwtx/jface/text/contentassist/ContentAssistant.d @ 168:cef27f663573
jface.text ...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Tue, 09 Sep 2008 17:44:11 +0200 |
parents | 862b05e0334a |
children | c3583c6ec027 |
line wrap: on
line diff
--- a/dwtx/jface/text/contentassist/ContentAssistant.d Tue Sep 09 15:59:16 2008 +0200 +++ b/dwtx/jface/text/contentassist/ContentAssistant.d Tue Sep 09 17:44:11 2008 +0200 @@ -49,6 +49,8 @@ import dwt.dwthelper.utils; import dwtx.dwtxhelper.Collection; import dwtx.dwtxhelper.JThread; +import tango.core.sync.Mutex; +import tango.core.sync.Condition; import dwt.DWT; import dwt.DWTError; @@ -276,30 +278,38 @@ */ protected class AutoAssistListener : KeyAdapter , KeyListener, Runnable, VerifyKeyListener { + // DWT intf impl + public void keyReleased(KeyEvent e) { + super.keyReleased(e); + } + private JThread fThread; private bool fIsReset= false; - private Object fMutex= new Object(); + private Mutex fMutex; + private Condition fMutex_cond; private int fShowStyle; private const static int SHOW_PROPOSALS= 1; private const static int SHOW_CONTEXT_INFO= 2; protected this() { + fMutex = new Mutex(); + fMutex_cond = new Condition(fMutex); } protected void start(int showStyle) { fShowStyle= showStyle; - fThread= new Thread(&run); - fThread.name = JFaceTextMessages.getString("ContentAssistant.assist_delay_timer_name"); //$NON-NLS-1$ + fThread= new JThread(this); + fThread.setName( JFaceTextMessages.getString("ContentAssistant.assist_delay_timer_name")); //$NON-NLS-1$ fThread.start(); } - public void run() { + public override void run() { try { while (true) { synchronized (fMutex) { if (fAutoActivationDelay !is 0) - fMutex.wait(fAutoActivationDelay); + fMutex_cond.wait(fAutoActivationDelay); if (fIsReset) { fIsReset= false; continue; @@ -317,12 +327,12 @@ synchronized (fMutex) { fShowStyle= showStyle; fIsReset= true; - fMutex.notifyAll(); + fMutex_cond.notifyAll(); } } protected void stop() { - Thread threadToStop= fThread; + JThread threadToStop= fThread; if (threadToStop !is null && threadToStop.isAlive()) threadToStop.interrupt(); } @@ -432,8 +442,13 @@ public const static int LAYOUT_CONTEXT_INFO_POPUP= 2; int fContextType= LAYOUT_CONTEXT_SELECTOR; - Shell[] fShells= new Shell[3]; - Object[] fPopups= new Object[3]; + Shell[] fShells; + Object[] fPopups; + + this(){ + fShells= new Shell[3]; + fPopups= new Object[3]; + } protected void add(Object popup, Shell shell, int type, int offset) { Assert.isNotNull(popup); @@ -668,7 +683,7 @@ Control subjectControl= fContentAssistSubjectControlAdapter.getControl(); Display display= subjectControl.getDisplay(); Rectangle caret= getCaretRectangle(offset); - Monitor monitor= getClosestMonitor(display, caret); + dwt.widgets.Monitor.Monitor monitor= getClosestMonitor(display, caret); Rectangle bounds= monitor.getClientArea(); Geometry.moveInside(caret, bounds); @@ -708,7 +723,7 @@ Control subjectControl= fContentAssistSubjectControlAdapter.getControl(); Display display= subjectControl.getDisplay(); Rectangle caret= getCaretRectangle(offset); - Monitor monitor= getClosestMonitor(display, caret); + dwt.widgets.Monitor.Monitor monitor= getClosestMonitor(display, caret); Rectangle bounds= monitor.getClientArea(); Geometry.moveInside(caret, bounds); @@ -761,7 +776,7 @@ p= parent.toDisplay(p); Point shellSize= shell.getSize(); - Monitor monitor= getClosestMonitor(parent.getDisplay(), new Rectangle(p.x, p.y, 0, 0)); + dwt.widgets.Monitor.Monitor monitor= getClosestMonitor(parent.getDisplay(), new Rectangle(p.x, p.y, 0, 0)); Rectangle displayBounds= monitor.getClientArea(); constrainLocation(p, shellSize, displayBounds); @@ -800,15 +815,15 @@ * @return the monitor closest to the given point * @since 3.3 */ - private Monitor getClosestMonitor(Display toSearch, Rectangle rectangle) { + private dwt.widgets.Monitor.Monitor getClosestMonitor(Display toSearch, Rectangle rectangle) { int closest = Integer.MAX_VALUE; Point toFind= Geometry.centerPoint(rectangle); - Monitor[] monitors = toSearch.getMonitors(); - Monitor result = monitors[0]; + dwt.widgets.Monitor.Monitor[] monitors = toSearch.getMonitors(); + dwt.widgets.Monitor.Monitor result = monitors[0]; for (int idx = 0; idx < monitors.length; idx++) { - Monitor current = monitors[idx]; + dwt.widgets.Monitor.Monitor current = monitors[idx]; Rectangle clientArea = current.getClientArea(); @@ -840,7 +855,7 @@ * @see VerifyKeyListener#verifyKey(dwt.events.VerifyEvent) */ public void verifyKey(VerifyEvent e) { - IContentAssistListener[] listeners= arraycast!(IContentAssistListener)( fListeners.clone() ); + IContentAssistListener[] listeners= arraycast!(IContentAssistListener)( fListeners.dup ); for (int i= 0; i < listeners.length; i++) { if (listeners[i] !is null) { if (!listeners[i].verifyKey(e) || !e.doit) @@ -858,7 +873,7 @@ installKeyListener(); - IContentAssistListener[] listeners= arraycast!(IContentAssistListener)( fListeners.clone() ); + IContentAssistListener[] listeners= arraycast!(IContentAssistListener)( fListeners.dup ); for (int i= 0; i < listeners.length; i++) { if (listeners[i] !is null) { listeners[i].processEvent(event); @@ -878,9 +893,9 @@ public static const String STORE_SIZE_Y= "size.y"; //$NON-NLS-1$ // Content-Assist Listener types - final static int CONTEXT_SELECTOR= 0; - final static int PROPOSAL_SELECTOR= 1; - final static int CONTEXT_INFO_POPUP= 2; + const static int CONTEXT_SELECTOR= 0; + const static int PROPOSAL_SELECTOR= 1; + const static int CONTEXT_INFO_POPUP= 2; /** * The popup priority: > linked position proposals and hover pop-ups. Default value: @@ -1075,7 +1090,7 @@ if (processor is null) fProcessors.remove(contentType); else - fProcessors.put(contentType, processor); + fProcessors.put(contentType, cast(Object)processor); } /* @@ -1101,7 +1116,7 @@ StringBuffer buf= new StringBuffer(5); Iterator iter= fProcessors.entrySet().iterator(); while (iter.hasNext()) { - Entry entry= cast(Entry) iter.next(); + Map.Entry entry= cast(Map.Entry) iter.next(); IContentAssistProcessor processor= cast(IContentAssistProcessor) entry.getValue(); char[] triggers= processor.getCompletionProposalAutoActivationCharacters(); if (triggers !is null) @@ -1414,7 +1429,7 @@ int delay= fAutoActivationDelay; if (delay is 0) delay= DEFAULT_AUTO_ACTIVATION_DELAY; - delay= Math.round(delay * 1.5f); + delay= cast(int)Math.round(delay * 1.5f); controller= new AdditionalInfoController(fInformationControlCreator, delay); } @@ -2241,7 +2256,7 @@ */ public void addCompletionListener(ICompletionListener listener) { Assert.isLegal(listener !is null); - fCompletionListeners.add(listener); + fCompletionListeners.add(cast(Object)listener); } /* @@ -2249,7 +2264,7 @@ * @since 3.2 */ public void removeCompletionListener(ICompletionListener listener) { - fCompletionListeners.remove(listener); + fCompletionListeners.remove(cast(Object)listener); } /** @@ -2478,7 +2493,7 @@ protected final void registerHandler(String commandId, IHandler handler) { if (fHandlers is null) fHandlers= new HashMap(2); - fHandlers.put(commandId, handler); + fHandlers.put(commandId, cast(Object)handler); } /**