Java Code Examples for org.netbeans.modules.php.api.util.UiUtils

The following examples show how to use org.netbeans.modules.php.api.util.UiUtils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: netbeans   Source File: Atoum.java    License: Apache License 2.0 6 votes vote down vote up
@CheckForNull
public static Atoum getForPhpModule(PhpModule phpModule, boolean showCustomizer) {
    if (validatePhpModule(phpModule) != null) {
        if (showCustomizer) {
            UiUtils.invalidScriptProvided(phpModule, AtoumCustomizer.IDENTIFIER, null);
        }
        return null;
    }
    // atoum
    String path;
    if (AtoumPreferences.isAtoumEnabled(phpModule)) {
        // custom atoum
        path = AtoumPreferences.getAtoumPath(phpModule);
    } else {
        // default atoum
        String error = validateDefault();
        if (error != null) {
            if (showCustomizer) {
                UiUtils.invalidScriptProvided(error, AtoumOptionsPanelController.OPTIONS_SUB_PATH);
            }
            return null;
        }
        path = AtoumOptions.getInstance().getAtoumPath();
    }
    return new Atoum(path);
}
 
Example 2
Source Project: netbeans   Source File: FileRunner.java    License: Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages({
    "# {0} - project or file name",
    "FileRunner.debug.displayName=Debug ({0})",
})
public void debug() {
    RP.post(new Runnable() {
        @Override
        public void run() {
            PhpExecutable executable = getExecutable(Bundle.FileRunner_debug_displayName(getDisplayName()));
            try {
                executable.debug(FileUtil.toFileObject(file), getDescriptor(getPostExecution(executable)));
            } catch (ExecutionException ex) {
                UiUtils.processExecutionException(ex);
            }
        }
    });
}
 
Example 3
Source Project: netbeans   Source File: FileRunner.java    License: Apache License 2.0 6 votes vote down vote up
ExecutionDescriptor getDescriptor(Runnable postExecution) {
    ExecutionDescriptor descriptor = PhpExecutable.DEFAULT_EXECUTION_DESCRIPTOR
            .charset(Charset.forName(getEncoding()))
            .controllable(true)
            .optionsPath(UiUtils.OPTIONS_PATH)
            .outConvertorFactory(PHP_LINE_CONVERTOR_FACTORY);
    if (!getPhpOptions().isOpenResultInOutputWindow()) {
        descriptor = descriptor.inputOutput(InputOutput.NULL)
                .frontWindow(false)
                .frontWindowOnError(false);
    }
    if (postExecution != null) {
        descriptor = descriptor.postExecution(postExecution);
    }
    return descriptor;
}
 
Example 4
Source Project: netbeans   Source File: GoToTest.java    License: Apache License 2.0 6 votes vote down vote up
private LocationResult findOpposite0(FileObject fo) {
    PhpProject project = PhpProjectUtils.getPhpProject(fo);
    if (project == null) {
        // XXX what to do now??
        LOGGER.log(Level.INFO, "PHP project was not found for file {0}", fo);
        return null;
    }
    if (PhpProjectValidator.isFatallyBroken(project)) {
        UiUtils.warnBrokenProject(project.getPhpModule());
        return null;
    }

    if (CommandUtils.isUnderTests(project, fo, false)) {
        return findSource(project, fo);
    } else if (CommandUtils.isUnderSources(project, fo)) {
        return findTest(project, fo);
    }
    return null;
}
 
Example 5
Source Project: netbeans   Source File: PhpUnit.java    License: Apache License 2.0 6 votes vote down vote up
@CheckForNull
public static PhpUnit getForPhpModule(PhpModule phpModule, boolean showCustomizer) {
    if (validatePhpModule(phpModule) != null) {
        if (showCustomizer) {
            UiUtils.invalidScriptProvided(phpModule, PhpUnitCustomizer.IDENTIFIER, null);
        }
        return null;
    }
    // phpunit
    String path;
    if (PhpUnitPreferences.isPhpUnitEnabled(phpModule)) {
        // custom phpunit
        path = PhpUnitPreferences.getPhpUnitPath(phpModule);
    } else {
        // default phpunit
        String error = validateDefault();
        if (error != null) {
            if (showCustomizer) {
                UiUtils.invalidScriptProvided(error, PhpUnitOptionsPanelController.OPTIONS_SUB_PATH);
            }
            return null;
        }
        path = PhpUnitOptions.getInstance().getPhpUnitPath();
    }
    return new PhpUnit(path);
}
 
Example 6
Source Project: netbeans   Source File: PhpUnit.java    License: Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages({
    "# {0} - project name",
    "PhpUnit.run.title=PHPUnit ({0})",
})
@CheckForNull
private PhpExecutable getExecutable(PhpModule phpModule) {
    FileObject sourceDirectory = phpModule.getSourceDirectory();
    if (sourceDirectory == null) {
        org.netbeans.modules.php.phpunit.ui.UiUtils.warnNoSources(phpModule.getDisplayName());
        return null;
    }

    return new PhpExecutable(phpUnitPath)
            .optionsSubcategory(PhpUnitOptionsPanelController.OPTIONS_SUB_PATH)
            .displayName(Bundle.PhpUnit_run_title(phpModule.getDisplayName()));
}
 
Example 7
@Override
public void actionPerformed(ActionEvent e) {
    if (phpModule.isBroken()) {
        // broken project
        UiUtils.warnBrokenProject(phpModule);
        return;
    }
    RP.post(new Runnable() {
        @Override
        public void run() {
            LifecycleManager.getDefault().saveAll();
            if (remember) {
                // remember curent provider
                docProvider.notifyEnabled(phpModule, true);
            }
            docProvider.generateDocumentation(phpModule);
        }

    });
}
 
Example 8
Source Project: netbeans   Source File: Doctrine2CommandSupport.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected List<FrameworkCommand> getFrameworkCommandsInternal() {
    Doctrine2Script doctrine2;
    try {
        doctrine2 = Doctrine2Script.getDefault();
    } catch (InvalidPhpExecutableException ex) {
        UiUtils.invalidScriptProvided(ex.getLocalizedMessage(), Doctrine2OptionsPanelController.OPTIONS_SUBPATH);
        return null;
    }

    List<Doctrine2CommandVO> commandsVO = doctrine2.getCommands(phpModule);
    if (commandsVO == null) {
        // some error
        return null;
    }
    List<FrameworkCommand> commands = new ArrayList<>(commandsVO.size());
    for (Doctrine2CommandVO command : commandsVO) {
        commands.add(new Doctrine2Command(command.getCommand(), command.getDescription(), command.getHelp()));
    }
    return commands;
}
 
Example 9
Source Project: netbeans   Source File: PhpExecutable.java    License: Apache License 2.0 6 votes vote down vote up
@CheckForNull
private Future<Integer> runInternal(ExecutionDescriptor executionDescriptor, ExecutionDescriptor.InputProcessorFactory2 outProcessorFactory, boolean debug) {
    Parameters.notNull("executionDescriptor", executionDescriptor); // NOI18N
    String error;
    if (validationHandler == null) {
        error = PhpExecutableValidator.validateCommand(executable, executableName);
    } else {
        error = PhpExecutableValidator.validateCommand(executable, validationHandler);
    }
    if (error != null) {
        if (warnUser) {
            // optionsSubcategory should be taken from executionDescriptor (unfortunately not possible)
            UiUtils.invalidScriptProvided(error, optionsSubcategory);
        }
        return null;
    }
    ProcessBuilder processBuilder = getProcessBuilder(debug);
    if (processBuilder == null) {
        return null;
    }
    executionDescriptor = getExecutionDescriptor(executionDescriptor, outProcessorFactory);
    return ExecutionService.newService(processBuilder, executionDescriptor, getDisplayName()).run();
}
 
Example 10
Source Project: netbeans   Source File: TestCreator.java    License: Apache License 2.0 6 votes vote down vote up
public CreateTestsResult createTests(List<FileObject> files, Map<String, Object> configurationPanelProperties) {
    final Set<FileObject> failed = new HashSet<>();
    final Set<FileObject> succeeded = new HashSet<>();
    Pair<GenerateCommand, String> commandSuite = Pair.of((GenerateCommand) configurationPanelProperties.get(GENERATE_COMMAND_PARAM),
            (String) configurationPanelProperties.get(SUITE_PARAM));
    if (commandSuite.first() != null
            && commandSuite.second() != null) {
        try {
            Codecept codeception = Codecept.getForPhpModule(phpModule, true);
            if (codeception != null) {
                for (FileObject fo : files) {
                    generateTest(codeception, phpModule, fo, commandSuite, failed, succeeded);
                }
            }
        } catch (ExecutionException ex) {
            LOGGER.log(Level.INFO, null, ex);
            UiUtils.processExecutionException(ex, CodeceptionOptionsPanelController.OPTIONS_SUB_PATH);
        }
    }
    return new CreateTestsResult(succeeded, failed);
}
 
Example 11
Source Project: netbeans   Source File: PhpDocOptionsPanel.java    License: Apache License 2.0 5 votes vote down vote up
private void searchButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_searchButtonActionPerformed
    String phpDoc = UiUtils.SearchWindow.search(new UiUtils.SearchWindow.SearchWindowSupport() {
        @Override
        public List<String> detect() {
            return FileUtils.findFileOnUsersPath(PhpDocScript.SCRIPT_NAME, PhpDocScript.SCRIPT_NAME_LONG);
        }

        @Override
        public String getWindowTitle() {
            return NbBundle.getMessage(PhpDocOptionsPanel.class, "LBL_PhpDocsTitle");
        }

        @Override
        public String getListTitle() {
            return NbBundle.getMessage(PhpDocOptionsPanel.class, "LBL_PhpDocs");
        }

        @Override
        public String getPleaseWaitPart() {
            return NbBundle.getMessage(PhpDocOptionsPanel.class, "LBL_PhpDocsPleaseWaitPart");
        }

        @Override
        public String getNoItemsFound() {
            return NbBundle.getMessage(PhpDocOptionsPanel.class, "LBL_NoPhpDocsFound");
        }
    });
    if (phpDoc != null) {
        phpDocTextField.setText(phpDoc);
    }
}
 
Example 12
Source Project: netbeans   Source File: PhpDocumentorProvider.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void generateDocumentation(PhpModule phpModule) {
    try {
        PhpDocScript.getDefault().generateDocumentation(phpModule);
    } catch (InvalidPhpExecutableException ex) {
        UiUtils.invalidScriptProvided(ex.getLocalizedMessage(), PhpDocScript.OPTIONS_SUB_PATH);
    }
}
 
Example 13
Source Project: netbeans   Source File: InstallerExecutable.java    License: Apache License 2.0 5 votes vote down vote up
@CheckForNull
public static InstallerExecutable getDefault(@NullAllowed PhpModule phpModule, boolean showOptions) {
    ValidationResult result = new SymfonyOptionsValidator()
            .validate()
            .getResult();
    if (validateResult(result) != null) {
        if (showOptions) {
            UiUtils.showOptions(SymfonyOptionsPanelController.OPTIONS_SUBPATH);
        }
        return null;
    }
    return new InstallerExecutable(SymfonyOptions.getInstance().getInstaller(), phpModule);
}
 
Example 14
Source Project: netbeans   Source File: AtoumOptionsPanel.java    License: Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages({
    "AtoumOptionsPanel.atoum.search.title=atoum files",
    "AtoumOptionsPanel.atoum.search.files=&atoum files:",
    "AtoumOptionsPanel.atoum.search.pleaseWaitPart=atoum files",
    "AtoumOptionsPanel.atoum.search.notFound=No atoum files found."
})
private void searchAtoumButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_searchAtoumButtonActionPerformed
    String atoum = UiUtils.SearchWindow.search(new UiUtils.SearchWindow.SearchWindowSupport() {
        @Override
        public List<String> detect() {
            return FileUtils.findFileOnUsersPath(Atoum.PHAR_FILE_NAME, Atoum.ATOUM_FILE_NAME);
        }
        @Override
        public String getWindowTitle() {
            return Bundle.AtoumOptionsPanel_atoum_search_title();
        }
        @Override
        public String getListTitle() {
            return Bundle.AtoumOptionsPanel_atoum_search_files();
        }
        @Override
        public String getPleaseWaitPart() {
            return Bundle.AtoumOptionsPanel_atoum_search_pleaseWaitPart();
        }
        @Override
        public String getNoItemsFound() {
            return Bundle.AtoumOptionsPanel_atoum_search_notFound();
        }
    });
    if (atoum != null) {
        atoumPathTextField.setText(atoum);
    }
    // TODO add your handling code here:
}
 
Example 15
Source Project: netbeans   Source File: InternalWebServer.java    License: Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages({
    "# {0} - project name",
    "InternalWebServer.output.title=Internal WebServer ({0})"
})
private Future<Integer> createProcess() {
    // validate
    PhpInterpreter phpInterpreter;
    try {
        phpInterpreter = PhpInterpreter.getDefault();
    } catch (InvalidPhpExecutableException ex) {
        UiUtils.invalidScriptProvided(ex.getLocalizedMessage());
        return null;
    }
    RunConfigInternal runConfig = RunConfigInternal.forProject(project);
    if (RunConfigInternalValidator.validateCustomizer(runConfig) != null) {
        PhpProjectUtils.openCustomizerRun(project);
        return null;
    }
    // run
    return new PhpExecutable(phpInterpreter.getInterpreter())
            .viaAutodetection(false)
            .viaPhpInterpreter(false)
            .workDir(runConfig.getWorkDir())
            .additionalParameters(getParameters(runConfig))
            .displayName(Bundle.InternalWebServer_output_title(project.getName()))
            .run(getDescriptor());
}
 
Example 16
Source Project: netbeans   Source File: InternalWebServer.java    License: Apache License 2.0 5 votes vote down vote up
private ExecutionDescriptor getDescriptor() {
    return PhpExecutable.DEFAULT_EXECUTION_DESCRIPTOR
            .showSuspended(true)
            .optionsPath(UiUtils.OPTIONS_PATH + "/" + UiUtils.GENERAL_OPTIONS_SUBCATEGORY) // NOI18N
            .outConvertorFactory(FileRunner.PHP_LINE_CONVERTOR_FACTORY)
            .preExecution(new Runnable() {
                @Override
                public void run() {
                    // needs to be called even from the output window (rerun button)
                    startingInstance(InternalWebServer.this);
                }
            });
}
 
Example 17
Source Project: netbeans   Source File: CustomizerProviderImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void showCustomizer(final String preselectedCategory, String preselectedSubCategory) {
    if (PhpProjectValidator.isFatallyBroken(project)) {
        // metadata corrupted
        UiUtils.warnBrokenProject(project.getPhpModule());
        return;
    }
    Mutex.EVENT.readAccess(new Runnable() {
        @Override
        public void run() {
            Dialog dialog = PROJECT_2_DIALOG.get(project);
            if (dialog != null) {
                dialog.setVisible(true);
                return;
            }
            IncludePathSupport includePathSupport = new IncludePathSupport(ProjectPropertiesSupport.getPropertyEvaluator(project),
                    project.getRefHelper(), project.getHelper());
            IgnorePathSupport ignorePathSupport = new IgnorePathSupport(ProjectPropertiesSupport.getPropertyEvaluator(project),
                    project.getRefHelper(), project.getHelper());
            TestDirectoriesPathSupport testDirectoriesPathSupport = new TestDirectoriesPathSupport(ProjectPropertiesSupport.getPropertyEvaluator(project),
                    project.getRefHelper(), project.getHelper());
            SeleniumTestDirectoriesPathSupport seleniumTestDirectoriesPathSupport = new SeleniumTestDirectoriesPathSupport(ProjectPropertiesSupport.getPropertyEvaluator(project),
                    project.getRefHelper(), project.getHelper());
            PhpProjectProperties uiProperties = new PhpProjectProperties(project, includePathSupport, ignorePathSupport, testDirectoriesPathSupport, seleniumTestDirectoriesPathSupport);
            Lookup context = Lookups.fixed(project, uiProperties);

            OptionListener optionListener = new OptionListener(project);
            StoreListener storeListener = new StoreListener(uiProperties);
            dialog = ProjectCustomizer.createCustomizerDialog(CUSTOMIZER_FOLDER_PATH, context, preselectedCategory,
                    optionListener, storeListener, null);
            dialog.addWindowListener(optionListener);
            dialog.setTitle(MessageFormat.format(
                    NbBundle.getMessage(CustomizerProviderImpl.class, "LBL_Customizer_Title"),
                    ProjectUtils.getInformation(project).getDisplayName()));

            PROJECT_2_DIALOG.put(project, dialog);
            dialog.setVisible(true);
        }
    });
}
 
Example 18
Source Project: netbeans   Source File: CompositePanelProviderImpl.java    License: Apache License 2.0 5 votes vote down vote up
@ProjectCustomizer.CompositeCategoryProvider.Registration(
    projectType = UiUtils.CUSTOMIZER_PATH,
    position = 100
)
public static CompositePanelProviderImpl createSources() {
    return new CompositePanelProviderImpl(SOURCES);
}
 
Example 19
Source Project: netbeans   Source File: CompositePanelProviderImpl.java    License: Apache License 2.0 5 votes vote down vote up
@ProjectCustomizer.CompositeCategoryProvider.Registration(
    projectType = UiUtils.CUSTOMIZER_PATH,
    position = 150
)
public static CompositePanelProviderImpl createRunConfig() {
    return new CompositePanelProviderImpl(RUN);
}
 
Example 20
Source Project: netbeans   Source File: CompositePanelProviderImpl.java    License: Apache License 2.0 5 votes vote down vote up
@ProjectCustomizer.CompositeCategoryProvider.Registration(
    projectType = UiUtils.CUSTOMIZER_PATH,
    position = 180
)
public static CompositePanelProviderImpl createBrowser() {
    return new CompositePanelProviderImpl(BROWSER);
}
 
Example 21
Source Project: netbeans   Source File: CompositePanelProviderImpl.java    License: Apache License 2.0 5 votes vote down vote up
@ProjectCustomizer.CompositeCategoryProvider.Registration(
    projectType = UiUtils.CUSTOMIZER_PATH,
    position = 195
)
public static ProjectCustomizer.CompositeCategoryProvider createCssPreprocessors() {
    return CssPreprocessorsUI.getDefault().createCustomizer();
}
 
Example 22
Source Project: netbeans   Source File: CompositePanelProviderImpl.java    License: Apache License 2.0 5 votes vote down vote up
@ProjectCustomizer.CompositeCategoryProvider.Registration(
    projectType = UiUtils.CUSTOMIZER_PATH,
    position = 200
)
public static CompositePanelProviderImpl createPhpIncludePath() {
    return new CompositePanelProviderImpl(PHP_INCLUDE_PATH);
}
 
Example 23
Source Project: netbeans   Source File: CompositePanelProviderImpl.java    License: Apache License 2.0 5 votes vote down vote up
@ProjectCustomizer.CompositeCategoryProvider.Registration(
    projectType = UiUtils.CUSTOMIZER_PATH,
    position = 250
)
public static CompositePanelProviderImpl createIgnorePath() {
    return new CompositePanelProviderImpl(IGNORE_PATH);
}
 
Example 24
Source Project: netbeans   Source File: CompositePanelProviderImpl.java    License: Apache License 2.0 5 votes vote down vote up
@ProjectCustomizer.CompositeCategoryProvider.Registration(
    projectType = UiUtils.CUSTOMIZER_PATH,
    position = 300
)
public static CompositePanelProviderImpl createFrameworks() {
    return new CompositePanelProviderImpl(FRAMEWORKS);
}
 
Example 25
Source Project: netbeans   Source File: CompositePanelProviderImpl.java    License: Apache License 2.0 5 votes vote down vote up
@ProjectCustomizer.CompositeCategoryProvider.Registration(
    projectType = UiUtils.CUSTOMIZER_PATH,
    position = 350
)
public static CompositePanelProviderImpl createTesting() {
    return new CompositePanelProviderImpl(TESTING);
}
 
Example 26
Source Project: netbeans   Source File: CompositePanelProviderImpl.java    License: Apache License 2.0 5 votes vote down vote up
@ProjectCustomizer.CompositeCategoryProvider.Registration(
        projectType = UiUtils.CUSTOMIZER_PATH,
    position = 352
)
public static CompositePanelProviderImpl createSeleniumTesting() {
    return new CompositePanelProviderImpl(TESTING_SELENIUM);
}
 
Example 27
Source Project: netbeans   Source File: CompositePanelProviderImpl.java    License: Apache License 2.0 5 votes vote down vote up
@ProjectCustomizer.CompositeCategoryProvider.Registration(
    projectType = UiUtils.CUSTOMIZER_PATH,
    position = 900
)
public static CompositePanelProviderImpl createLicense() {
    return new CompositePanelProviderImpl(LICENSE);
}
 
Example 28
Source Project: netbeans   Source File: CompositePanelProviderImpl.java    License: Apache License 2.0 5 votes vote down vote up
@ProjectCustomizer.CompositeCategoryProvider.Registration(
    projectType = UiUtils.CUSTOMIZER_PATH,
    position = 1000
)
public static ProjectCustomizer.CompositeCategoryProvider createFormatting() {
    return Customizers.createFormattingCategoryProvider(Collections.singletonMap(
            "allowedMimeTypes", FileUtils.PHP_MIME_TYPE + ",text/html,text/css,text/javascript,text/x-json")); // NOI18N
}
 
Example 29
Source Project: netbeans   Source File: PhpOptionsPanel.java    License: Apache License 2.0 5 votes vote down vote up
private void phpInterpreterSearchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_phpInterpreterSearchButtonActionPerformed
    String phpInterpreter = UiUtils.SearchWindow.search(new UiUtils.SearchWindow.SearchWindowSupport() {
        @Override
        public List<String> detect() {
            return PhpEnvironment.get().getAllPhpInterpreters();
        }

        @Override
        public String getWindowTitle() {
            return NbBundle.getMessage(PhpOptionsPanel.class, "LBL_PhpInterpretersTitle");
        }

        @Override
        public String getListTitle() {
            return NbBundle.getMessage(PhpOptionsPanel.class, "LBL_PhpInterpreters");
        }

        @Override
        public String getPleaseWaitPart() {
            return NbBundle.getMessage(PhpOptionsPanel.class, "LBL_PhpInterpretersPleaseWaitPart");
        }

        @Override
        public String getNoItemsFound() {
            return NbBundle.getMessage(PhpOptionsPanel.class, "LBL_NoPhpInterpretersFound");
        }
    });
    if (phpInterpreter != null) {
        phpInterpreterTextField.setText(phpInterpreter);
    }
}
 
Example 30
Source Project: netbeans   Source File: RunFileActionProvider.java    License: Apache License 2.0 5 votes vote down vote up
private FileRunner createFileRunner(File file, RunFileArgs args) {
    PhpInterpreter phpInterpreter;
    try {
        phpInterpreter = PhpInterpreter.getDefault();
    } catch (InvalidPhpExecutableException ex) {
        UiUtils.invalidScriptProvided(ex.getLocalizedMessage());
        return null;
    }
    return new FileRunner(file)
            .command(phpInterpreter.getInterpreter())
            .workDir(args.getWorkDir())
            .phpArgs(args.getPhpOpts())
            .fileArgs(args.getRunArgs());
}