Author: dgeraskov
Date: 2010-11-01 10:08:51 -0400 (Mon, 01 Nov 2010)
New Revision: 26161
Removed:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/TextDialogCellEditor.java
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/QueryParametersPage.java
Log:
Reverted wrong commit
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/QueryParametersPage.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/QueryParametersPage.java 2010-11-01
13:55:48 UTC (rev 26160)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/QueryParametersPage.java 2010-11-01
14:08:51 UTC (rev 26161)
@@ -48,7 +48,6 @@
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
@@ -63,7 +62,6 @@
import org.eclipse.ui.part.Page;
import org.hibernate.console.ConsoleQueryParameter;
import org.hibernate.console.ImageConstants;
-import org.hibernate.console.ParametersListDialog;
import org.hibernate.console.QueryInputModel;
import org.hibernate.eclipse.console.HibernateConsoleMessages;
import org.hibernate.eclipse.console.QueryEditor;
@@ -124,6 +122,8 @@
toggleActive.setChecked(model.ignoreParameters());
tableViewer.getTable().setEnabled(!model.ignoreParameters());
tableViewer.setInput(model);
+
+
}
private void createStatusLabel() {
@@ -224,27 +224,11 @@
}
}
if ( VALUE_PROPERTY.equals( property ) ) {
- String[] inputStrings;
- if (value instanceof String[]){
- inputStrings = (String[])value;
- } else {
- inputStrings = new String[]{(String) value};
- }
- Object[] values = new Object[inputStrings.length];
- for (int i = 0; i < inputStrings.length; i++) {
- values[i] = cqp.convertStringToValue(inputStrings[i]);
- }
- if (values.length > 1){
- cqp.setValue(values);
- } else if (values.length == 1){
- cqp.setValue(values[0]);
- } else {
- cqp.setValue(null);
- }
+ cqp.setValueFromString((String) value);
}
if ( NULL_PROPERTY.equals( property ) ) {
if(cqp.isNull()) {
- cqp.setValue(cqp.convertStringToValue( "" )); // best attempt to
"unnull" //$NON-NLS-1$
+ cqp.setValueFromString( "" ); // best attempt to "unnull"
//$NON-NLS-1$
} else {
cqp.setNull();
}
@@ -269,11 +253,7 @@
}
}
if ( VALUE_PROPERTY.equals( property ) ) {
- return cqp.getStringValues();
- /*if (cqp.isArrayValue()){
- return cqp.convertValueToString(((Object[])cqp.getValue())[0]);
- }
- return cqp.convertValueToString(cqp.getValue());*/
+ return cqp.getValueAsString();
}
if ( NULL_PROPERTY.equals( property )) {
return Boolean.valueOf(cqp.isNull());
@@ -314,21 +294,7 @@
CellEditor[] editors = new CellEditor[columnProperties.length];
editors[0] = new TextCellEditor( queryParametersTable );
editors[1] = new ComboBoxCellEditor( queryParametersTable, valueTypes );
- editors[2] = new TextDialogCellEditor(queryParametersTable) {
-
- @Override
- protected Object openDialogBox(Control cellEditorWindow) {
- Object firstElement =
((IStructuredSelection)tableViewer.getSelection()).getFirstElement();
- if(firstElement instanceof ConsoleQueryParameter) {
- ParametersListDialog pld = new ParametersListDialog(null, (ConsoleQueryParameter)
firstElement);
- if (pld.open()==Window.OK){
- return pld.getValue();//String[]
- }
- }
- return getValue();//could be String or String[]
- }
- };
-
+ editors[2] = new TextCellEditor( queryParametersTable );
editors[3] = new CheckboxCellEditor( queryParametersTable );
tableViewer.setCellEditors( editors );
@@ -357,7 +323,7 @@
case 1:
return cqp.getType().getName();
case 2:
- return cqp.getStringValues()[0];
+ return cqp.getValueAsString();
case 3:
return null; //cqp.isNull()?"X":"";
default:
Deleted:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/TextDialogCellEditor.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/TextDialogCellEditor.java 2010-11-01
13:55:48 UTC (rev 26160)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/TextDialogCellEditor.java 2010-11-01
14:08:51 UTC (rev 26161)
@@ -1,243 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.hibernate.eclipse.console.views;
-
-import java.text.MessageFormat;
-
-import org.eclipse.jface.viewers.TextCellEditor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Layout;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public abstract class TextDialogCellEditor extends TextCellEditor {
-
- private Text text;
-
- /**
- * The button.
- */
- private Button button;
-
- /**
- * The editor control.
- */
- private Composite editor;
-
- private String[] strValues = null;
-
- private FocusListener buttonFocusListener;
-
- protected TextDialogCellEditor(Composite parent) {
- super(parent);
- }
-
- @Override
- protected Control createControl(Composite parent) {
- Font font = parent.getFont();
- Color bg = parent.getBackground();
-
- editor = new Composite(parent, getStyle());
- editor.setFont(font);
- editor.setBackground(bg);
- editor.setLayout(new DialogCellLayout());
-
- text = (Text) super.createControl(editor);
- updateContents(strValues);
-
- button = createButton(editor);
- button.setFont(font);
-
- button.addKeyListener(new KeyAdapter() {
- /* (non-Javadoc)
- * @see
org.eclipse.swt.events.KeyListener#keyReleased(org.eclipse.swt.events.KeyEvent)
- */
- public void keyReleased(KeyEvent e) {
- if (e.character == '\u001b') { // Escape
- fireCancelEditor();
- }
- }
- });
-
- button.addFocusListener(getButtonFocusListener());
-
- button.addSelectionListener(new SelectionAdapter() {
- /* (non-Javadoc)
- * @see
org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- public void widgetSelected(SelectionEvent event) {
- // Remove the button's focus listener since it's guaranteed
- // to lose focus when the dialog opens
- button.removeFocusListener(getButtonFocusListener());
-
- Object newValue = openDialogBox(editor);
-
- // Re-add the listener once the dialog closes
- button.addFocusListener(getButtonFocusListener());
-
- if (newValue != null) {
- boolean newValidState = isCorrect(newValue);
- if (newValidState) {
- markDirty();
- doSetValue(newValue);
- } else {
- // try to insert the current value into the error message.
- setErrorMessage(MessageFormat.format(getErrorMessage(),
- new Object[] { newValue.toString() }));
- }
- fireApplyEditorValue();
- }
- }
-
-
- });
-
- setValueValid(true);
-
- return editor;
- }
-
- @Override
- protected void focusLost() {
- if (isActivated()) {
- if (button != null && !button.isDisposed() &&
!button.isFocusControl()) {
- if (text != null && !text.isDisposed() &&
!text.isFocusControl()){
- fireApplyEditorValue();
- deactivate();
- }
- }
- }
- }
-
- protected abstract Object openDialogBox(Control cellEditorWindow);
-
- private FocusListener getButtonFocusListener() {
- if (buttonFocusListener == null) {
- buttonFocusListener = new FocusListener() {
-
- /* (non-Javadoc)
- * @see
org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent)
- */
- public void focusGained(FocusEvent e) {
-
- }
-
- /* (non-Javadoc)
- * @see
org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
- */
- public void focusLost(FocusEvent e) {
- TextDialogCellEditor.this.focusLost();
- }
- };
- }
-
- return buttonFocusListener;
- }
-
- protected Button createButton(Composite parent) {
- Button result = new Button(parent, SWT.DOWN);
- result.setText("..."); //$NON-NLS-1$
- return result;
- }
-
- public void deactivate() {
- if (button != null && !button.isDisposed()) {
- button.removeFocusListener(getButtonFocusListener());
- }
-
- super.deactivate();
- }
-
- @Override
- protected void editOccured(ModifyEvent e) {
- String text = this.text.getText();
- if (strValues == null || strValues.length == 0){
- strValues = new String[]{text};
- } else {
- strValues[0] = text;
- }
- super.editOccured(e);
- }
-
- protected Object doGetValue() {
- return strValues;
- }
-
- protected void doSetValue(Object value) {
- if (value == null) {
- value = "";
- this.strValues = new String[]{""};
- } else if (value.getClass().isArray()){
- this.strValues = (String[])value;
- value = this.strValues[0];
- }
- super.doSetValue(value);
- }
-
- protected void updateContents(String[] value) {
- if (text == null) {
- return;
- }
-
- String strVal = "";//$NON-NLS-1$
- if (value != null && value.length > 0) {
- strVal = value[0];
- }
- text.setText(strVal);
- }
-
- private class DialogCellLayout extends Layout {
- public void layout(Composite editor, boolean force) {
- Rectangle bounds = editor.getClientArea();
- Point size = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, force);
- if (text != null) {
- text.setBounds(0, 0, bounds.width - size.x, bounds.height);
- }
- button.setBounds(bounds.width - size.x, 0, size.x, bounds.height);
- }
-
- public Point computeSize(Composite editor, int wHint, int hHint,
- boolean force) {
- if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) {
- return new Point(wHint, hHint);
- }
- Point contentsSize = text.computeSize(SWT.DEFAULT, SWT.DEFAULT,
- force);
- Point buttonSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT,
- force);
- // Just return the button width to ensure the button is not clipped
- // if the label is long.
- // The label will just use whatever extra width there is
- Point result = new Point(buttonSize.x, Math.max(contentsSize.y,
- buttonSize.y));
- return result;
- }
- }
-
-
-}
\ No newline at end of file