use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.
the class PropertyEditorPresenter method obtainExistingPropertiesForPath.
@Override
public void obtainExistingPropertiesForPath() {
final Project project = appContext.getRootProject();
checkState(project != null);
final Resource[] resources = appContext.getResources();
checkState(!Arrays.isNullOrEmpty(resources));
checkState(resources.length == 1);
service.propertyList(project.getLocation(), toRelative(project, resources[0])).then(new Operation<CLIOutputResponse>() {
@Override
public void apply(CLIOutputResponse response) throws OperationException {
List<String> properties = new ArrayList<String>();
for (String property : response.getOutput()) {
properties.add(property.trim());
}
view.setExistingPropertiesForPath(properties);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE));
}
});
}
use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.
the class ProjectConfigurationAction method updateInPerspective.
@Override
public void updateInPerspective(@NotNull ActionEvent event) {
final Resource[] resources = appContext.getResources();
if (resources != null && resources.length == 1) {
final Resource resource = resources[0];
if (resource.getResourceType() == PROJECT) {
event.getPresentation().setEnabledAndVisible(true);
event.getPresentation().setText("Update Project Configuration...");
} else {
event.getPresentation().setEnabledAndVisible(false);
}
}
}
use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.
the class RefreshPathAction method updateInPerspective.
@Override
public void updateInPerspective(@NotNull ActionEvent event) {
event.getPresentation().setText("Refresh");
event.getPresentation().setVisible(true);
final Resource[] resources = appContext.getResources();
if (resources == null || resources.length != 1) {
event.getPresentation().setEnabled(false);
return;
}
final Resource resource = resources[0];
if (resource instanceof Container) {
event.getPresentation().setText("Refresh '" + resource.getName() + "'");
} else {
final Container parent = resource.getParent();
if (parent != null) {
event.getPresentation().setText("Refresh '" + parent.getName() + "'");
} else {
event.getPresentation().setEnabled(false);
return;
}
}
event.getPresentation().setEnabled(true);
}
use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.
the class RenameItemAction method actionPerformed.
/** {@inheritDoc} */
@Override
public void actionPerformed(ActionEvent e) {
final Resource resource = appContext.getResource();
checkState(resource != null, "Null resource occurred");
final String resourceName = resource.getName();
final int selectionLength = resourceName.indexOf('.') >= 0 ? resourceName.lastIndexOf('.') : resourceName.length();
final InputValidator validator;
final String dialogTitle;
if (resource.getResourceType() == FILE) {
validator = new FileNameValidator(resourceName);
dialogTitle = localization.renameFileDialogTitle(resourceName);
} else if (resource.getResourceType() == FOLDER) {
validator = new FolderNameValidator(resourceName);
dialogTitle = localization.renameFolderDialogTitle(resourceName);
} else if (resource.getResourceType() == PROJECT) {
validator = new ProjectNameValidator(resourceName);
dialogTitle = localization.renameProjectDialogTitle(resourceName);
} else {
throw new IllegalStateException("Not a resource");
}
final InputCallback inputCallback = new InputCallback() {
@Override
public void accepted(final String value) {
//we shouldn't perform renaming file with the same name
if (!value.trim().equals(resourceName)) {
closeRelatedEditors(resource);
final Path destination = resource.getLocation().parent().append(value);
resource.move(destination).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
notificationManager.notify("", arg.getMessage(), FAIL, EMERGE_MODE);
}
});
}
}
};
InputDialog inputDialog = dialogFactory.createInputDialog(dialogTitle, localization.renameDialogNewNameLabel(), resource.getName(), 0, selectionLength, inputCallback, null);
inputDialog.withValidator(validator);
inputDialog.show();
}
use of org.eclipse.che.ide.api.resources.Resource in project che by eclipse.
the class DownloadResourceAction method actionPerformed.
/** {@inheritDoc} */
@Override
public void actionPerformed(ActionEvent e) {
final Resource resource = appContext.getResource();
checkState(resource != null, "Null resource occurred");
downloadContainer.setUrl(urlModifier.modify(resource.getURL()));
}
Aggregations