use of org.apache.sling.ide.transport.RepositoryException in project sling by apache.
the class JcrEditingSupport method doGetCellEditor.
protected CellEditor doGetCellEditor(Object element) {
if (!canEdit(element)) {
return null;
}
switch(columnId) {
case NAME:
{
// no validator needed - any string is OK
return new TextCellEditor(tableViewer.getTable());
}
case TYPE:
{
// using a dropdown editor
final ComboBoxCellEditor editor = new ComboBoxCellEditor(tableViewer.getTable(), PropertyTypeSupport.PROPERTY_TYPES, SWT.NONE);
editor.setActivationStyle(ComboBoxCellEditor.DROP_DOWN_ON_KEY_ACTIVATION | ComboBoxCellEditor.DROP_DOWN_ON_MOUSE_ACTIVATION | ComboBoxCellEditor.DROP_DOWN_ON_TRAVERSE_ACTIVATION);
return editor;
}
case VALUE:
{
final Field field = asField(element);
if (getNode().getProperty(field.getPropertyName()).isMultiple()) {
// then launch the MVPEditor instead of returning an editor here
return new MVNCellEditor(tableViewer.getTable(), getNode(), field.getPropertyName());
}
if (field.getPropertyType() == PropertyType.DATE) {
return new DateTimeCellEditor(tableViewer.getTable(), getNode(), field.getPropertyName());
}
if (field.getPropertyType() == PropertyType.BOOLEAN) {
return new ComboBoxCellEditor(tableViewer.getTable(), new String[] { "false", "true" }, SWT.READ_ONLY);
}
CellEditor editor;
if (field.getPropertyName().equals("jcr:primaryType")) {
editor = new TextCellEditor(tableViewer.getTable()) {
@Override
protected Control createControl(Composite parent) {
Text text = (Text) super.createControl(parent);
Repository repository = ServerUtil.getDefaultRepository(getNode().getProject());
NodeTypeRegistry ntManager = (repository == null) ? null : repository.getNodeTypeRegistry();
if (ntManager == null) {
return text;
}
try {
Collection<String> types = ntManager.getAllowedPrimaryChildNodeTypes(getNode().getParent().getPrimaryType());
SimpleContentProposalProvider proposalProvider = new SimpleContentProposalProvider(types.toArray(new String[0]));
proposalProvider.setFiltering(true);
ContentProposalAdapter adapter = new ContentProposalAdapter(text, new TextContentAdapter(), proposalProvider, null, null);
adapter.setPropagateKeys(true);
adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
return text;
} catch (RepositoryException e) {
return text;
}
}
};
} else {
editor = new TextCellEditor(tableViewer.getTable());
}
// value might require a validator depending on the property type
int propertyType = getNode().getPropertyType(field.getPropertyName());
switch(propertyType) {
case PropertyType.STRING:
case PropertyType.NAME:
{
//TODO: check jcr rules for name
break;
}
case PropertyType.DECIMAL:
{
editor.setValidator(new DecimalValidator(editor));
break;
}
default:
{
//TODO
break;
}
}
return editor;
}
case MULTIPLE:
{
if (element instanceof NewRow) {
return null;
}
return new ComboBoxCellEditor(tableViewer.getTable(), new String[] { "false", "true" }, SWT.READ_ONLY);
}
default:
{
throw new IllegalStateException("Unknown columnId: " + columnId);
}
}
}
use of org.apache.sling.ide.transport.RepositoryException in project sling by apache.
the class NewNodeDialog method validateInput.
protected void validateInput() {
final String firstInput = getText().getText();
final String secondInput = comboSelection;
try {
if (secondInput == null || secondInput.length() == 0) {
setErrorMessage("");
} else if (ntManager == null) {
setErrorMessage(null);
} else if (ntManager.isAllowedPrimaryChildNodeType(parentNodeType, secondInput)) {
// also check on the name, not only the type
if (allChildNodeDefs == null) {
setErrorMessage("No child node definitions found for " + parentNodeType);
} else {
boolean success = false;
for (int i = 0; i < allChildNodeDefs.length; i++) {
NodeDefinition aChildNodeDef = allChildNodeDefs[i];
if (aChildNodeDef.getName() != null && aChildNodeDef.getName().length() > 0) {
if (firstInput.equals(aChildNodeDef.getName())) {
setErrorMessage(null);
return;
}
} else {
// mark success if there's a child node definition without a name
// (ie then it can be any name)
success = true;
}
}
if (success) {
setErrorMessage(null);
return;
}
StringBuffer details = new StringBuffer();
for (NodeDefinition aChildNodeDef : allChildNodeDefs) {
if (details.length() != 0) {
details.append(", ");
}
details.append("(name=" + aChildNodeDef.getName() + ", required primary type(s)=");
String[] requiredPrimaryTypeNames = aChildNodeDef.getRequiredPrimaryTypeNames();
if (requiredPrimaryTypeNames == null) {
details.append("null");
} else {
for (int j = 0; j < requiredPrimaryTypeNames.length; j++) {
String rptn = requiredPrimaryTypeNames[j];
if (j > 0) {
details.append(",");
}
details.append(rptn);
}
}
details.append(")");
}
setErrorMessage("No matching child node definition found for " + parentNodeType + ". Expected one of: " + details);
}
} else {
setErrorMessage("Error: Invalid child node type of " + parentNodeType);
}
} catch (RepositoryException e) {
setErrorMessage("RepositoryException: " + e);
}
}
use of org.apache.sling.ide.transport.RepositoryException in project sling by apache.
the class ImportRepositoryContentAction method run.
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException, SerializationException, CoreException {
// TODO: We should try to make this give 'nice' progress feedback (aka here's what I'm processing)
monitor.beginTask("Repository import", IProgressMonitor.UNKNOWN);
this.monitor = monitor;
repository = ServerUtil.getConnectedRepository(server, monitor);
this.builder = serializationManager.newBuilder(repository, ProjectUtil.getSyncDirectoryFile(project));
SerializationKindManager skm;
try {
skm = new SerializationKindManager();
skm.init(repository);
} catch (RepositoryException e1) {
throw new InvocationTargetException(e1);
}
filter = ProjectUtil.loadFilter(project);
ProgressUtils.advance(monitor, 1);
try {
contentSyncRootDir = ProjectUtil.getSyncDirectory(project);
repositoryImportRoot = projectRelativePath.makeRelativeTo(contentSyncRootDir.getProjectRelativePath()).makeAbsolute();
contentSyncRoot = ProjectUtil.getSyncDirectoryFullPath(project).toFile();
readVltIgnoresNotUnderImportRoot(contentSyncRootDir, repositoryImportRoot);
ProgressUtils.advance(monitor, 1);
Activator.getDefault().getPluginLogger().trace("Starting import; repository start point is {0}, workspace start point is {1}", repositoryImportRoot, projectRelativePath);
recordNotIgnoredResources();
ProgressUtils.advance(monitor, 1);
crawlChildrenAndImport(repositoryImportRoot.toPortableString());
removeNotIgnoredAndNotUpdatedResources(new NullProgressMonitor());
ProgressUtils.advance(monitor, 1);
} catch (OperationCanceledException e) {
throw e;
} catch (Exception e) {
throw new InvocationTargetException(e);
} finally {
if (builder != null) {
builder.destroy();
builder = null;
}
monitor.done();
}
}
Aggregations