in eclipse/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/views/JcrPropertiesView.java [418:521]
private void makeActions() {
insertAction = new Action() {
public void run() {
NewRow newRow = new NewRow();
viewer.add(newRow);
viewer.getTable().setTopIndex(viewer.getTable().getItemCount());
viewer.getTable().select(viewer.getTable().getItemCount()-1);
viewer.editElement(newRow, 0);
}
};
insertAction.setText("Insert");
insertAction.setToolTipText("Insert a property");
insertAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
getImageDescriptor(ISharedImages.IMG_OBJ_ADD));
deleteAction = new Action() {
public void run() {
if (viewer.getSelection().isEmpty()) {
return;
}
ISelection sel = viewer.getSelection();
if (sel instanceof IStructuredSelection) {
IStructuredSelection iss = (IStructuredSelection)sel;
Object elem = iss.getFirstElement();
if (elem instanceof IPropertyDescriptor) {
IPropertyDescriptor pd = (IPropertyDescriptor)elem;
JcrNode jcrnode = (JcrNode)viewer.getInput();
jcrnode.deleteProperty(pd.getDisplayName());
refreshContent();
}
}
}
};
deleteAction.setText("Delete");
deleteAction.setToolTipText("Delete a proeprty");
deleteAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
doubleClickAction = new Action() {
public void run() {
//TODO doesn't do anything currently..
ISelection selection = viewer.getSelection();
// Object obj = ((IStructuredSelection)selection).getFirstElement();
// showMessage("Double-click detected on "+obj.toString());
}
};
showInEditorAction = new Action() {
public void run() {
JcrNode node = (JcrNode)viewer.getInput();
final IFile file = node.getFileForEditor();
if (file!=null) {
try {
IDE.openEditor(getPage(), file, true);
} catch (PartInitException e) {
e.printStackTrace(System.out);
}
}
}
};
showInEditorAction.setText("Show in editor");
showInEditorAction.setToolTipText("Show underlying vault file in editor");
showInEditorAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
getImageDescriptor(ISharedImages.IMG_OBJ_FILE));
if (getViewSite()!=null) {
pinAction = new Action("pin to selection", IAction.AS_CHECK_BOX) {
public void run() {
if (!pinAction.isChecked()) {
// unpin
setContentDescription("");
setInput(lastInput);
} else {
setContentDescription("[pinned]");
}
// toggle state of syncedAction accordingly
if (synchedAction!=null) {
synchedAction.setEnabled(!pinAction.isChecked());
}
}
};
pinAction.setText("Pin to selection");
pinAction.setToolTipText("Pin this property view to the current selection");
pinAction.setImageDescriptor(WorkbenchImages
.getImageDescriptor(IWorkbenchGraphicConstants.IMG_ETOOL_PIN_EDITOR));
pinAction.setDisabledImageDescriptor(WorkbenchImages
.getImageDescriptor(IWorkbenchGraphicConstants.IMG_ETOOL_PIN_EDITOR_DISABLED));
pinAction.setChecked(false);
synchedAction = new Action("Link with Editor and selection", IAction.AS_CHECK_BOX) {
public void run() {
// toggle state of pinAction accordingly
pinAction.setEnabled(!synchedAction.isChecked());
}
};
synchedAction.setText("Link with Editor and selection");
synchedAction.setToolTipText("Link with Editor and selection");
synchedAction.setImageDescriptor(WorkbenchImages
.getImageDescriptor(ISharedImages.IMG_ELCL_SYNCED));
synchedAction.setDisabledImageDescriptor(WorkbenchImages
.getImageDescriptor(ISharedImages.IMG_ELCL_SYNCED_DISABLED));
synchedAction.setChecked(true);
}
}