congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
CommandImpl$ApplicableContext
Code IndexAdd Tabnine to your IDE (free)

How to use
CommandImpl$ApplicableContext
in
org.eclipse.che.ide.api.command

Best Java code snippets using org.eclipse.che.ide.api.command.CommandImpl$ApplicableContext (Showing top 15 results out of 315)

origin: org.eclipse.che.core/che-core-ide-app

@Override
public Promise<CommandImpl> createCommand(String goalId, String typeId) {
 return createCommand(goalId, typeId, null, null, new HashMap<>(), new ApplicableContext());
}
origin: org.eclipse.che.core/che-core-ide-api

/** Creates copy of the given {@code context}. */
public ApplicableContext(ApplicableContext context) {
 this(context.isWorkspaceApplicable(), new HashSet<>(context.getApplicableProjects()));
}
origin: org.eclipse.che.core/che-core-ide-app

/** Returns the default {@link ApplicableContext} for the new command. */
private ApplicableContext getDefaultContext() {
 final ApplicableContext context = new ApplicableContext();
 if (appContext.getProjects().length > 0) {
  context.setWorkspaceApplicable(false);
  Arrays.stream(appContext.getProjects()).forEach(p -> context.addProject(p.getPath()));
 }
 return context;
}
origin: org.eclipse.che.core/che-core-ide-app

commands.put(
  workspaceCommand.getName(),
  new CommandImpl(workspaceCommand, new ApplicableContext())));
          new CommandImpl(
            projectCommand,
            new ApplicableContext(project.getPath())));
       } else {
        if (projectCommand.equalsIgnoreContext(existedCommand)) {
         existedCommand
           .getApplicableContext()
           .addProject(project.getPath());
        } else {
origin: org.eclipse.che.core/che-core-ide-app

if (!context.isWorkspaceApplicable() && context.getApplicableProjects().isEmpty()) {
 return promiseProvider.reject(
   new Exception("Command has to be applicable to the workspace or at least one project"));
if (context.isWorkspaceApplicable()) {
 Promise<CommandImpl> p =
   workspaceCommandManager
       (Function<Void, CommandImpl>)
         aVoid -> {
          newCommand.getApplicableContext().setWorkspaceApplicable(true);
          return newCommand;
         });
for (final String projectPath : context.getApplicableProjects()) {
 final Project project = getProjectByPath(projectPath);
       (Function<CommandImpl, CommandImpl>)
         arg -> {
          newCommand.getApplicableContext().addProject(projectPath);
          return newCommand;
         });
origin: org.eclipse.che.core/che-core-ide-app

/** Removes the command without notifying listeners. */
private Promise<Void> doRemoveCommand(String name) {
 final CommandImpl command = commands.get(name);
 if (command == null) {
  return promiseProvider.reject(new Exception("Command '" + name + "' does not exist."));
 }
 final ApplicableContext context = command.getApplicableContext();
 final ArrayOf<Promise<?>> commandPromises = Collections.arrayOf();
 if (context.isWorkspaceApplicable()) {
  commandPromises.push(workspaceCommandManager.removeCommand(name));
 }
 for (final String projectPath : context.getApplicableProjects()) {
  final Project project = getProjectByPath(projectPath);
  if (project == null) {
   continue;
  }
  commandPromises.push(projectCommandManager.removeCommand(project, name));
 }
 return promiseProvider
   .all2(commandPromises)
   .then(
     (Function<ArrayOf<?>, Void>)
       arg -> {
        commands.remove(command.getName());
        return null;
       });
}
origin: org.eclipse.che.core/che-core-ide-app

@Override
public void onApplicableProjectChanged(Project project, boolean applicable) {
 final ApplicableContext context = editedCommand.getApplicableContext();
 if (applicable) {
  // if command is bound with one project at least
  // then remove command from the workspace
  if (context.getApplicableProjects().isEmpty()) {
   context.setWorkspaceApplicable(false);
  }
  context.addProject(project.getPath());
 } else {
  context.removeProject(project.getPath());
  // if command isn't bound to any project
  // then save it to the workspace
  if (context.getApplicableProjects().isEmpty()) {
   context.setWorkspaceApplicable(true);
  }
 }
 notifyDirtyStateChanged();
}
origin: org.eclipse.che.core/che-core-ide-app

private Promise<CommandImpl> addCommand(Project project, CommandDto commandDto) {
 final String name = project.getName() + ": " + commandDto.getName();
 final String absoluteProjectPath =
   appContext.getProjectsRoot().append(project.getPath()).toString();
 final String commandLine =
   commandDto.getCommandLine().replaceAll(PROJECT_PATH_MACRO_REGEX, absoluteProjectPath);
 final CommandImpl command =
   new CommandImpl(
     name,
     commandLine,
     commandDto.getType(),
     commandDto.getAttributes(),
     new ApplicableContext(project.getPath()));
 return commandManager.createCommand(command);
}
origin: org.eclipse.che.core/che-core-ide-app

/** Checks whether the given command is applicable to the current project. */
private boolean isCommandApplicableToCurrentProject(CommandImpl command) {
 final Set<String> applicableProjects = command.getApplicableContext().getApplicableProjects();
 if (applicableProjects.isEmpty()) {
  return true;
 }
 final Resource currentResource = appContext.getResource();
 if (currentResource != null) {
  final Project currentProject = currentResource.getProject();
  if (currentProject != null) {
   return applicableProjects.contains(currentProject.getPath());
  }
 }
 return false;
}
origin: org.eclipse.che.core/che-core-ide-app

@Override
protected void initialize() {
 final ApplicableContext context = editedCommand.getApplicableContext();
 applicableProjectsInitial = new HashSet<>(context.getApplicableProjects());
 refreshProjects();
}
origin: org.eclipse.che.core/che-core-ide-api

/** Creates new {@link CommandImpl} based on the provided data. */
public CommandImpl(
  String name, String commandLine, String typeId, Map<String, String> attributes) {
 this.name = name;
 this.commandLine = commandLine;
 this.typeId = typeId;
 this.attributes = attributes;
 this.context = new ApplicableContext();
}
origin: org.eclipse.che.core/che-core-ide-app

@Override
public Promise<CommandImpl> createCommand(
  String goalId,
  String typeId,
  String name,
  String commandLine,
  Map<String, String> attributes) {
 return createCommand(goalId, typeId, name, commandLine, attributes, new ApplicableContext());
}
origin: org.eclipse.che.core/che-core-ide-api

/** Creates copy of the given {@code command}. */
public CommandImpl(CommandImpl command) {
 this(
   command.getName(),
   command.getCommandLine(),
   command.getType(),
   new HashMap<>(command.getAttributes()),
   new ApplicableContext(command.getApplicableContext()));
}
origin: org.eclipse.che.core/che-core-ide-app

@Override
public boolean isDirty() {
 if (editedCommand == null) {
  return false;
 }
 ApplicableContext context = editedCommand.getApplicableContext();
 return !(applicableProjectsInitial.equals(context.getApplicableProjects()));
}
origin: org.eclipse.che.core/che-core-ide-app

/** Refresh 'Projects' section in the view. */
private void refreshProjects() {
 final Map<Project, Boolean> projectsStates = new HashMap<>();
 for (Project project : appContext.getProjects()) {
  ApplicableContext context = editedCommand.getApplicableContext();
  boolean applicable = context.getApplicableProjects().contains(project.getPath());
  projectsStates.put(project, applicable);
 }
 view.setProjects(projectsStates);
}
org.eclipse.che.ide.api.commandCommandImpl$ApplicableContext

Javadoc

Defines the context in which command is applicable.

Most used methods

  • <init>
    Creates new ApplicableContext based on the provided data.
  • getApplicableProjects
    Returns immutable list of the paths of the applicable projects.
  • isWorkspaceApplicable
    Returns true if command is applicable to the workspace and false otherwise.
  • addProject
    Adds applicable project's path.
  • removeProject
    Removes applicable project's path.
  • setWorkspaceApplicable
    Sets whether the command should be applicable to the workspace or not.

Popular in Java

  • Reactive rest calls using spring rest template
  • setContentView (Activity)
  • putExtra (Intent)
  • getExternalFilesDir (Context)
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • Menu (java.awt)
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Collectors (java.util.stream)
  • JTextField (javax.swing)
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now