Example usage for org.eclipse.jdt.core IJavaProject getProject

List of usage examples for org.eclipse.jdt.core IJavaProject getProject

Introduction

In this page you can find the example usage for org.eclipse.jdt.core IJavaProject getProject.

Prototype

IProject getProject();

Source Link

Document

Returns the IProject on which this IJavaProject was created.

Usage

From source file:com.google.gwt.eclipse.core.launch.processors.DevModeCodeServerPortArgumentProcessor.java

License:Open Source License

@Override
public void update(ILaunchConfigurationWorkingCopy launchConfig, IJavaProject javaProject,
        List<String> programArgs, List<String> vmArgs) throws CoreException {
    // Only GWT projects will use -codeServerPort
    if (!GWTNature.isGWTProject(javaProject.getProject())) {
        return;//from   ww w.  jav  a 2s .com
    }

    int index = getArgIndex(programArgs);

    // Only run with the DevMode entrypoint and not the CodeServer entrypoint
    if (GwtLaunchConfigurationProcessorUtilities.isSuperDevModeCodeServer(launchConfig)) {
        // Just in case the argument pre-existed, remove it
        if (index > -1) {
            programArgs.remove(index); // remove arg name
            programArgs.remove(index); // remove port value
        }
        return;
    }

    String port = GWTLaunchConfigurationWorkingCopy.getClassicDevModeCodeServerPort(launchConfig);
    boolean auto = GWTLaunchConfigurationWorkingCopy.getClassicDevModeCodeServerPortAuto(launchConfig);

    if (auto || !validatePort(port)) {
        port = "auto";
    }

    if (index < 0) {
        programArgs.add(0, CODE_SERVER_PORT_ARG);
        programArgs.add(1, port);
    } else {
        if (index == programArgs.size() - 1) {
            programArgs.add(port);
        } else {
            String argValue = programArgs.get(index + 1);
            if (validatePort(argValue)) {
                programArgs.set(index + 1, port);
            } else {
                programArgs.add(index + 1, port);
            }
        }
    }
}

From source file:com.google.gwt.eclipse.core.launch.processors.DGwtDevJarArgumentProcessor.java

License:Open Source License

/**
 * Returns the path to the gwt-dev-xxx.jar in the event that the launch configuration depends on a
 * GWT Contributor Runtime. Otherwise, returns the empty string.
 *//* w  w  w  . j a v  a2 s  . c  om*/
private static String maybeGetDevJarPath(IJavaProject project) {

    /*
     * In order to figure out whether or not to add the -Dgwt.devjar argument to the list of VM
     * args, we have to figure out the runtime that this launch configuration depends on. If the
     * project is one of the GWT Runtime projects, then we'll definitely have to add the
     * -Dgwt.devjar argument to the launch configuration.
     */
    try {
        if (GWTProjectsRuntime.isGWTRuntimeProject(project)) {
            // Synthesize a temporary contributor SDK so that we can use it
            // to compute the devjar path
            GWTRuntime tempContribSDK = GWTProjectsRuntime.syntheziseContributorRuntime();

            if (tempContribSDK.validate().isOK()) {
                return tempContribSDK.getDevJar().getAbsolutePath();
            } else {
                return "";
            }
        }

        GWTRuntime sdk = GWTRuntime.findSdkFor(project);
        if (sdk == null) {
            MessageConsole messageConsole = MessageConsoleUtilities
                    .getMessageConsole(project.getProject().getName() + "-GWT", null);
            messageConsole.activate();
            ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { messageConsole });
            final ConsoleColorProvider consoleColorProvider = new ConsoleColorProvider();
            final MessageConsoleStream console = messageConsole.newMessageStream();
            Display.getDefault().asyncExec(new Runnable() {
                @Override
                public void run() {
                    console.setColor(consoleColorProvider.getColor(IDebugUIConstants.ID_STANDARD_ERROR_STREAM));
                }
            });
            console.println("GWT SDK not installed.");
            try {
                console.close();
            } catch (IOException e) {
                GWTPluginLog.logError(e, "Unable to close output stream to console");
            }
            return "";
        } else if (sdk.usesGwtDevProject()) {
            File gwtDevJarFile = sdk.getDevJar();
            return gwtDevJarFile.getAbsolutePath();
        }
    } catch (SdkException sdke) {
        GWTPluginLog.logError(sdke, "Unable to extract gwt dev jar argument from GWTProjectsRuntime");
    } catch (JavaModelException jme) {
        GWTPluginLog.logError(jme, "Unable to extract gwt dev jar argument from GWTProjectsRuntime");
    }
    return "";
}

From source file:com.google.gwt.eclipse.core.launch.processors.DGwtDevJarArgumentProcessor.java

License:Open Source License

@Override
public void update(ILaunchConfigurationWorkingCopy launchConfig, IJavaProject javaProject,
        List<String> programArgs, List<String> vmArgs) throws CoreException {

    int devJarIndex = StringUtilities.indexOfThatStartsWith(vmArgs, ARG_DGWT_DEVJAR, 0);

    int insertionIndex = LaunchConfigurationProcessorUtilities.removeArgsAndReturnInsertionIndex(vmArgs,
            devJarIndex, false);//  w  w w. j  av  a  2s  .co  m

    if (GWTNature.isGWTProject(javaProject.getProject())) {
        String devJarPath = maybeGetDevJarPath(javaProject);
        if (!StringUtilities.isEmpty(devJarPath)) {
            vmArgs.add(insertionIndex, ARG_DGWT_DEVJAR + devJarPath);
        }
    }
}

From source file:com.google.gwt.eclipse.core.launch.processors.LogLevelArgumentProcessor.java

License:Open Source License

@Override
public void update(ILaunchConfigurationWorkingCopy config, IJavaProject javaProject, List<String> programArgs,
        List<String> vmArgs) throws CoreException {

    //    if (!isApplicable(config) && !GwtLaunchConfigurationProcessorUtilities.isSuperDevModeCodeServer(config)) {
    //      return;
    //    }//from w ww .  j av a 2 s .  co  m

    int insertionIndex = LaunchConfigurationProcessorUtilities.removeArgsAndReturnInsertionIndex(programArgs,
            getArgIndex(programArgs), true);

    String persistedLogLevel = GWTLaunchConfiguration.getLogLevel(config);

    if (GWTNature.isGWTProject(javaProject.getProject()) && !StringUtilities.isEmpty(persistedLogLevel)) {
        programArgs.add(insertionIndex, ARG_LOG_LEVEL);
        programArgs.add(insertionIndex + 1, persistedLogLevel);
    } else {
        // TODO remove?
    }
}

From source file:com.google.gwt.eclipse.core.launch.processors.LogLevelArgumentProcessor.java

License:Open Source License

@Override
public String validate(ILaunchConfiguration launchConfig, IJavaProject javaProject, List<String> programArgs,
        List<String> vmArgs) throws CoreException {

    if (!isApplicable(launchConfig)) {
        return null;
    }/*  ww  w. j  a  v a 2 s .  c o m*/

    int logLevelArgIndex = getArgIndex(programArgs);
    if (logLevelArgIndex == -1) {
        return null;
    }

    if (!GWTNature.isGWTProject(javaProject.getProject())) {
        return "Log level argument is only valid for GWT projects";
    }

    String logLevel = LaunchConfigurationProcessorUtilities.getArgValue(programArgs, logLevelArgIndex + 1);
    if (StringUtilities.isEmpty(logLevel)) {
        return "Argument for specifying a log level is missing or invalid";
    }

    return null;
}

From source file:com.google.gwt.eclipse.core.launch.processors.ModuleArgumentProcessor.java

License:Open Source License

@Override
public void update(ILaunchConfigurationWorkingCopy launchConfig, IJavaProject javaProject,
        List<String> programArgs, List<String> vmArgs) throws CoreException {
    IProject project = javaProject.getProject();
    List<String> persistedModules = GWTLaunchConfiguration.getEntryPointModules(launchConfig);

    if (persistedModules.isEmpty()) {
        persistedModules = getDefaultModules(project, launchConfig);
    }/* www  .  j  a va2s . co m*/

    Set<String> possibleModules = getAllPossibleModules(launchConfig, project);
    ModuleParser parser = ModuleParser.parse(programArgs, possibleModules);

    if (!GWTNature.isGWTProject(project) || !doesGwtMainTypeTakeModuleArguments(launchConfig)) {
        removeModules(programArgs, parser, null);

    } else {
        // Remove modules that should not be present
        removeModules(programArgs, parser, persistedModules);

        // Add modules that are not present
        for (String module : persistedModules) {
            if (!parser.modules.contains(module)) {
                programArgs.add(module);
            }
        }
    }
}

From source file:com.google.gwt.eclipse.core.launch.processors.NoServerArgumentProcessor.java

License:Open Source License

@Override
public void update(ILaunchConfigurationWorkingCopy launchConfig, IJavaProject javaProject,
        List<String> programArgs, List<String> vmArgs) throws CoreException {
    IProject project = javaProject.getProject();
    int noServerArgIndex = programArgs.indexOf(ARG_NO_SERVER);

    int insertionIndex = LaunchConfigurationProcessorUtilities.removeArgsAndReturnInsertionIndex(programArgs,
            noServerArgIndex, false);//from w  w  w .j a  v  a  2s . co  m
    if (!WebAppLaunchConfiguration.getRunServer(launchConfig) && GWTNature.isGWTProject(project)) {
        programArgs.add(insertionIndex, ARG_NO_SERVER);
    }
}

From source file:com.google.gwt.eclipse.core.launch.processors.RemoteUiArgumentProcessor.java

License:Open Source License

@Override
public void update(ILaunchConfigurationWorkingCopy launchConfig, IJavaProject javaProject,
        List<String> programArgs, List<String> vmArgs) throws CoreException {
    // GWT arg processor only
    if (!GWTNature.isGWTProject(javaProject.getProject())) {
        return;//  www  .  j  a  v  a2s  .c o  m
    }

    int index = programArgs.indexOf(ARG_REMOTE_UI);

    // Prefer the existing value, fallback on the precanned one
    String remoteUiValue = null;
    if (index >= 0) {
        remoteUiValue = LaunchConfigurationProcessorUtilities.getArgValue(programArgs, index + 1);
    }

    if (StringUtilities.isEmpty(remoteUiValue)) {
        remoteUiValue = "${gwt_remote_ui_server_port}:${unique_id}";
    }

    int insertionIndex = LaunchConfigurationProcessorUtilities.removeArgsAndReturnInsertionIndex(programArgs,
            index, true);

    IProject project = javaProject.getProject();
    if (GWTNature.isGWTProject(project) && shouldUseRemoteUI(launchConfig)) {
        programArgs.add(insertionIndex, ARG_REMOTE_UI);
        programArgs.add(insertionIndex + 1, remoteUiValue);
    }
}

From source file:com.google.gwt.eclipse.core.launch.processors.StartupUrlArgumentProcessor.java

License:Open Source License

@Override
public void update(ILaunchConfigurationWorkingCopy launchConfig, IJavaProject javaProject,
        List<String> programArgs, List<String> vmArgs) throws CoreException {

    String persistedStartupUrl = GWTLaunchConfiguration.getStartupUrl(launchConfig);

    StartupUrlParser parser = StartupUrlParser.parse(programArgs, persistedStartupUrl, launchConfig);

    if (!GWTNature.isGWTProject(javaProject.getProject())) {
        removeStartupUrlForGwtShell(programArgs, parser);
        removeStartupUrlsWithStartupUrlArg(programArgs, parser, false);

    } else {/*from  www .j  a  va2 s.c o  m*/
        removeStartupUrlForGwtShell(programArgs, parser);
        int insertionIndex = removeStartupUrlsWithStartupUrlArg(programArgs, parser, true);
        if (!StringUtilities.isEmpty(persistedStartupUrl)) {
            programArgs.add(insertionIndex, ARG_STARTUP_URL);
            programArgs.add(insertionIndex + 1, persistedStartupUrl);
        }
    }
}

From source file:com.google.gwt.eclipse.core.launch.processors.SuperDevModeArgumentProcessor.java

License:Open Source License

@Override
public void update(ILaunchConfigurationWorkingCopy launchConfig, IJavaProject javaProject,
        List<String> programArgs, List<String> vmArgs) throws CoreException {
    // GWT arg processor only
    if (!GWTNature.isGWTProject(javaProject.getProject())) {
        return;//from   ww w .j av  a 2 s.  c  o  m
    }

    String gwtVersion = GwtVersionUtil.getProjectGwtVersion(javaProject);
    boolean superDevModeEnabled = GWTLaunchConfigurationWorkingCopy.getSuperDevModeEnabled(launchConfig);
    int indexEnabled = programArgs.indexOf(SUPERDEVMODE_ENABLED_ARG); // -superDevMode index
    int indexDisabled = programArgs.indexOf(SUPERDEVMODE_DISABLED_ARG); // -nosuperDevMode index

    // Update according to GWT version
    if (GwtVersionUtil.isGwtVersionlessThan25(javaProject)) {
        updateLessThanGwt25(programArgs, indexDisabled, indexEnabled);

    } else if (GWTLaunchConstants.SUPERDEVMODE_LAUNCH_LEGACY_VERSIONS.contains(gwtVersion)) {
        updateGwt25toLessThan27(programArgs, indexDisabled, indexEnabled, superDevModeEnabled);

    } else {
        updateGwt27On(javaProject, programArgs, indexDisabled, indexEnabled, superDevModeEnabled);
    }
}