Java Reference
In-Depth Information
public class
SetHyperlinkAction
extends
PropertyChangeAction {
static public final
String ID = "setHyperlinkAction";
public
SetHyperlinkAction(IWorkbenchPage workbenchPage) {
super
(workbenchPage, PackageUtil.getID(
StylePackage.eINSTANCE.getCustomStyle_Hyperlink()),
"Set hyperlink...");
setId(ID);
setText("Set hyperlink...");
setToolTipText("Set a navigable hyperlink on this element");
}
@Override
protected void
doRun(IProgressMonitor progressMonitor) {
String value = (String)
getOperationSetPropertyValue(getPropertyId());
ChangePropertyValueRequest request =
(ChangePropertyValueRequest) getTargetRequest();
final
InputDialog inputDialog =
new
InputDialog(Display.getCurrent().getActiveShell(),
"Hyperlink", "Enter the URL:", value,
null
);
if
(InputDialog.OK == inputDialog.open()) {
request.setValue(inputDialog.getValue());
}
else
{
return
;
}
super
.doRun(progressMonitor);
}
@Override
protected
Object getNewPropertyValue() {
String value = (String)
getOperationSetPropertyValue(getPropertyId());
if
(value !=
null
) {
return
value;
}
return null
;
}
}
BEST PRACTICE
By extending the
PropertyChangeAction
class, we've violated an
Eclipse plug-in development best practice. The class is abstract and
extended by public classes within the runtime, but it is itself located in an
*.
internal
.* package namespace.The right thing to do would be extend
from its public superclass
DiagramAction
and reimplement the func-
tionality we need from
PropertyChangeAction
, or submit a bug to the
GMF project and ask that the class be made an API.
Search WWH ::
Custom Search