Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 332961 | Differences between
and this patch

Collapse All | Expand All

(-)META-INF/MANIFEST.MF (+1 lines)
Lines 10-15 Link Here
10
Bundle-RequiredExecutionEnvironment: J2SE-1.5
10
Bundle-RequiredExecutionEnvironment: J2SE-1.5
11
Require-Bundle: org.eclipse.core.runtime,
11
Require-Bundle: org.eclipse.core.runtime,
12
 org.eclipse.core.resources,
12
 org.eclipse.core.resources,
13
 org.eclipse.jface.text,
13
 org.eclipse.datatools.connectivity.oda.design.ui,
14
 org.eclipse.datatools.connectivity.oda.design.ui,
14
 org.eclipse.emf.edit.ui,
15
 org.eclipse.emf.edit.ui,
15
 org.eclipse.emf.ecore.edit,
16
 org.eclipse.emf.ecore.edit,
(-)src/org/eclipse/emf/oda/ecore/ui/impl/EcoreDataSetWizardPage.java (-29 / +78 lines)
Lines 60-65 Link Here
60
import org.eclipse.emf.ecore.util.EcoreUtil;
60
import org.eclipse.emf.ecore.util.EcoreUtil;
61
import org.eclipse.emf.ecore.util.QueryDelegate;
61
import org.eclipse.emf.ecore.util.QueryDelegate;
62
import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
62
import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
63
import org.eclipse.emf.edit.ui.util.QueryDelegateTextViewer;
63
import org.eclipse.emf.oda.ecore.impl.Connection;
64
import org.eclipse.emf.oda.ecore.impl.Connection;
64
import org.eclipse.emf.oda.ecore.impl.Driver;
65
import org.eclipse.emf.oda.ecore.impl.Driver;
65
import org.eclipse.emf.oda.ecore.impl.ParameterMetaData;
66
import org.eclipse.emf.oda.ecore.impl.ParameterMetaData;
Lines 68-73 Link Here
68
import org.eclipse.emf.oda.ecore.util.StringUtil;
69
import org.eclipse.emf.oda.ecore.util.StringUtil;
69
import org.eclipse.jface.layout.GridDataFactory;
70
import org.eclipse.jface.layout.GridDataFactory;
70
import org.eclipse.jface.resource.ImageDescriptor;
71
import org.eclipse.jface.resource.ImageDescriptor;
72
import org.eclipse.jface.text.Document;
73
import org.eclipse.jface.text.ITextListener;
74
import org.eclipse.jface.text.ITextViewer;
75
import org.eclipse.jface.text.TextEvent;
76
import org.eclipse.jface.text.TextViewer;
71
import org.eclipse.jface.viewers.ColumnWeightData;
77
import org.eclipse.jface.viewers.ColumnWeightData;
72
import org.eclipse.jface.viewers.ILabelProviderListener;
78
import org.eclipse.jface.viewers.ILabelProviderListener;
73
import org.eclipse.jface.viewers.ISelection;
79
import org.eclipse.jface.viewers.ISelection;
Lines 82-87 Link Here
82
import org.eclipse.jface.viewers.Viewer;
88
import org.eclipse.jface.viewers.Viewer;
83
import org.eclipse.jface.window.Window;
89
import org.eclipse.jface.window.Window;
84
import org.eclipse.swt.SWT;
90
import org.eclipse.swt.SWT;
91
import org.eclipse.swt.custom.StackLayout;
85
import org.eclipse.swt.events.ModifyEvent;
92
import org.eclipse.swt.events.ModifyEvent;
86
import org.eclipse.swt.events.ModifyListener;
93
import org.eclipse.swt.events.ModifyListener;
87
import org.eclipse.swt.events.MouseAdapter;
94
import org.eclipse.swt.events.MouseAdapter;
Lines 112-118 Link Here
112
119
113
  protected Combo queryDelegateCombo = null;
120
  protected Combo queryDelegateCombo = null;
114
121
115
  protected Text queryTextField = null;
122
  protected Map<String, ITextViewer> queryTextViewers = new HashMap<String, ITextViewer>();
123
  protected Composite queryTextViewerComposite = null;
124
  protected StackLayout queryTextViewerStackLayout = null;
116
125
117
  protected TableViewer variablesViewer = null;
126
  protected TableViewer variablesViewer = null;
118
  protected List<Variable> variables = new UniqueEList<Variable>();
127
  protected List<Variable> variables = new UniqueEList<Variable>();
Lines 175-185 Link Here
175
    queryDelegateLabel.setText(ODAEcoreUIPlugin.INSTANCE.getString("_UI_QueryDelegate_label")); //$NON-NLS-1$
184
    queryDelegateLabel.setText(ODAEcoreUIPlugin.INSTANCE.getString("_UI_QueryDelegate_label")); //$NON-NLS-1$
176
185
177
    queryDelegateCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
186
    queryDelegateCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
178
    queryDelegateCombo.addSelectionListener(new SelectionAdapter()
187
    queryDelegateCombo.addModifyListener(new ModifyListener()
179
      {
188
      {
180
        @Override
189
        public void modifyText(ModifyEvent me)
181
        public void widgetSelected(SelectionEvent ee)
182
        {
190
        {
191
          String queryDelegate = getQueryDelegate();
192
          QueryDelegateTextViewer.Factory factory = (QueryDelegateTextViewer.Factory)QueryDelegateTextViewer.Factory.Registry.INSTANCE.get(queryDelegate);
193
194
          ITextViewer queryTextViewer = queryTextViewers.get(queryDelegate);
195
196
          if (queryTextViewer == null)
197
          {
198
            queryTextViewer = factory != null
199
              ? factory.createTextViewer(queryTextViewerComposite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL) : new TextViewer(
200
                queryTextViewerComposite,
201
                SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
202
203
            queryTextViewer.addTextListener(new ITextListener()
204
              {
205
                public void textChanged(TextEvent te)
206
                {
207
                  validateData();
208
                }
209
              });
210
211
            queryTextViewers.put(queryDelegate, queryTextViewer);
212
          }
213
214
          queryTextViewerStackLayout.topControl = queryTextViewer.getTextWidget();
215
          queryTextViewerComposite.layout();
216
183
          validateData();
217
          validateData();
184
        }
218
        }
185
      });
219
      });
Lines 189-199 Link Here
189
      queryDelegateCombo.add(uri);
223
      queryDelegateCombo.add(uri);
190
    }
224
    }
191
225
192
    if (queryDelegateCombo.getItemCount() > 0)
193
    {
194
      queryDelegateCombo.setText(queryDelegateCombo.getItem(0));
195
    }
196
197
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(queryDelegateCombo);
226
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(queryDelegateCombo);
198
  }
227
  }
199
228
Lines 381-386 Link Here
381
      {
410
      {
382
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
411
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
383
        {
412
        {
413
          ITextViewer queryTextViewer = getQueryTextViewer();
414
415
          if (queryTextViewer instanceof QueryDelegateTextViewer)
416
          {
417
            ((QueryDelegateTextViewer)queryTextViewer).setParameters(convertVariablesToMap(getVariables()));
418
          }
384
        }
419
        }
385
420
386
        public void dispose()
421
        public void dispose()
Lines 528-543 Link Here
528
    Label queryTextLabel = new Label(parent, SWT.NONE);
563
    Label queryTextLabel = new Label(parent, SWT.NONE);
529
    queryTextLabel.setText(ODAEcoreUIPlugin.INSTANCE.getString("_UI_QueryText_label")); //$NON-NLS-1$
564
    queryTextLabel.setText(ODAEcoreUIPlugin.INSTANCE.getString("_UI_QueryText_label")); //$NON-NLS-1$
530
565
531
    queryTextField = new Text(parent, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
566
    (queryTextViewerComposite = new Composite(parent, SWT.NONE)).setLayout(queryTextViewerStackLayout = new StackLayout());
532
    queryTextField.addModifyListener(new ModifyListener()
533
      {
534
        public void modifyText(ModifyEvent me)
535
        {
536
          validateData();
537
        }
538
      });
539
567
540
    GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(queryTextField);
568
    GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(queryTextViewerComposite);
541
  }
569
  }
542
570
543
  /**
571
  /**
Lines 609-631 Link Here
609
      return; // nothing to initialize
637
      return; // nothing to initialize
610
    }
638
    }
611
639
612
    String queryText = dataSetDesign.getQueryText();
613
614
    if (queryText != null)
615
    {
616
      // initialize query text
617
      queryTextField.setText(queryText);
618
    }
619
620
    Properties properties = DesignUtil.convertDesignProperties(dataSetDesign.getPublicProperties());
640
    Properties properties = DesignUtil.convertDesignProperties(dataSetDesign.getPublicProperties());
621
641
622
    String queryDelegate = properties.getProperty(Query.DELEGATE_PROPERTY_NAME);
642
    String queryDelegate = properties.getProperty(Query.DELEGATE_PROPERTY_NAME);
623
643
624
    if (queryDelegate != null)
644
    if (!StringUtil.isEmpty(queryDelegate))
625
    {
645
    {
626
      // initialize query delegate
646
      // initialize query delegate
627
      queryDelegateCombo.setText(queryDelegate);
647
      queryDelegateCombo.setText(queryDelegate);
628
    }
648
    }
649
    else if (queryDelegateCombo.getItemCount() > 0)
650
    {
651
      queryDelegateCombo.setText(queryDelegateCombo.getItem(0));
652
    }
653
654
    String queryText = dataSetDesign.getQueryText();
655
656
    if (!StringUtil.isEmpty(queryText))
657
    {
658
      // initialize query text
659
      getQueryTextViewer().setDocument(new Document(queryText));
660
    }
661
    else
662
    {
663
      getQueryTextViewer().setDocument(new Document());
664
    }
629
665
630
    String context = properties.getProperty(Query.CONTEXT_PROPERTY_NAME);
666
    String context = properties.getProperty(Query.CONTEXT_PROPERTY_NAME);
631
667
Lines 843-849 Link Here
843
   */
879
   */
844
  protected String getQueryDelegate()
880
  protected String getQueryDelegate()
845
  {
881
  {
846
    return queryDelegateCombo == null ? null : queryDelegateCombo.getText();
882
    return queryDelegateCombo == null || queryDelegateCombo.isDisposed() ? null : queryDelegateCombo.getText();
847
  }
883
  }
848
884
849
  /**
885
  /**
Lines 855-867 Link Here
855
    return variables;
891
    return variables;
856
  }
892
  }
857
893
894
  protected ITextViewer getQueryTextViewer()
895
  {
896
    return queryTextViewers.get(getQueryDelegate());
897
  }
898
858
  /**
899
  /**
859
   * Returns the value of the query text.
900
   * Returns the value of the query text.
860
   * @return the query text
901
   * @return the query text
861
   */
902
   */
862
  protected String getQueryText()
903
  protected String getQueryText()
863
  {
904
  {
864
    return queryTextField == null ? null : queryTextField.getText();
905
    ITextViewer queryTextViewer = getQueryTextViewer();
906
    return queryTextViewer == null ? null : queryTextViewer.getDocument().get();
865
  }
907
  }
866
908
867
  /**
909
  /**
Lines 885-890 Link Here
885
    {
927
    {
886
      contextTypeField.setText(StringUtil.getTypeText(contextType));
928
      contextTypeField.setText(StringUtil.getTypeText(contextType));
887
    }
929
    }
930
931
    ITextViewer queryTextViewer = getQueryTextViewer();
932
933
    if (queryTextViewer instanceof QueryDelegateTextViewer)
934
    {
935
      ((QueryDelegateTextViewer)queryTextViewer).setContext(contextType);
936
    }
888
  }
937
  }
889
938
890
  /**
939
  /**

Return to bug 332961