import java.util.NoSuchElementException;
import java.util.Vector;
-import net.sourceforge.phpdt.sql.IConstants;
-import net.sourceforge.phpdt.sql.PHPEclipseSQLPlugin;
-import net.sourceforge.phpdt.sql.actions.ExecuteAction;
-import net.sourceforge.phpdt.sql.actions.ExportQueryAction;
-import net.sourceforge.phpdt.sql.actions.ImportQueryAction;
-import net.sourceforge.phpdt.sql.parser.SQLLexx;
-import net.sourceforge.phpdt.sql.parser.Token;
-import net.sourceforge.phpdt.sql.sql.MultiSQLServer;
-
import org.eclipse.jface.action.Action;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ExtendedModifyEvent;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.part.ViewPart;
+import net.sourceforge.phpdt.sql.IConstants;
+import net.sourceforge.phpdt.sql.Messages;
+import net.sourceforge.phpdt.sql.PHPEclipseSQLPlugin;
+import net.sourceforge.phpdt.sql.actions.ExecuteAction;
+import net.sourceforge.phpdt.sql.actions.ExportQueryAction;
+import net.sourceforge.phpdt.sql.actions.GeneratePHPAction;
+import net.sourceforge.phpdt.sql.actions.ImportQueryAction;
+import net.sourceforge.phpdt.sql.sql.MultiSQLServer;
+import net.sourceforge.phpdt.sql.sql.parser.SQLLexx;
+import net.sourceforge.phpdt.sql.sql.parser.Token;
+import net.sourceforge.phpdt.sql.view.bookmark.BookmarkNode;
+
public class SQLQueryView extends ViewPart implements IConstants {
- private ExecuteAction executeAction;
- private ImportQueryAction importQueryAction;
- private ExportQueryAction exportQueryAction;
+ ExecuteAction executeAction;
+ ImportQueryAction importQueryAction;
+ ExportQueryAction exportQueryAction;
+ GeneratePHPAction generatePHPAction;
private Clipboard clip;
private Label statusImage;
private Label status;
}
});
item = new ToolItem(toolbar, SWT.PUSH);
+ item.setImage(PHPEclipseSQLPlugin.getImage("php.gif")); //$NON-NLS-1$
+ item.setToolTipText(Messages.getString("sqlqueryview.generatePHP")); //$NON-NLS-1$
+ item.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ public void widgetSelected(SelectionEvent e) {
+ generatePHPAction.run();
+ }
+ });
+ item = new ToolItem(toolbar, SWT.PUSH);
item.setImage(PHPEclipseSQLPlugin.getImage("clear.gif")); //$NON-NLS-1$
item.setToolTipText(Messages.getString("sqlqueryview.clear")); //$NON-NLS-1$
item.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
- setQuery("");
+ setQuery(""); //$NON-NLS-1$
}
});
item = new ToolItem(toolbar, SWT.PUSH);
final ToolItem commit = item;
item.setImage(PHPEclipseSQLPlugin.getImage("commit.gif")); //$NON-NLS-1$
- item.setToolTipText("Commit");
+ item.setToolTipText(Messages.getString("SQLQueryView.Commit")); //$NON-NLS-1$
item.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
- MultiSQLServer.getInstance().commit();
+ BookmarkNode node = BookmarkView.getInstance().getCurrentBookmark();
+ MultiSQLServer.getInstance().commit(node.getConnection());
}
});
item.setEnabled(false);
item = new ToolItem(toolbar, SWT.PUSH);
final ToolItem rollback = item;
item.setImage(PHPEclipseSQLPlugin.getImage("rollback.gif")); //$NON-NLS-1$
- item.setToolTipText("RollBack");
+ item.setToolTipText(Messages.getString("SQLQueryView.RollBack")); //$NON-NLS-1$
item.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
- MultiSQLServer.getInstance().rollback();
+ BookmarkNode node = BookmarkView.getInstance().getCurrentBookmark();
+ MultiSQLServer.getInstance().rollback(node.getConnection());
}
});
item.setEnabled(false);
item = new ToolItem(toolbar, SWT.CHECK);
final ToolItem autocommit = item;
item.setImage(PHPEclipseSQLPlugin.getImage("autocommit.gif")); //$NON-NLS-1$
- item.setToolTipText("AutoCommit");
+ item.setToolTipText(Messages.getString("SQLQueryView.AutoCommit")); //$NON-NLS-1$
item.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
- MultiSQLServer.getInstance().setAutoCommit(autocommit.getSelection());
+ BookmarkNode node = BookmarkView.getInstance().getCurrentBookmark();
+
+ MultiSQLServer.getInstance().setAutoCommit(node.getConnection(), autocommit.getSelection());
if (autocommit.getSelection()) {
commit.setEnabled(false);
rollback.setEnabled(false);
progress = new ProgressBar(bottomStatus, SWT.HORIZONTAL);
- status.setText(Messages.getString("sqlqueryview.done"));
- statusImage.setImage(PHPEclipseSQLPlugin.getImage("success.gif"));
+ status.setText(Messages.getString("sqlqueryview.done")); //$NON-NLS-1$
+ statusImage.setImage(PHPEclipseSQLPlugin.getImage("success.gif")); //$NON-NLS-1$
progress.setMinimum(0);
}
importQueryAction.init(this);
exportQueryAction = new ExportQueryAction();
exportQueryAction.init(this);
+ generatePHPAction = new GeneratePHPAction();
+ generatePHPAction.init(this);
}
public void setStatus(String text) {
widget.setText(text);
}
- private String[] keywords = {"SELECT", "DROP", "FROM",
- "INSERT", "INTO", "VALUES",
- "CREATE", "TABLE", "VIEW", "SEQUENCE",
- "UPDATE", "SET", "WHERE"};
+ private String[] keywords = {"SELECT", "DROP", "FROM", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ "INSERT", "INTO", "VALUES", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ "CREATE", "TABLE", "VIEW", "SEQUENCE", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ "UPDATE", "SET", "WHERE"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
SyntaxHighlighter textUpdater = new SyntaxHighlighter();
if (upper || lower || both) {
min = Math.min(start, min);
max = Math.max(max, start + length);
- if (t.getType() == t.IDENTIFIER) {
+ if (t.getType() == Token.IDENTIFIER) {
boolean keyword = false;
for (int index = 0; index < keywords.length; index++) {
if (value.equals(keywords[index])) {
styleRange.foreground = DEFAULT;
}
styles.addElement(styleRange);
- } else if (t.getType() == t.COMMENT) {
+ } else if (t.getType() == Token.COMMENT) {
styleRange.foreground = COMMENT;
styles.addElement(styleRange);
- } else if (t.getType() == t.LITERAL) {
+ } else if (t.getType() == Token.LITERAL) {
styleRange.foreground = STRING_LITERAL;
styles.addElement(styleRange);
- } else if (t.getType() == t.NUMERIC) {
+ } else if (t.getType() == Token.NUMERIC) {
styleRange.foreground = NUMERIC;
styles.addElement(styleRange);
} else {
widget.setStyleRange(styles[i]);
}
} catch (Throwable t) {
- if (DEBUG) {
- System.out.println("Error with styles: " + t.getClass().toString());
+ System.out.println("Error with styles: " + t.getClass().toString()); //$NON-NLS-1$
// ignore any errors
- }
}
}
});