@Override public void actionPerformed(ActionEvent e) { final Resource resource = appContext.getResource(); checkState(resource instanceof Container, "Parent should be a container"); final Optional<Project> project = resource.getRelatedProject(); checkState(project.isPresent()); classpathService .getClasspath(project.get().getLocation().toString()) .then( new Operation<List<ClasspathEntryDto>>() { @Override public void apply(List<ClasspathEntryDto> arg) throws OperationException { classpathResolver.resolveClasspathEntries(arg); classpathResolver.getSources().add(resource.getLocation().toString()); classpathResolver.updateClasspath(); } }) .catchError( new Operation<PromiseError>() { @Override public void apply(PromiseError arg) throws OperationException { notificationManager.notify( "Can't get classpath", arg.getMessage(), FAIL, EMERGE_MODE); } }); }
/** Show copy dialog. */ public void showCopy() { final Project project = appContext.getRootProject(); Preconditions.checkState(project != null && SvnUtil.isUnderSvn(project)); final Resource[] resources = appContext.getResources(); Preconditions.checkState(resources != null && resources.length == 1); sourceNode = resources[0]; if (sourceNode.getResourceType() == Resource.FILE) { view.setDialogTitle(constants.copyViewTitleFile()); } else { view.setDialogTitle(constants.copyViewTitleDirectory()); } view.setNewName(sourceNode.getName()); view.setComment(sourceNode.getName()); view.setSourcePath(sourceNode.getLocation().toString(), false); validate(); view.show(); view.setProjectNode(project); }
/** {@inheritDoc} */ @Override public void onSourceCheckBoxChanged() { // url path chosen if (view.isSourceCheckBoxSelected()) { view.setSourcePath("", true); view.setNewName("name"); } else { view.setSourcePath(sourceNode.getLocation().toString(), false); view.setNewName(sourceNode.getName()); } validate(); }
/** * Shows dialog which contains information about file fqn and path calculated from passed element. * * @param resource element for which fqn and path will be calculated */ public void show(Resource resource) { final Optional<Project> project = resource.getRelatedProject(); if (project.isPresent()) { final FqnProvider provider = providers.get(project.get().getType()); try { view.show(provider.getFqn(resource), resource.getLocation()); } catch (RuntimeException e) { view.show("", resource.getLocation()); } } }
private void loadBuildConfig() { final Resource resource = appContext.getResource(); if (resource == null) { return; } final Optional<Project> project = resource.getRelatedProject(); if (project.isPresent()) { String namespace = project.get().getAttribute(OPENSHIFT_NAMESPACE_VARIABLE_NAME); String application = project.get().getAttribute(OPENSHIFT_APPLICATION_VARIABLE_NAME); service.getBuildConfigs(namespace, application).then(showBuildConfigs()).catchError(onFail()); } }
@Override public void updateInPerspective(ActionEvent e) { final Resource[] resources = appContext.getResources(); if (resources == null || resources.length != 1) { e.getPresentation().setEnabledAndVisible(false); return; } Resource resource = resources[0]; final boolean inJavaProject = isJavaProject(resource.getRelatedProject().get()); e.getPresentation() .setEnabledAndVisible( inJavaProject && resource.isFolder() && !resource.getMarker(SourceFolderMarker.ID).isPresent()); }