Author: yzhishko
Date: 2010-03-22 13:49:32 -0400 (Mon, 22 Mar 2010)
New Revision: 20976
Added:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/composite/TagAttributesTableViewer.java
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/DialogCellEditorEx.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DropWizardDialog.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/composite/TagAttributesComposite.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5876 - fixed.
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/DialogCellEditorEx.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/DialogCellEditorEx.java 2010-03-22
13:46:49 UTC (rev 20975)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/DialogCellEditorEx.java 2010-03-22
17:49:32 UTC (rev 20976)
@@ -42,6 +42,7 @@
public class DialogCellEditorEx extends DialogCellEditor { //implements IValueEditor {
protected Text text;
protected String textValue = null;
+ protected String startValue = null;
private Button button;
private static final int defaultStyle = SWT.NONE;
private boolean skipDeactivate = Boolean.FALSE.booleanValue();
@@ -181,6 +182,7 @@
}
public void keyReleased(KeyEvent e) {
if (e.character == '\u001b') { // Escape
+ text.setText(startValue);
fireCancelEditor();
}
}
@@ -295,11 +297,15 @@
public void activate() {
super.activate();
skipDeactivate = false;
+ if (text != null) {
+ startValue = text.getText();
+ }
}
public void deactivate() {
if (!this.skipDeactivate) {
skipDeactivate = true;
+ startValue = null;
super.deactivate();
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DropWizardDialog.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DropWizardDialog.java 2010-03-22
13:46:49 UTC (rev 20975)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DropWizardDialog.java 2010-03-22
17:49:32 UTC (rev 20976)
@@ -10,8 +10,13 @@
******************************************************************************/
package org.jboss.tools.common.model.ui.editors.dnd;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.events.TraverseEvent;
+import org.eclipse.swt.events.TraverseListener;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.jboss.tools.common.model.plugin.ModelPlugin;
@@ -39,4 +44,57 @@
if(os_name != null && os_name.indexOf("Windows") >= 0) return
DO_WIDTH_VALUE; //$NON-NLS-1$
return DO_WIDTH_VALUE_LINUX;
}
+
+ @Override
+ public void updateButtons() {
+ boolean canFlipToNextPage = false;
+ boolean canFinish = getWizard().canFinish();
+ if (getButton(IDialogConstants.BACK_ID) != null) {
+ getButton(IDialogConstants.BACK_ID).setEnabled(getCurrentPage().getPreviousPage() !=
null);
+ }
+ if (getButton(IDialogConstants.NEXT_ID) != null) {
+ canFlipToNextPage = getCurrentPage().canFlipToNextPage();
+ getButton(IDialogConstants.NEXT_ID).setEnabled(canFlipToNextPage);
+ }
+ getButton(IDialogConstants.FINISH_ID).setEnabled(canFinish);
+ getShell().setDefaultButton(null);
+ }
+
+ /*
+ *
+ * a part of
https://jira.jboss.org/jira/browse/JBIDE-5876 fix
+ *
+ */
+
+ @Override
+ protected Button createButton(Composite parent, int id, String label,
+ boolean defaultButton) {
+ Button button = super.createButton(parent, id, label, defaultButton);
+ if (id == IDialogConstants.FINISH_ID) {
+ getShell().setDefaultButton(null);
+ }
+ return button;
+ }
+
+ @Override
+ public void create() {
+ super.create();
+ getShell().addTraverseListener(new TraverseListener() {
+
+ public void keyTraversed(TraverseEvent e) {
+ if (e.character == '\r') {
+ Button finishButton = getButton(IDialogConstants.FINISH_ID);
+ Button cancelButton = getButton(IDialogConstants.CANCEL_ID);
+ if (!finishButton.isFocusControl() && !cancelButton.isFocusControl()) {
+ if (finishButton.isEnabled()) {
+ buttonPressed(IDialogConstants.FINISH_ID);
+ } else {
+ handleShellCloseEvent();
+ }
+ }
+ }
+ }
+ });
+ }
+
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/composite/TagAttributesComposite.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/composite/TagAttributesComposite.java 2010-03-22
13:46:49 UTC (rev 20975)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/composite/TagAttributesComposite.java 2010-03-22
17:49:32 UTC (rev 20976)
@@ -187,7 +187,7 @@
TableLayout tableLayout = new TableLayout();
tableViewer =
- new TableViewer(swtTable);
+ new TagAttributesTableViewer(swtTable);
swtTable.setLayout(tableLayout);
swtTable.setLayoutData(data);
Added:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/composite/TagAttributesTableViewer.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/composite/TagAttributesTableViewer.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/composite/TagAttributesTableViewer.java 2010-03-22
17:49:32 UTC (rev 20976)
@@ -0,0 +1,111 @@
+package org.jboss.tools.common.model.ui.editors.dnd.composite;
+
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent;
+import org.eclipse.jface.viewers.ICellEditorListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.jface.viewers.ViewerRow;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.TraverseEvent;
+import org.eclipse.swt.events.TraverseListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+
+public class TagAttributesTableViewer extends TableViewer {
+ private boolean isHandle = true;
+ private boolean isTraversed = false;
+
+ public TagAttributesTableViewer(Composite parent, int style) {
+ super(parent, style);
+ }
+
+ public TagAttributesTableViewer(Composite parent) {
+ super(parent);
+ }
+
+ public TagAttributesTableViewer(Table table) {
+ super(table);
+ }
+
+ @Override
+ protected void hookControl(Control control) {
+ super.hookControl(control);
+ if (getColumnViewerEditor() != null) {
+ getTable().addKeyListener(new KeyListener() {
+
+ public void keyReleased(KeyEvent e) {
+ if (isHandle || (!isHandle && isTraversed)) {
+ handleKeyReleasedEvent(e);
+ }
+ isHandle = true;
+ isTraversed = false;
+ }
+
+ public void keyPressed(KeyEvent e) {
+ }
+ });
+ addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ isTraversed = false;
+ isHandle = true;
+ }
+ });
+ getTable().addTraverseListener(new TraverseListener() {
+
+ public void keyTraversed(TraverseEvent e) {
+ if (e.character == '\r') {
+ e.doit = false;
+ }
+ if (isCellEditorActive() && e.detail == SWT.TRAVERSE_ESCAPE) {
+ e.doit = false;
+ e.detail = SWT.TRAVERSE_NONE;
+ isTraversed = true;
+ }
+ }
+ });
+ }
+ }
+
+ private void handleKeyReleasedEvent(KeyEvent keyEvent) {
+ if (keyEvent.character == '\r' && keyEvent.doit == true) {
+ TableItem[] selectedItems = getTable().getSelection();
+ if (selectedItems == null || selectedItems.length != 1) {
+ return;
+ }
+ TableItem item = selectedItems[0];
+ ViewerRow row = getViewerRowFromItem(item);
+ ViewerCell cell = row.getCell(1);
+ if (cell != null) {
+ triggerEditorActivationEvent(new ColumnViewerEditorActivationEvent(
+ cell));
+ }
+ }
+ }
+
+ @Override
+ public void setCellEditors(CellEditor[] editors) {
+ super.setCellEditors(editors);
+ editors[1].addListener(new ICellEditorListener() {
+
+ public void editorValueChanged(boolean oldValidState,
+ boolean newValidState) {
+ isHandle = false;
+ }
+
+ public void cancelEditor() {
+ isHandle = false;
+ }
+
+ public void applyEditorValue() {
+ }
+ });
+ }
+
+}