Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.1.0)

E17493-02

oracle.ide.externaltools.macro
Class MacroExpander

java.lang.Object
  extended by oracle.ide.externaltools.macro.MacroExpander
All Implemented Interfaces:
Displayable
Direct Known Subclasses:
ParameterizedMacro

public abstract class MacroExpander
extends java.lang.Object
implements Displayable

Macro expanders are registered with the MacroRegistry and can be used to expand macros prior to running external tools.

This interface extends Displayable. The getShortLabel() method is used when this macro is displayed to users in the external tools UI. When a longer description of the macro is displayed to users, the getLongLabel() method is used.

The getMacro() method should be used to return a short string that will be recognized in input strings as belonging to this macro expander. For example, if the getMacro() method returns "mymacro", then the sequence "${mymacro}" will be recognized in input strings as belonging to this expander. Note that the string should not contain the macro escape characters "${...}".

Implement the expand( Context ) method to actually expand an IDE context into a String. Whenever possible, this should happen automatically, however it's acceptable to display UI (e.g. a prompt) while expanding a macro - macro expansion occurs just prior to running external tools. Note: as of 11.1.2.0.0 Macros now must be registered in the extension.xml file in a trigger hook section where most of the information will be defined (short/long label, macro, tooltip, isDirectoryMacro) The methods to get this information are now effectively no-ops in this class as they will be handled by LazyMacroExpander which will wrap this class and resolve these from the registered data. Thus the following methods must be implemented but can essentially do nothing as they will be provided by the wrapper class LazyMacroExpander which will resolve them based on declarative data: - getShortLabel() - getLongLabel() - getIcon() - getToolTipText() - isAvailableForType() - isDirectoryMacro() - getMacro()


Constructor Summary
MacroExpander()
           
 
Method Summary
abstract  java.lang.String expand(Context context)
          Expand the specified context into a String.
 javax.swing.Icon getIcon()
          Get the icon for this macro.
 java.lang.String getLongLabel()
          Returns a long label that can be displayed to the user.
 java.lang.String getMacro()
          Get the macro string recognized by this expander.
 java.lang.String getSampleExpansion(Context context)
          Get a sample expansion of this macro.
 java.lang.String getShortLabel()
          Returns a short label that can be displayed to the user.
 java.lang.String getToolTipText()
          Get the tool tip text for this macro.
 boolean isAvailableForType(ExternalToolType type)
          Deprecated. since 11.1.2.0.0 use isAvailableForType that takes id instead
 boolean isAvailableForType(java.lang.String typeId)
          Should this macro be made available for external tools of the specified type?
 boolean isDirectoryMacro()
          Does this macro expand to a directory? Some of the external tools UI provides a restricted list of macros where only directory values can be used.
 java.lang.String toMacroString()
          Gets the text of this macro exactly as it appears in an unexpanded string.
 java.lang.String toString()
          Get a string representation of this macro.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MacroExpander

public MacroExpander()
Method Detail

getIcon

public javax.swing.Icon getIcon()
Get the icon for this macro. This implementation returns null.

Specified by:
getIcon in interface Displayable
Returns:
the icon for this macr.

getToolTipText

public java.lang.String getToolTipText()
Get the tool tip text for this macro. This implementation returns null.

Specified by:
getToolTipText in interface Displayable
Returns:
the tooltip text for this macro.

toString

public java.lang.String toString()
Get a string representation of this macro. This implementation returns getShortLabel().

Specified by:
toString in interface Displayable
Overrides:
toString in class java.lang.Object
Returns:
a string representation of this macro.
See Also:
Object.toString(), Displayable.getShortLabel()

getMacro

public java.lang.String getMacro()
Get the macro string recognized by this expander.

Returns:
a string. On macro expansion, if an escaped string matching the specified string exists, this macro expander will be used to do the expansion.

getShortLabel

public java.lang.String getShortLabel()
Description copied from interface: Displayable
Returns a short label that can be displayed to the user. Generally, the value of the returned String is considered translatable and should therefore be placed in an appropriate resource file. When possible, the returned label should be reasonably short enough to show in the navigator or explorer windows but long enough to clearly identify and distinguish the Displayable.

Specified by:
getShortLabel in interface Displayable
Returns:
a short descriptive label of the Displayable that can be shown to the user.

getLongLabel

public java.lang.String getLongLabel()
Description copied from interface: Displayable
Returns a long label that can be displayed to the user. Generally, the value of the returned String is considered translatable and should therefore be placed in an appropriate resource file. The long label differs from the short label essentially on length. Usually the long label will only be shown on-demand and in places where horizontal space is more available. Examples are the status bar and tooltips.

Specified by:
getLongLabel in interface Displayable
Returns:
a long descriptive label of the Displayable that can be shown to the user.

toMacroString

public java.lang.String toMacroString()
Gets the text of this macro exactly as it appears in an unexpanded string. This includes macro escape characters ( ${}).

This implementation returns "${" + getMacro() + "}"

Returns:
the text of this macro exactly as it appears in an unexpanded string.

isDirectoryMacro

public boolean isDirectoryMacro()
Does this macro expand to a directory? Some of the external tools UI provides a restricted list of macros where only directory values can be used. If this macro may represent a directory, it should return true from this method.

This implementation returns false.

Returns:
true if the expansion of this macro may result in a String containining the path of a directory.

getSampleExpansion

public java.lang.String getSampleExpansion(Context context)
Get a sample expansion of this macro. This is used by the external tools UI when displaying example command lines.

The simplest implementation of this method just returns the same result as expand( Context ).

Because these commmand lines are displayed while the external tools UI is on screen, and are not necessarily related to actually running an external tool, you should avoid displaying UI in this method.

In addition, because this is an example string, you may choose to ignore the specified context and just provide a string that resembles the expansion of this macro.

This implementation just calls expand( Context ). You should override this if expand() displays UI or takes a long time. Note: the implementation for this method will only be called if the extension that registered the implementation is already loaded. Otherwise the LazyMacroExpander will return null rather than calling the true implementation.

Parameters:
context - an IDE context
Returns:
a String representing an example evaluation of this macro.

expand

public abstract java.lang.String expand(Context context)
Expand the specified context into a String.

Parameters:
context - an IDE context
Returns:
a String (which may be empty) representing the evaluation of this macro on the specified context.

isAvailableForType

public boolean isAvailableForType(ExternalToolType type)
Deprecated. since 11.1.2.0.0 use isAvailableForType that takes id instead

Should this macro be made available for external tools of the specified type?

This implementation returns true.

Returns:
true if the macro is available, false otherwise.

isAvailableForType

public boolean isAvailableForType(java.lang.String typeId)
Should this macro be made available for external tools of the specified type?

This implementation returns true.

Returns:
true if the macro is available, false otherwise.

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.1.0)

E17493-02

Copyright © 1997, 2011, Oracle. All rights reserved.