1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
/*******************************************************************************
* Copyright (c) 2004, 2007 Sybase, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Sybase, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties;
import org.eclipse.jface.window.Window;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode;
import org.eclipse.jst.jsf.facesconfig.ui.util.WebrootUtil;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
/**
*
* Dialog Cell Editor for Action's outcome browser.
*
* @author Xiao-guang Zhang
*/
public class ActionOutcomeDialogCellEditor extends EditableDialogCellEditor {
/** the source PFLink element */
PageflowElement element;
/**
* @param element
*/
public ActionOutcomeDialogCellEditor(PageflowElement element) {
super();
this.element = element;
}
/**
* @param parent
* @param element
*/
public ActionOutcomeDialogCellEditor(Composite parent,
PageflowElement element) {
super(parent);
this.element = element;
}
/**
* @param parent
* @param style
* @param element
*/
public ActionOutcomeDialogCellEditor(Composite parent, int style,
PageflowElement element) {
super(parent, style);
this.element = element;
}
/**
* get the previous JSP page, it can be null if the previous node is not
* PFPage, but PFAction.
*
* @param element_
* @return
*/
private String getPreviousJSPPath(PageflowElement element_) {
String jspPath = null;
if (element_ instanceof PageflowLink) {
PageflowNode source = ((PageflowLink) element_).getSource();
if (source instanceof PageflowPage) {
jspPath = ((PageflowPage) source).getPath();
}
}
return jspPath;
}
/*
* (non-Javadoc)
*
* @see DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control)
*/
protected Object openDialogBox(Control cellEditorWindow) {
String outcome = getDefaultText().getText();
String jspPathName = WebrootUtil.getProjectPath(element,
getPreviousJSPPath(element));
ActionOutcomeSelectionDialog selectionDialog = new ActionOutcomeSelectionDialog(
getControl().getShell(), outcome, jspPathName);
if (selectionDialog.open() == Window.OK) {
outcome = selectionDialog.getSelectedAction();
}
return outcome;
}
}
|