ui: Added Java Path detector for Mac

This commit is contained in:
Eberhard Graether
2016-08-26 13:27:34 +02:00
parent f719212678
commit 55ae17af29
6 changed files with 76 additions and 7 deletions
+5 -3
View File
@@ -164,7 +164,7 @@ add_files(
qt/QtApplication.h
qt/QtCoreApplication.cpp
qt/QtCoreApplication.h
utility/path_detector/cxx_header/CxxFrameworkPathDetector.cpp
utility/path_detector/cxx_header/CxxFrameworkPathDetector.h
utility/path_detector/cxx_header/CxxHeaderPathDetector.cpp
@@ -173,12 +173,14 @@ add_files(
utility/path_detector/cxx_header/CxxVsHeaderPathDetector.h
utility/path_detector/cxx_header/utilityCxxHeaderDetection.cpp
utility/path_detector/cxx_header/utilityCxxHeaderDetection.h
utility/path_detector/java_runtime/JavaPathDetector.cpp
utility/path_detector/java_runtime/JavaPathDetector.h
utility/path_detector/java_runtime/JavaPathDetectorMac.cpp
utility/path_detector/java_runtime/JavaPathDetectorMac.h
utility/path_detector/java_runtime/JavaPathDetectorWindows.cpp
utility/path_detector/java_runtime/JavaPathDetectorWindows.h
utility/path_detector/CombinedPathDetector.cpp
utility/path_detector/CombinedPathDetector.h
utility/path_detector/PathDetector.cpp
@@ -164,6 +164,7 @@ void QtProjectWizzardContentPaths::addDetection(QGridLayout* layout, int row)
connect(button, SIGNAL(clicked()), this, SLOT(detectionClicked()));
QHBoxLayout* hlayout = new QHBoxLayout();
hlayout->setContentsMargins(0, 0, 0, 0);
hlayout->addWidget(label);
hlayout->addWidget(m_detectorBox);
hlayout->addWidget(button);
@@ -3,6 +3,7 @@
#include "settings/ApplicationSettings.h"
#include "utility/file/FileSystem.h"
#include "utility/messaging/type/MessageSwitchColorScheme.h"
#include "utility/path_detector/java_runtime/JavaPathDetectorMac.h"
#include "utility/path_detector/java_runtime/JavaPathDetectorWindows.h"
#include "utility/ResourcePaths.h"
@@ -157,7 +158,15 @@ void QtProjectWizzardContentPreferences::populateForm(QGridLayout* layout, int&
// java path
m_javaPath = new QtLocationPicker(this);
m_javaPath->setPickDirectory(true);
m_javaPath->setPlaceholderText("<jre_8_root>/bin/client");
if (QSysInfo::windowsVersion() != QSysInfo::WV_None)
{
m_javaPath->setPlaceholderText("<jre_8_root>/bin/client");
}
else if (QSysInfo::macVersion() != QSysInfo::MV_None)
{
m_javaPath->setPlaceholderText("<jre_8_root>/Contents/Home");
}
layout->addWidget(createFormLabel("Java Path"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_javaPath, row, QtProjectWizzardWindow::BACK_COL);
@@ -173,7 +182,12 @@ void QtProjectWizzardContentPreferences::populateForm(QGridLayout* layout, int&
m_javaPathDetector = std::make_shared<CombinedPathDetector>();
m_javaPathDetector->addDetector(std::make_shared<JavaPathDetectorWindows>("1.8"));
addJavaPathDetection(layout, row);
row++;
}
else if (QSysInfo::macVersion() != QSysInfo::MV_None)
{
m_javaPathDetector = std::make_shared<CombinedPathDetector>();
m_javaPathDetector->addDetector(std::make_shared<JavaPathDetectorMac>("1.8"));
addJavaPathDetection(layout, row);
}
layout->setRowMinimumHeight(row++, 20);
@@ -264,7 +278,7 @@ void QtProjectWizzardContentPreferences::javaPathDetectionClicked()
}
}
void QtProjectWizzardContentPreferences::addJavaPathDetection(QGridLayout* layout, int row)
void QtProjectWizzardContentPreferences::addJavaPathDetection(QGridLayout* layout, int& row)
{
std::vector<std::string> detectorNames = m_javaPathDetector->getWorkingDetectorNames();
if (!detectorNames.size())
@@ -286,6 +300,7 @@ void QtProjectWizzardContentPreferences::addJavaPathDetection(QGridLayout* layou
connect(button, SIGNAL(clicked()), this, SLOT(javaPathDetectionClicked()));
QHBoxLayout* hlayout = new QHBoxLayout();
hlayout->setContentsMargins(0, 0, 0, 0);
hlayout->addWidget(label);
hlayout->addWidget(m_javaPathDetectorBox);
hlayout->addWidget(button);
@@ -294,4 +309,5 @@ void QtProjectWizzardContentPreferences::addJavaPathDetection(QGridLayout* layou
detectionWidget->setLayout(hlayout);
layout->addWidget(detectionWidget, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft | Qt::AlignTop);
row++;
}
@@ -31,7 +31,7 @@ private slots:
void javaPathDetectionClicked();
private:
void addJavaPathDetection(QGridLayout* layout, int row);
void addJavaPathDetection(QGridLayout* layout, int& row);
QLineEdit* m_fontFace;
QComboBox* m_fontSize;
@@ -0,0 +1,34 @@
#include "utility/path_detector/java_runtime/JavaPathDetectorMac.h"
#include "utility/utilityApp.h"
#include "utility/utilityString.h"
JavaPathDetectorMac::JavaPathDetectorMac(const std::string javaVersion)
: JavaPathDetector("Java " + javaVersion + " for Mac", javaVersion)
{
}
JavaPathDetectorMac::~JavaPathDetectorMac()
{
}
std::vector<FilePath> JavaPathDetectorMac::getPaths() const
{
std::vector<FilePath> paths;
std::string command = "/usr/libexec/java_home";
std::string output = utility::executeProcess(command.c_str());
if (output.size())
{
output = utility::trim(output);
FilePath javaPath(output);
if (!javaPath.empty() && javaPath.exists())
{
paths.push_back(javaPath);
}
}
return paths;
}
@@ -0,0 +1,16 @@
#ifndef JAVA_PATH_DETECTOR_MAC_H
#define JAVA_PATH_DETECTOR_MAC_H
#include "utility/path_detector/java_runtime/JavaPathDetector.h"
class JavaPathDetectorMac
: public JavaPathDetector
{
public:
JavaPathDetectorMac(const std::string javaVersion);
virtual ~JavaPathDetectorMac();
virtual std::vector<FilePath> getPaths() const;
};
#endif // JAVA_PATH_DETECTOR_MAC_H