which accompanies this distribution, and is available at
http://www.eclipse.org/legal/cpl-v10.html
- Contributors:
- IBM Corporation - Initial implementation
- Klaus Hartlage - www.eclipseproject.de
**********************************************************************/
package net.sourceforge.phpeclipse;
plugin = this;
setJVM();
externalTools = new ExternalToolsPlugin();
+
// try {
// resourceBundle =
// ResourceBundle.getBundle("net.sourceforge.PHPeclipsePluginResources");
// store.setDefault(PHP_LOCALHOST_PREF, "http://localhost");
// store.setDefault(PHP_DOCUMENTROOT_PREF, getWorkspace().getRoot()
// .getLocation().toString());
+
- // store.setDefault(SHOW_EXTERNAL_PREVIEW_PREF, "true");
+// store.setDefault(SHOW_EXTERNAL_PREVIEW_PREF, "true");
// store.setDefault(USE_EXTERNAL_BROWSER_PREF, "false");
store.setDefault(SHOW_OUTPUT_IN_CONSOLE, "true");
store.setDefault(PHP_OBFUSCATOR_DEFAULT, "c:\\temp");
// if ((jvm == WINDOWS_9x) || (jvm == WINDOWS_NT)) {
//
if (windowsSystem.equals(Platform.WS_WIN32)) {
+// String workspaceLocation = getWorkspace().getRoot().getLocation().toString();
+// String baseLocation = null;
+// int index = workspaceLocation.lastIndexOf('/');
+// if (index>0) {
+// index = workspaceLocation.lastIndexOf('/', index-1);
+// if (index>0) {
+// baseLocation = workspaceLocation.substring(0,index);
+// }
+// }
+// if (baseLocation!=null) {
+// String xampp_start = baseLocation + "/xampp_start.exe";
+// String xampp_stop = baseLocation + "/xampp_stop.exe";
+// File testFile = new File(xampp_start);
+// if (testFile.exists()) {
+// System.out.println(xampp_start);
+// System.out.println(xampp_stop);
+// } else {
+// xampp_start = "c:\\xampp\\xampp_start.exe";
+// xampp_stop = "c:\\xampp\\xampp_stop.exe";
+// testFile = new File(xampp_start);
+// if (testFile.exists()) {
+// System.out.println(xampp_start);
+// System.out.println(xampp_stop);
+// }
+// }
+// }
store.setDefault(PHP_RUN_PREF, "c:\\apache\\php\\php.exe");
store.setDefault(EXTERNAL_PARSER_PREF, "c:\\apache\\php\\php -l -f {0}");
store.setDefault(MYSQL_RUN_PREF, "c:\\apache\\mysql\\bin\\mysqld-nt.exe");
*/
public void start(BundleContext context) throws Exception {
super.start(context);
-
+
// JavaCore.start(this, context);
final JavaModelManager manager = JavaModelManager.getJavaModelManager();
try {
Contributors:
IBM Corporation - Initial implementation
- Klaus Hartlage - www.eclipseproject.de
**********************************************************************/
package net.sourceforge.phpeclipse.phpeditor.php;
}
IPHPCompletionProposal[] sqlResults = new IPHPCompletionProposal[0];
if (project != null) {
- // Get The Database bookmark from the Quantum SQL plugin:
- BookmarkCollection sqlBookMarks = BookmarkCollection.getInstance();
- if (sqlBookMarks != null) {
- String bookmarkString = Util.getMiscProjectsPreferenceValue(project,
- IPreferenceConstants.PHP_BOOKMARK_DEFAULT);
- if (bookmarkString != null && !bookmarkString.equals("")) {
- Bookmark bookmark = sqlBookMarks.find(bookmarkString);
- ArrayList sqlList = new ArrayList();
- if (bookmark != null && !bookmark.isConnected()) {
- new ConnectionUtil().connect(bookmark, null);
- }
- if (bookmark != null && bookmark.isConnected()) {
- try {
- Connection connection = bookmark.getConnection();
- DatabaseMetaData metaData = connection.getMetaData();
-
- if (metaData != null) {
- int start = context.getStart();
- int end = context.getEnd();
- String foundSQLTableName = sqlTable.getTableName();
- String tableName;
- String columnName;
- String prefixWithoutDollar = prefix;
- boolean isDollarPrefix = false;
- if (prefix.length() > 0 && prefix.charAt(0) == '$') {
- prefixWithoutDollar = prefix.substring(1);
- isDollarPrefix = true;
- }
- IRegion region = new Region(start, end - start);
- ResultSet set;
- if (!isDollarPrefix) {
- set = metaData.getTables(null, null, prefixWithoutDollar
- + "%", null);
- while (set.next()) {
- // String tempSchema = set.getString("TABLE_SCHEM");
- // tempSchema = (tempSchema == null) ? "" :
- // tempSchema.trim();
- tableName = set.getString("TABLE_NAME");
- tableName = (tableName == null) ? "" : tableName.trim();
- if (tableName != null && tableName.length() > 0) {
- sqlList.add(new SQLProposal(tableName, context, region,
- viewer, PHPUiImages.get(PHPUiImages.IMG_TABLE)));
- }
- }
- set.close();
- }
- set = metaData.getColumns(null, null, "%",
- prefixWithoutDollar + "%");
- SQLProposal sqlProposal;
- while (set.next()) {
- columnName = set.getString("COLUMN_NAME");
- columnName = (columnName == null) ? "" : columnName.trim();
- tableName = set.getString("TABLE_NAME");
- tableName = (tableName == null) ? "" : tableName.trim();
- if (tableName != null && tableName.length() > 0
- && columnName != null && columnName.length() > 0) {
- if (isDollarPrefix) {
- sqlProposal = new SQLProposal(tableName, "$"
- + columnName, context, region, viewer, PHPUiImages
- .get(PHPUiImages.IMG_COLUMN));
- } else {
- sqlProposal = new SQLProposal(tableName, columnName,
- context, region, viewer, PHPUiImages
- .get(PHPUiImages.IMG_COLUMN));
- }
- if (tableName.equals(foundSQLTableName)) {
- sqlProposal.setRelevance(90);
- } else if (tableName.indexOf(foundSQLTableName) >= 0) {
- sqlProposal.setRelevance(75);
- }
- sqlList.add(sqlProposal);
- }
- }
- set.close();
- sqlResults = new IPHPCompletionProposal[sqlList.size()];
- for (int i = 0; i < sqlList.size(); i++) {
- sqlResults[i] = (SQLProposal) sqlList.get(i);
- }
- }
- } catch (NotConnectedException e) {
- // ignore this - not mission critical
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
- }
+ sqlResults = getSQLProposals(viewer, project, context, prefix, sqlTable, sqlResults);
}
// concatenate the result arrays
IPHPCompletionProposal[] total;
return new IPHPCompletionProposal[0];
}
+ /**
+ * @param viewer
+ * @param project
+ * @param context
+ * @param prefix
+ * @param sqlTable
+ * @param sqlResults
+ * @return
+ */
+ private IPHPCompletionProposal[] getSQLProposals(ITextViewer viewer, IProject project, JavaContext context, String prefix, TableName sqlTable, IPHPCompletionProposal[] sqlResults) {
+ // Get The Database bookmark from the Quantum SQL plugin:
+ BookmarkCollection sqlBookMarks = BookmarkCollection.getInstance();
+ if (sqlBookMarks != null) {
+ String bookmarkString = Util.getMiscProjectsPreferenceValue(project,
+ IPreferenceConstants.PHP_BOOKMARK_DEFAULT);
+ if (bookmarkString != null && !bookmarkString.equals("")) {
+ Bookmark bookmark = sqlBookMarks.find(bookmarkString);
+ ArrayList sqlList = new ArrayList();
+ if (bookmark != null && !bookmark.isConnected()) {
+ new ConnectionUtil().connect(bookmark, null);
+ }
+ if (bookmark != null && bookmark.isConnected()) {
+ try {
+ Connection connection = bookmark.getConnection();
+ DatabaseMetaData metaData = connection.getMetaData();
+
+ if (metaData != null) {
+ int start = context.getStart();
+ int end = context.getEnd();
+ String foundSQLTableName = sqlTable.getTableName();
+ String tableName;
+ String columnName;
+ String prefixWithoutDollar = prefix;
+ boolean isDollarPrefix = false;
+ if (prefix.length() > 0 && prefix.charAt(0) == '$') {
+ prefixWithoutDollar = prefix.substring(1);
+ isDollarPrefix = true;
+ }
+ IRegion region = new Region(start, end - start);
+ ResultSet set;
+ if (!isDollarPrefix) {
+ set = metaData.getTables(null, null, prefixWithoutDollar
+ + "%", null);
+ while (set.next()) {
+ // String tempSchema = set.getString("TABLE_SCHEM");
+ // tempSchema = (tempSchema == null) ? "" :
+ // tempSchema.trim();
+ tableName = set.getString("TABLE_NAME");
+ tableName = (tableName == null) ? "" : tableName.trim();
+ if (tableName != null && tableName.length() > 0) {
+ sqlList.add(new SQLProposal(tableName, context, region,
+ viewer, PHPUiImages.get(PHPUiImages.IMG_TABLE)));
+ }
+ }
+ set.close();
+ }
+ set = metaData.getColumns(null, null, "%",
+ prefixWithoutDollar + "%");
+ SQLProposal sqlProposal;
+ while (set.next()) {
+ columnName = set.getString("COLUMN_NAME");
+ columnName = (columnName == null) ? "" : columnName.trim();
+ tableName = set.getString("TABLE_NAME");
+ tableName = (tableName == null) ? "" : tableName.trim();
+ if (tableName != null && tableName.length() > 0
+ && columnName != null && columnName.length() > 0) {
+ if (isDollarPrefix) {
+ sqlProposal = new SQLProposal(tableName, "$"
+ + columnName, context, region, viewer, PHPUiImages
+ .get(PHPUiImages.IMG_COLUMN));
+ } else {
+ sqlProposal = new SQLProposal(tableName, columnName,
+ context, region, viewer, PHPUiImages
+ .get(PHPUiImages.IMG_COLUMN));
+ }
+ if (tableName.equals(foundSQLTableName)) {
+ sqlProposal.setRelevance(90);
+ } else if (tableName.indexOf(foundSQLTableName) >= 0) {
+ sqlProposal.setRelevance(75);
+ }
+ sqlList.add(sqlProposal);
+ }
+ }
+ set.close();
+ sqlResults = new IPHPCompletionProposal[sqlList.size()];
+ for (int i = 0; i < sqlList.size(); i++) {
+ sqlResults[i] = (SQLProposal) sqlList.get(i);
+ }
+ }
+ } catch (NotConnectedException e) {
+ // ignore this - not mission critical
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ return sqlResults;
+ }
+
private int guessContextInformationPosition(ITextViewer viewer, int offset) {
int contextPosition = offset;
IDocument document = viewer.getDocument();