Mercurial > projects > dwt-addons
changeset 148:b3dec671d1f7
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 24 Aug 2008 22:40:25 +0200 |
parents | 000f9136b8f7 |
children | b411f1c62131 |
files | dwtx/jface/text/AbstractHoverInformationControlManager.d dwtx/jface/text/templates/TemplateVariableResolver.d dwtx/jface/text/templates/TextTemplateMessages.d dwtx/jface/text/templates/persistence/TemplatePersistenceMessages.d dwtx/jface/text/templates/persistence/TemplateReaderWriter.d dwtx/jface/text/templates/persistence/TemplateStore.d |
diffstat | 6 files changed, 84 insertions(+), 83 deletions(-) [+] |
line wrap: on
line diff
--- a/dwtx/jface/text/AbstractHoverInformationControlManager.d Sun Aug 24 22:35:05 2008 +0200 +++ b/dwtx/jface/text/AbstractHoverInformationControlManager.d Sun Aug 24 22:40:25 2008 +0200 @@ -210,14 +210,14 @@ * @since 2.0 */ abstract public class AbstractHoverInformationControlManager : AbstractInformationControlManager { - + /** * The information control closer for the hover information. Closes the information control as * soon as the mouse pointer leaves the subject area (unless "move into hover" is enabled), * a mouse button is pressed, the user presses a key, or the subject control is resized, moved, or loses focus. */ class Closer : IInformationControlCloser, MouseListener, MouseMoveListener, ControlListener, KeyListener, SelectionListener, Listener { - + /** The closer's subject control */ private Control fSubjectControl; /** The subject area */ @@ -277,17 +277,17 @@ if (hBar !is null) hBar.addSelectionListener(this); } - + fDisplay= fSubjectControl.getDisplay(); if (!fDisplay.isDisposed()) { fDisplay.addFilter(DWT.Activate, this); fDisplay.addFilter(DWT.MouseWheel, this); - + fDisplay.addFilter(DWT.FocusOut, this); - + fDisplay.addFilter(DWT.MouseDown, this); fDisplay.addFilter(DWT.MouseUp, this); - + fDisplay.addFilter(DWT.MouseMove, this); fDisplay.addFilter(DWT.MouseEnter, this); fDisplay.addFilter(DWT.MouseExit, this); @@ -304,7 +304,7 @@ fIsActive= false; - if cast(DEBUG) + if (DEBUG) System.out_.println("AbstractHoverInformationControlManager.Closer stopped"); //$NON-NLS-1$ if (fSubjectControl !is null && !fSubjectControl.isDisposed()) { @@ -326,12 +326,12 @@ if (fDisplay !is null && !fDisplay.isDisposed()) { fDisplay.removeFilter(DWT.Activate, this); fDisplay.removeFilter(DWT.MouseWheel, this); - + fDisplay.removeFilter(DWT.FocusOut, this); - + fDisplay.removeFilter(DWT.MouseDown, this); fDisplay.removeFilter(DWT.MouseUp, this); - + fDisplay.removeFilter(DWT.MouseMove, this); fDisplay.removeFilter(DWT.MouseEnter, this); fDisplay.removeFilter(DWT.MouseExit, this); @@ -408,13 +408,13 @@ public void widgetSelected(SelectionEvent e) { hideInformationControl(); } - + /* * @see dwt.events.SelectionListener#widgetDefaultSelected(dwt.events.SelectionEvent) */ public void widgetDefaultSelected(SelectionEvent e) { } - + /* * @see dwt.widgets.Listener#handleEvent(dwt.widgets.Event) * @since 3.1 @@ -440,7 +440,7 @@ } } break; - + case DWT.MouseUp: case DWT.MouseDown: if (!hasInformationControlReplacer()) @@ -466,7 +466,7 @@ } }); } - + // XXX: workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=212392 : control.getShell().getDisplay().asyncExec(new class() Runnable { public void run() { @@ -488,7 +488,7 @@ if (iControl !is null && ! iControl.isFocusControl()) hideInformationControl(); break; - + case DWT.MouseMove: case DWT.MouseEnter: case DWT.MouseExit: @@ -499,24 +499,24 @@ /** * Handle mouse movement events. - * + * * @param event the event * @since 3.4 */ private void handleMouseMove(Event event) { -// if cast(DEBUG) +// if (DEBUG) // System.out_.println("AbstractHoverInformationControl.Closer.handleMouseMove():" + event); //$NON-NLS-1$ - + if (!(event.widget instanceof Control)) return; Control eventControl= cast(Control) event.widget; - + //transform coordinates to subject control: Point mouseLoc= event.display.map(eventControl, fSubjectControl, event.x, event.y); - + if (fSubjectArea.contains(mouseLoc)) return; - + IInformationControl iControl= getCurrentInformationControl(); if (!hasInformationControlReplacer() || !canMoveIntoInformationControl(iControl)) { if (this.outer instanceof AnnotationBarHoverManager) { @@ -526,7 +526,7 @@ hideInformationControl(); return; } - + IInformationControlExtension3 iControl3= cast(IInformationControlExtension3) iControl; Rectangle controlBounds= iControl3.getBounds(); if (controlBounds !is null) { @@ -639,11 +639,11 @@ public void mouseHover(MouseEvent event) { if (fIsComputing || fIsInRestartMode || (fSubjectControl !is null && !fSubjectControl.isDisposed() && fSubjectControl.getShell() !is fSubjectControl.getShell().getDisplay().getActiveShell())) { - if cast(DEBUG) + if (DEBUG) System.out_.println("AbstractHoverInformationControlManager...mouseHover: @ " + event.x + "/" + event.y + " : hover cancelled: fIsComputing= " + fIsComputing + ", fIsInRestartMode= " + fIsInRestartMode); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ return; } - + fIsInRestartMode= true; fIsComputing= true; fMouseLostWhileComputing= false; @@ -673,7 +673,7 @@ protected void deactivate() { if (fIsComputing) return; - + fIsInRestartMode= false; if (fSubjectControl !is null && !fSubjectControl.isDisposed()) { fSubjectControl.removeMouseMoveListener(this); @@ -779,24 +779,24 @@ /** * The thread that delays replacing of the hover information control. * To be accessed in the UI thread only! - * + * * @since 3.4 */ private Job fReplacingDelayJob; - + /** * The {@link ITextViewerExtension8.EnrichMode}, may be <code>null</code>. * @since 3.4 */ private EnrichMode fEnrichMode; - + /** * Indicates whether we have received a MouseDown event and are waiting for a MouseUp * (and don't replace the information control until that happened). * @since 3.4 */ private bool fWaitForMouseUp= false; - + /** * Creates a new hover information control manager using the given information control creator. * By default a <code>Closer</code> instance is set as this manager's closer. @@ -812,21 +812,21 @@ /** * Tests whether a given mouse location is within the keep-up zone. * The hover should not be hidden as long as the mouse stays inside this zone. - * + * * @param x the x coordinate, relative to the <em>subject control</em> * @param y the y coordinate, relative to the <em>subject control</em> * @param subjectControl the subject control * @param subjectArea the area for which the presented information is valid * @param blowUp If <code>true</code>, then calculate for the closer, i.e. blow up the keepUp area. * If <code>false</code>, then use tight bounds for hover detection. - * + * * @return <code>true</code> iff the mouse event occurred in the keep-up zone * @since 3.4 */ private bool inKeepUpZone(int x, int y, Control subjectControl, Rectangle subjectArea, bool blowUp) { if (subjectArea.contains(x, y)) return true; - + IInformationControl iControl= getCurrentInformationControl(); if (( cast(IInformationControlExtension5)iControl && !(cast(IInformationControlExtension5) iControl).isVisible())) { iControl= null; @@ -839,7 +839,7 @@ } if ( cast(IInformationControlExtension3)iControl ) { IInformationControlExtension3 iControl3= cast(IInformationControlExtension3) iControl; - + Rectangle iControlBounds= subjectControl.getDisplay().map(null, subjectControl, iControl3.getBounds()); Rectangle totalBounds= Geometry.copy(iControlBounds); if (blowUp && isReplaceInProgress()) { @@ -848,11 +848,11 @@ int margin= getInformationControlReplacer().getKeepUpMargin(); Geometry.expand(totalBounds, margin, margin, margin, margin); } - + if (!blowUp) { if (iControlBounds.contains(x, y)) return true; - + if (subjectArea.y + subjectArea.height < iControlBounds.y) { // special case for hover events: subjectArea totally above iControl: // +-----------+ @@ -871,7 +871,7 @@ // FIXME: cases when subjectArea extends to left or right of iControl? } return false; - + } else if (iControlBounds.x + iControlBounds.width < subjectArea.x) { // special case for hover events (e.g. in overview ruler): iControl totally left of subjectArea // +--------------------+-----------+ @@ -887,7 +887,7 @@ } } return false; - + } else if (subjectArea.x + subjectArea.width < iControlBounds.x) { // special case for hover events (e.g. in annotation ruler): subjectArea totally left of iControl // +-----------+--------------------+ @@ -905,7 +905,7 @@ return false; } } - + // FIXME: should maybe use convex hull, not bounding box totalBounds.add(subjectArea); if (totalBounds.contains(x, y)) @@ -913,11 +913,11 @@ } return false; } - + /** * Tests whether the given information control allows the mouse to be moved * into it. - * + * * @param iControl information control or <code>null</code> if none * @return <code>true</code> if information control allows mouse move into * control, <code>false</code> otherwise @@ -925,7 +925,7 @@ bool canMoveIntoInformationControl(IInformationControl iControl) { return fEnrichMode !is null && canReplace(iControl); } - + /* * @see dwtx.jface.text.AbstractInformationControlManager#hideInformationControl() */ @@ -938,7 +938,7 @@ * Sets the hover enrich mode. Only applicable when an information * control replacer has been set with * {@link #setInformationControlReplacer(InformationControlReplacer)} . - * + * * @param mode the enrich mode * @since 3.4 * @see ITextViewerExtension8#setHoverEnrichMode(dwtx.jface.text.ITextViewerExtension8.EnrichMode) @@ -946,7 +946,7 @@ void setHoverEnrichMode(EnrichMode mode) { fEnrichMode= mode; } - + /* * @see dwtx.jface.text.AbstractInformationControlManager#replaceInformationControl(bool) */ @@ -954,7 +954,7 @@ fWaitForMouseUp= false; super.replaceInformationControl(takeFocus); } - + /** * Cancels the replacing delay job. * @return <code>true</code> iff canceling was successful, <code>false</code> if replacing has already started @@ -964,28 +964,28 @@ if (fReplacingDelayJob !is null && fReplacingDelayJob.getState() !is Job.RUNNING) { bool cancelled= fReplacingDelayJob.cancel(); fReplacingDelayJob= null; -// if cast(DEBUG) +// if (DEBUG) // System.out_.println("AbstractHoverInformationControlManager.cancelReplacingDelay(): cancelled=" + cancelled); //$NON-NLS-1$ return cancelled; } -// if cast(DEBUG) +// if (DEBUG) // System.out_.println("AbstractHoverInformationControlManager.cancelReplacingDelay(): not delayed"); //$NON-NLS-1$ return true; } - + /** * Starts replacing the information control, considering the current * {@link ITextViewerExtension8.EnrichMode}. * If set to {@link ITextViewerExtension8.EnrichMode#AFTER_DELAY}, this * method cancels previous requests and restarts the delay timer. - * + * * @param display the display to be used for the call to * {@link #replaceInformationControl(bool)} in the UI thread */ private void startReplaceInformationControl(final Display display) { if (fEnrichMode is EnrichMode.ON_CLICK) return; - + if (fReplacingDelayJob !is null) { if (fReplacingDelayJob.getState() !is Job.RUNNING) { if (fReplacingDelayJob.cancel()) { @@ -994,7 +994,7 @@ if (! fWaitForMouseUp) replaceInformationControl(false); } else { -// if cast(DEBUG) +// if (DEBUG) // System.out_.println("AbstractHoverInformationControlManager.startReplaceInformationControl(): rescheduled"); //$NON-NLS-1$ fReplacingDelayJob.schedule(HOVER_AUTO_REPLACING_DELAY); } @@ -1002,7 +1002,7 @@ } return; } - + fReplacingDelayJob= new Job("AbstractHoverInformationControlManager Replace Delayer") { //$NON-NLS-1$ public IStatus run(final IProgressMonitor monitor) { if (monitor.isCanceled() || display.isDisposed()) { @@ -1022,7 +1022,7 @@ }; fReplacingDelayJob.setSystem(true); fReplacingDelayJob.setPriority(Job.INTERACTIVE); -// if cast(DEBUG) +// if (DEBUG) // System.out_.println("AbstractHoverInformationControlManager.startReplaceInformationControl(): scheduled"); //$NON-NLS-1$ fReplacingDelayJob.schedule(HOVER_AUTO_REPLACING_DELAY); } @@ -1107,12 +1107,12 @@ protected int getHoverEventStateMask() { return fHoverEventStateMask; } - + /** * Returns an adapter that gives access to internal methods. * <p> * <strong>Note:</strong> This method is not intended to be referenced or overridden by clients.</p> - * + * * @return the replaceable information control accessor * @since 3.4 * @noreference This method is not intended to be referenced by clients.
--- a/dwtx/jface/text/templates/TemplateVariableResolver.d Sun Aug 24 22:35:05 2008 +0200 +++ b/dwtx/jface/text/templates/TemplateVariableResolver.d Sun Aug 24 22:40:25 2008 +0200 @@ -122,7 +122,7 @@ String binding= resolve(context); if (binding is null) return new String[0]; - return new String[] { binding }; + return [ binding ]; } /**
--- a/dwtx/jface/text/templates/TextTemplateMessages.d Sun Aug 24 22:35:05 2008 +0200 +++ b/dwtx/jface/text/templates/TextTemplateMessages.d Sun Aug 24 22:40:25 2008 +0200 @@ -44,8 +44,13 @@ */ class TextTemplateMessages { - private static const String RESOURCE_BUNDLE= TextTemplateMessages.class.getName(); - private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE); +// private static const String RESOURCE_BUNDLE= TextTemplateMessages.class.getName(); + private static ResourceBundle fgResourceBundle;//= ResourceBundle.getBundle(RESOURCE_BUNDLE); + + static this() { + fgResourceBundle = ResourceBundle.getBundle( + getImportData!("dwtx.jface.text.templates.TextTemplateMessages.properties")); + } private this() { } @@ -54,16 +59,11 @@ try { return fgResourceBundle.getString(key); } catch (MissingResourceException e) { - return '!' + key + '!'; + return '!' ~ key ~ '!'; } } - public static String getFormattedString(String key, Object arg) { - return MessageFormat.format(getString(key), new Object[] { arg }); - } - - - public static String getFormattedString(String key, Object[] args) { + public static String getFormattedString(String key, Object[] args... ) { return MessageFormat.format(getString(key), args); } }
--- a/dwtx/jface/text/templates/persistence/TemplatePersistenceMessages.d Sun Aug 24 22:35:05 2008 +0200 +++ b/dwtx/jface/text/templates/persistence/TemplatePersistenceMessages.d Sun Aug 24 22:40:25 2008 +0200 @@ -29,8 +29,13 @@ */ class TemplatePersistenceMessages { - private static const String RESOURCE_BUNDLE= TemplatePersistenceMessages.class.getName(); - private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE); +// private static const String RESOURCE_BUNDLE= TemplatePersistenceMessages.class.getName(); + private static ResourceBundle fgResourceBundle;//= ResourceBundle.getBundle(RESOURCE_BUNDLE); + + static this() { + fgResourceBundle = ResourceBundle.getBundle( + getImportData!("dwtx.jface.text.templates.persistence.TemplatePersistenceMessages.properties")); + } private this() { } @@ -39,15 +44,11 @@ try { return fgResourceBundle.getString(key); } catch (MissingResourceException e) { - return '!' + key + '!'; + return '!' ~ key ~ '!'; } } - public static String getFormattedString(String key, Object arg) { - return MessageFormat.format(getString(key), new Object[] { arg }); - } - - public static String getFormattedString(String key, Object[] args) { + public static String getFormattedString(String key, Object[] args...) { return MessageFormat.format(getString(key), args); } }
--- a/dwtx/jface/text/templates/persistence/TemplateReaderWriter.d Sun Aug 24 22:35:05 2008 +0200 +++ b/dwtx/jface/text/templates/persistence/TemplateReaderWriter.d Sun Aug 24 22:40:25 2008 +0200 @@ -330,7 +330,7 @@ } catch (ParserConfigurationException e) { Assert.isTrue(false); } catch (TransformerException e) { - if (e.getException() instanceof IOException) + if (cast(IOException)e.getException() ) throw cast(IOException) e.getException(); Assert.isTrue(false); }
--- a/dwtx/jface/text/templates/persistence/TemplateStore.d Sun Aug 24 22:35:05 2008 +0200 +++ b/dwtx/jface/text/templates/persistence/TemplateStore.d Sun Aug 24 22:40:25 2008 +0200 @@ -61,13 +61,13 @@ /** * Set to <code>true</code> if property change events should be ignored (e.g. during writing * to the preference store). - * + * * @since 3.2 */ private bool fIgnorePreferenceStoreChanges= false; /** * The property listener, if any is registered, <code>null</code> otherwise. - * + * * @since 3.2 */ private IPropertyChangeListener fPropertyListener; @@ -115,13 +115,13 @@ loadContributedTemplates(); loadCustomTemplates(); } - + /** * Starts listening for property changes on the preference store. If the configured preference * key changes, the template store is {@link #load() reloaded}. Call * {@link #stopListeningForPreferenceChanges()} to remove any listener and stop the * auto-updating behavior. - * + * * @since 3.2 */ public final void startListeningForPreferenceChanges() { @@ -143,13 +143,13 @@ }; fPreferenceStore.addPropertyChangeListener(fPropertyListener); } - + } - + /** * Stops the auto-updating behavior started by calling * {@link #startListeningForPreferenceChanges()}. - * + * * @since 3.2 */ public final void stopListeningForPreferenceChanges() { @@ -158,11 +158,11 @@ fPropertyListener= null; } } - + /** * Handles an {@link IOException} thrown during reloading the preferences due to a preference * store update. The default is to write to stderr. - * + * * @param x the exception * @since 3.2 */ @@ -263,7 +263,7 @@ * * @param data the template to remove */ - public void delete(TemplatePersistenceData data) { + public void delete_(TemplatePersistenceData data) { if (data.isUserAdded()) fTemplates.remove(data); else