Author: rob.stryker(a)jboss.com
Date: 2008-09-22 15:21:00 -0400 (Mon, 22 Sep 2008)
New Revision: 10399
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/ChangePortDialog.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/XPathDialogs.java
Log:
JBIDE-2235 - ui for selecting ports in server editor
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java 2008-09-22
16:46:28 UTC (rev 10398)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java 2008-09-22
19:21:00 UTC (rev 10399)
@@ -63,8 +63,8 @@
public static String ServerDialogHeading;
public static String credentials_warning;
public static String credentials_save;
-
-
+
+
/* Module extension properties */
public static String ModulePropertyType;
public static String ModulePropertyProject;
@@ -116,12 +116,12 @@
public static String ActionDelegatePublishFailed;
public static String ActionDelegateFileResourcesOnly;
public static String ActionDelegateSelectServer;
-
+
/* Console */
public static String ConsoleResourceNotFound;
public static String ConsoleCouldNotLocateInWorkspace;
-
+
/* Twiddle Dialog */
public static String TwiddleDialog;
public static String TwiddleDialogExecute;
@@ -198,7 +198,7 @@
public static String DescriptorXPathComplex;
public static String DescriptorXPathMatch;
-
+
/* Filesets addition */
public static String FilesetsCreateFilter;
public static String FilesetsDeleteFilter;
@@ -209,11 +209,11 @@
public static String FilesetsNewName;
public static String FilesetsNewRootDir;
public static String FilesetsNewBrowse;
- public static String FilesetsNewIncludes;
- public static String FilesetsNewExcludes;
+ public static String FilesetsNewIncludes;
+ public static String FilesetsNewExcludes;
public static String FilesetsNewPreview;
-
-
+
+
/* Editor Strings */
public static String EditorSetDeployLabel;
public static String EditorSetTempDeployLabel;
@@ -232,29 +232,21 @@
public static String EditorChangeWebCommandName;
public static String EditorChangeUsernameCommandName;
public static String EditorChangePasswordCommandName;
- public static String EditorCPD_Name;
- public static String EditorCPD_XPath;
- public static String EditorCPD_Attribute;
- public static String EditorCPD_Count;
public static String EditorCPD_Value;
- public static String EditorCPD_Location;
- public static String EditorCPD_Default;
- public static String EditorCPD_NoDefault;
- public static String EditorCPD_SelectionDetails;
public static String EditorCPD_DefaultShellTitle;
public static String EditorCPD_DefaultDescription;
-
+
public static String Customize;
-
+
// misc
public static String ServerSaveFailed;
-
+
// Launch Config
public static String LaunchInvalidConfigChanged;
public static String LaunchInvalidHostChanged;
-
+
static {
NLS.initializeMessages(JBossServerUIPlugin.PLUGIN_ID + ".Messages",
Messages.class);
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties 2008-09-22
16:46:28 UTC (rev 10398)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties 2008-09-22
19:21:00 UTC (rev 10399)
@@ -26,7 +26,7 @@
swf_NameInUse=Server name already in use
swf_DeployGroup=Deployment
swf_DeployEditorHeading=Deployment
-swf_DeploymentDescription=The temporary deployment location is where files will \nbe
copied to before being renamed into the deploy directory. \nThis folder should be on the
same file system \nas the deploy folder.
+swf_DeploymentDescription=The temporary deployment location is where files will \nbe
copied to before being renamed into the deploy directory. \nThis folder should be on the
same file system \nas the deploy folder.
swf_DeployDirectory=Deploy Directory
swf_TempDeployDirectory=Temporary Deploy Directory
sswf_Title=Create a new System Copy Server
@@ -85,7 +85,7 @@
ActionDelegateFileResourcesOnly=One or more selected objects are not Files.
ActionDelegateSelectServer=Select a server to publish to
-# Console
+# Console
ConsoleResourceNotFound=Resource not found
ConsoleCouldNotLocateInWorkspace=Could not locate {0} in workspace.
@@ -93,7 +93,7 @@
TwiddleDialog=Twiddle Dialog
TwiddleDialogExecute=Execute Twiddle
TwiddleDialogDone=Done
-TwiddleDialogArguments=Twiddle Arguments\:
+TwiddleDialogArguments=Twiddle Arguments\:
TwiddleDialogTutorial=Twiddle Tutorial
@@ -106,16 +106,16 @@
XPathNameInUse=Name already in use.
XPathColumnLocation=Location
XPathColumnAttributeVals=Value
-XPathName=Name\:
-XPathPattern=XPath Pattern\:
-XPathAttribute=Attribute Name\:
+XPathName=Name\:
+XPathPattern=XPath Pattern\:
+XPathAttribute=Attribute Name\:
#preference page
PreferencePageServerTimeouts=Server Timeouts
PreferencePageStartTimeouts=Start Timeout
PreferencePageStopTimeouts=Stop Timeout
-PreferencePageUponTimeout=Upon Timeout\:
+PreferencePageUponTimeout=Upon Timeout\:
PreferencePageUponTimeoutAbort=Abort Server Transition
PreferencePageUponTimeoutIgnore=Set Server State to Target State
@@ -129,27 +129,27 @@
JBoss Servers View. \n The enablement box designates whether the extension should be
present.\
The weight field \ndesignates how "heavy" each extension is. (Heavier elements
fall towards the bottom.)
-ViewExtensionPreferenceDescription=Below, you may set or clear any preferences specific
to each view extension above. \nSome extensions may have no preferences to set.
+ViewExtensionPreferenceDescription=Below, you may set or clear any preferences specific
to each view extension above. \nSome extensions may have no preferences to set.
# Upgrade Wizard
UpgradeWizardTitle=Convert JBoss AS Launch Configurations
- UpgradeWizardDescription=Starting and Stopping JBoss is no longer done through simple
launch configurations.\nInstead, webtools and its server functionality is being used,
which means your launch\nconfigurations must be converted into JBoss "servers"
and "runtimes".\n\n This wizard will help with that.
+ UpgradeWizardDescription=Starting and Stopping JBoss is no longer done through simple
launch configurations.\nInstead, webtools and its server functionality is being used,
which means your launch\nconfigurations must be converted into JBoss "servers"
and "runtimes".\n\n This wizard will help with that.
UpgradeWizardNoConvertableConfigs=You do not have any JBoss launch configurations to
convert, so you can just skip this page.
- UpgradeWizardDetails=Details\:
- UpgradeWizardLaunchConfigName=Launch Configuration Name\:
- UpgradeWizardLaunchHomeDir=Home Directory\:
- UpgradeWizardLaunchJBossConfig=JBoss Configuration\:
- UpgradeWizardLaunchStartArgs=Start Args\:
- UpgradeWizardLaunchShutdownArgs=Shutdown Args\:
- UpgradeWizardLaunchJRE=JRE\:
+ UpgradeWizardDetails=Details\:
+ UpgradeWizardLaunchConfigName=Launch Configuration Name\:
+ UpgradeWizardLaunchHomeDir=Home Directory\:
+ UpgradeWizardLaunchJBossConfig=JBoss Configuration\:
+ UpgradeWizardLaunchStartArgs=Start Args\:
+ UpgradeWizardLaunchShutdownArgs=Shutdown Args\:
+ UpgradeWizardLaunchJRE=JRE\:
UpgradeWizardLaunchConvert=Convert?
UpgradeWizardLaunchConfigName2=Configuration Name
UpgradeWizardLaunchRuntimeName=Runtime Name
UpgradeWizardLaunchServerName=Server Name
UpgradeWizardLaunchMonitorMainTask=Converting Launch Configurations
- UpgradeWizardLaunchMonitorConverting=Converting
- UpgradeWizardLaunchRuntimeNamesInUse=The following runtime names are already in use\:
+ UpgradeWizardLaunchMonitorConverting=Converting
+ UpgradeWizardLaunchRuntimeNamesInUse=The following runtime names are already in use\:
UpgradeWizardLaunchServerNamesInUse=The following server names are already in use:
@@ -172,11 +172,11 @@
DescriptorXPathAttributeKeyValue=Attribute Key / Value
DescriptorXPathDescriptorValues=Descriptor Values
DescriptorXPathNameLocation=Name / Location
-DescriptorXPathServerName=Server Name\:
-DescriptorXPathPortCategory=Port Category\:
+DescriptorXPathServerName=Server Name\:
+DescriptorXPathPortCategory=Port Category\:
DescriptorXPathSimple=Show only xpath value in properties view.
DescriptorXPathComplex=Show all details in properties view.
-DescriptorXPathMatch=Match
+DescriptorXPathMatch=Match
#Filesets
@@ -186,11 +186,11 @@
FilesetsDeleteFile=Delete File
FilesetsEditFile=Edit File
FilesetsNewFileset=New File Filter
-FilesetsNewName=Name:
-FilesetsNewRootDir=Root Directory:
+FilesetsNewName=Name:
+FilesetsNewRootDir=Root Directory:
FilesetsNewBrowse=Browse...
-FilesetsNewIncludes=Includes:
-FilesetsNewExcludes=Excludes:
+FilesetsNewIncludes=Includes:
+FilesetsNewExcludes=Excludes:
FilesetsNewPreview=Preview
@@ -212,15 +212,7 @@
EditorChangeWebCommandName=Change Web Port Details
EditorChangeUsernameCommandName=Change Username
EditorChangePasswordCommandName=Change Password
-EditorCPD_Name=Name
-EditorCPD_XPath=XPath Pattern
-EditorCPD_Attribute=Attribute Name
-EditorCPD_Count=Number of Matches
-EditorCPD_Value=First Value
-EditorCPD_Location=File of first match
-EditorCPD_Default=The default xpath for {0} is "{1}".
-EditorCPD_NoDefault=There is no default xpath for {0}.
-EditorCPD_SelectionDetails=Selection Details
+EditorCPD_Value=Current Value
EditorCPD_DefaultShellTitle=Edit Port
EditorCPD_DefaultDescription=This wizard allows you to edit which xpath is used to locate
a port used by the tooling.\nThis will not change any server files, only what ports are
used to interact with it.
Customize=Customize...
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/ChangePortDialog.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/ChangePortDialog.java 2008-09-22
16:46:28 UTC (rev 10398)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/ChangePortDialog.java 2008-09-22
19:21:00 UTC (rev 10399)
@@ -9,7 +9,7 @@
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.osgi.util.NLS;
+import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
@@ -17,11 +17,10 @@
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Shell;
@@ -32,6 +31,7 @@
import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathModel;
import org.jboss.ide.eclipse.as.core.extensions.descriptors.XPathQuery;
import org.jboss.ide.eclipse.as.ui.Messages;
+import org.jboss.ide.eclipse.as.ui.dialogs.XPathDialogs.XPathDialog;
public class ChangePortDialog extends TitleAreaDialog {
@@ -43,26 +43,21 @@
public IServer server;
public String currentXPath;
}
-
+
private ChangePortDialogInfo info;
private String selected;
private XPathQuery currentQuery;
private boolean queriesLoaded = false;
private List listWidget;
- private Group group;
- private Label nameLabel; private Text nameValueLabel;
- private Label xpathLabel; private Text xpathValueLabel;
- private Label attributeLabel; private Text attributeValueLabel;
- private Label locationLabel; private Text locationValueLabel;
- private Label countLabel; private Text countValueLabel;
- private Label valueLabel; private Text valueValueLabel;
+ private Label currentValue;
+ private Text currentValueText;
+ private Button editXPathButton;
-
public ChangePortDialog(Shell parentShell, ChangePortDialogInfo info) {
super(parentShell);
this.info = info;
}
-
+
protected Control createDialogArea(Composite parent) {
Composite c = (Composite)super.createDialogArea(parent);
Composite main = new Composite(c, SWT.BORDER);
@@ -74,7 +69,7 @@
setTitle(info.port);
setMessage(info.description != null ? info.description
: Messages.EditorCPD_DefaultDescription);
- getShell().setText(info.shellTitle != null ? info.shellTitle
+ getShell().setText(info.shellTitle != null ? info.shellTitle
: Messages.EditorCPD_DefaultShellTitle);
return c;
}
@@ -87,61 +82,30 @@
d.bottom = new FormAttachment(100,-5);
d.right = new FormAttachment(0,150);
listWidget.setLayoutData(d);
-
- Label defaultLabel = new Label(main, SWT.NONE);
+
+ currentValue = new Label(main, SWT.NONE);
d = new FormData();
- d.right = new FormAttachment(100,-5);
- d.left = new FormAttachment(listWidget,5);
- d.bottom = new FormAttachment(100,-5);
- defaultLabel.setLayoutData(d);
-
- group = new Group(main, SWT.DEFAULT);
+ d.left = new FormAttachment(listWidget, 5);
+ d.top = new FormAttachment(0,7);
+ currentValue.setLayoutData(d);
+ currentValue.setText(Messages.EditorCPD_Value);
+
+ editXPathButton = new Button(main, SWT.NONE);
d = new FormData();
- d.right = new FormAttachment(100,-5);
- d.left = new FormAttachment(listWidget,5);
- d.bottom = new FormAttachment(defaultLabel,-5);
- d.top = new FormAttachment(0,5);
- group.setLayoutData(d);
+ d.right = new FormAttachment(100, -5);
+ d.top = new FormAttachment(currentValue, 5);
+ editXPathButton.setLayoutData(d);
+ editXPathButton.setText(Messages.DescriptorXPathEditXPath);
- GridLayout gl = new GridLayout(2, false);
- gl.marginRight = 5;
- group.setLayout(gl);
- GridData common = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
- nameLabel = new Label(group, SWT.NONE);
- nameValueLabel = new Text(group, SWT.DEFAULT | SWT.H_SCROLL);
- xpathLabel = new Label(group, SWT.NONE);
- xpathValueLabel = new Text(group, SWT.DEFAULT | SWT.H_SCROLL);
- attributeLabel = new Label(group, SWT.NONE);
- attributeValueLabel = new Text(group, SWT.DEFAULT | SWT.H_SCROLL);
- countLabel = new Label(group, SWT.NONE);
- countValueLabel = new Text(group, SWT.DEFAULT | SWT.H_SCROLL);
- valueLabel = new Label(group, SWT.NONE);
- valueValueLabel = new Text(group, SWT.DEFAULT | SWT.H_SCROLL);
- locationLabel = new Label(group, SWT.NONE);
- locationValueLabel = new Text(group, SWT.DEFAULT | SWT.H_SCROLL);
-
- nameValueLabel.setLayoutData(common);
- xpathValueLabel.setLayoutData(common);
- attributeValueLabel.setLayoutData(common);
- countValueLabel.setLayoutData(common);
- valueValueLabel.setLayoutData(common);
- locationValueLabel.setLayoutData(common);
-
- nameLabel.setText(Messages.EditorCPD_Name);
- xpathLabel.setText(Messages.EditorCPD_XPath);
- attributeLabel.setText(Messages.EditorCPD_Attribute);
- countLabel.setText(Messages.EditorCPD_Count);
- valueLabel.setText(Messages.EditorCPD_Value);
- locationLabel.setText(Messages.EditorCPD_Location);
- String defaultLabelText;
- if( info.defaultValue != null )
- defaultLabelText = NLS.bind(Messages.EditorCPD_Default, info.port,
info.defaultValue);
- else
- defaultLabelText = NLS.bind(Messages.EditorCPD_NoDefault, info.port);
- defaultLabel.setText(defaultLabelText);
- group.setText(Messages.EditorCPD_SelectionDetails);
+ currentValueText = new Text(main, SWT.DEFAULT);
+ d = new FormData();
+ d.left = new FormAttachment(listWidget, 5);
+ d.right = new FormAttachment(editXPathButton,-5);
+ d.top = new FormAttachment(currentValue,5);
+ currentValueText.setLayoutData(d);
+ currentValueText.setEnabled(false);
}
-
+
protected void fillWidgets() {
ArrayList<String> list = new ArrayList<String>();
XPathCategory[] categories = XPathModel.getDefault().getCategories(info.server);
@@ -153,7 +117,7 @@
}
String[] stuff = (String[]) list.toArray(new String[list.size()]);
listWidget.setItems(stuff);
- for( int i = 0; i < stuff.length; i++ )
+ for( int i = 0; i < stuff.length; i++ )
if( stuff[i] == info.currentXPath)
listWidget.select(i);
}
@@ -166,11 +130,39 @@
public void widgetSelected(SelectionEvent e) {
selectionChanged();
} });
+
+ editXPathButton.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ public void widgetSelected(SelectionEvent e) {
+ editPressed();
+ } });
+
}
-
+
+ protected void editPressed() {
+ if( currentQuery != null ) {
+ XPathCategory category = currentQuery.getCategory();
+
+ XPathDialog d = new XPathDialog(Display.getCurrent().getActiveShell(),
+ info.server, category.getName(), currentQuery.getName());
+ d.setAttribute(currentQuery.getAttribute());
+ d.setXpath(currentQuery.getXpathPattern());
+
+ if( d.open() == Window.OK ) {
+ currentQuery.setAttribute(d.getAttribute());
+ currentQuery.setXpathPattern(d.getXpath());
+ currentQuery.setName(d.getName());
+ category.save();
+ fillWidgets();
+ }
+ }
+ }
+
protected synchronized void selectionChanged() {
- if( !queriesLoaded ) {
- try {
+ if( !queriesLoaded ) {
+ try {
final String[] items = listWidget.getItems();
ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
dialog.run(true, false, new IRunnableWithProgress() {
@@ -183,22 +175,22 @@
}
monitor.done();
queriesLoaded = true;
- Display.getDefault().asyncExec(new Runnable() {
+ Display.getDefault().asyncExec(new Runnable() {
public void run() {
selectionChanged2();
}
});
} });
- } catch( InvocationTargetException ite) {
+ } catch( InvocationTargetException ite) {
ite.printStackTrace();
- } catch(InterruptedException ie ) {
+ } catch(InterruptedException ie ) {
ie.printStackTrace();
}
} else {
selectionChanged2();
}
}
-
+
private void selectionChanged2() {
currentQuery = null;
int s = listWidget.getSelectionIndex();
@@ -207,26 +199,16 @@
currentQuery = XPathModel.getDefault().getQuery(info.server, new Path(selected));
}
if(currentQuery != null) {
- nameValueLabel.setText(safeString(currentQuery.getName()));
- xpathValueLabel.setText(safeString(currentQuery.getXpathPattern()));
- attributeValueLabel.setText(safeString(currentQuery.getAttribute()));
- locationValueLabel.setText(safeString(currentQuery.getBaseDir()));
- countValueLabel.setText(countMatches(currentQuery));
- valueValueLabel.setText(safeString(currentQuery.getFirstResult()));
+ editXPathButton.setEnabled(true);
+ currentValueText.setText(currentQuery.getFirstResult());
} else {
- nameValueLabel.setText(safeString(null));
- xpathValueLabel.setText(safeString(null));
- attributeValueLabel.setText(safeString(null));
- locationValueLabel.setText(safeString(null));
- countValueLabel.setText(safeString(null));
- valueValueLabel.setText(safeString(null));
}
}
-
+
private String countMatches(XPathQuery query) {
- if( query == null )
+ if( query == null )
return new Integer(-1).toString();
-
+
int count = 0;
XPathFileResult[] fResults = query.getResults();
for( int i = 0; i < fResults.length; i++ ) {
@@ -237,7 +219,7 @@
private String safeString(String s) {
return s == null ? "" : s;
}
-
+
public String getSelection() {
return selected;
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/XPathDialogs.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/XPathDialogs.java 2008-09-22
16:46:28 UTC (rev 10398)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/dialogs/XPathDialogs.java 2008-09-22
19:21:00 UTC (rev 10399)
@@ -87,7 +87,7 @@
private String currentText;
private IServer server;
private Label errorLabel;
-
+
public XPathCategoryDialog(Shell parentShell, IServer server) {
super(parentShell);
this.server = server;
@@ -96,17 +96,17 @@
this(parentShell, server);
this.initialName = initialName;
}
-
-
+
+
protected void configureShell(Shell shell) {
super.configureShell(shell);
shell.setText(Messages.XPathNewCategory);
}
-
+
protected Control createDialogArea(Composite parent) {
Composite c = (Composite)super.createDialogArea(parent);
c.setLayout(new FormLayout());
-
+
errorLabel = new Label(c, SWT.NONE);
errorLabel.setText(Messages.XPathNewCategoryNameInUse);
FormData errorData = new FormData();
@@ -114,7 +114,7 @@
errorData.top = new FormAttachment(0,5);
errorLabel.setLayoutData(errorData);
errorLabel.setVisible(false);
-
+
Label l = new Label(c, SWT.NONE);
l.setText(Messages.XPathCategoryName);
FormData labelData = new FormData();
@@ -122,8 +122,8 @@
labelData.top = new FormAttachment(errorLabel,5);
l.setLayoutData(labelData);
-
- final Text t = new Text(c, SWT.BORDER);
+
+ final Text t = new Text(c, SWT.BORDER);
FormData tData = new FormData();
tData.left = new FormAttachment(l,5);
tData.top = new FormAttachment(errorLabel,5);
@@ -133,16 +133,16 @@
if( currentText != null ) {
t.setText(currentText);
}
-
+
t.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
verifyText(t.getText());
- }
+ }
});
-
+
return c;
}
-
+
private void verifyText(String text) {
boolean valid = !XPathModel.getDefault().containsCategory(server, text) ||
(initialName != null && initialName.equals(text));
if( valid ) {
@@ -154,7 +154,7 @@
getButton(IDialogConstants.OK_ID).setEnabled(false);
}
}
-
+
public String getText() {
return currentText;
}
@@ -167,21 +167,21 @@
protected Combo categoryCombo, serverCombo;
protected Label nameLabel, serverLabel, categoryLabel, xpathLabel, attributeLabel;
protected Button previewButton;
-
+
protected XPathProposalProvider proposalProvider;
-
+
protected IServer server;
protected String name, xpath, attribute, category;
protected String originalName = null;
protected XPathQuery original = null;
protected int previewId = 48879;
-
+
protected Tree previewTree;
protected TreeColumn column, column2;
protected TreeViewer previewTreeViewer;
protected Composite main;
protected XMLDocumentRepository repository;
-
+
public XPathDialog(Shell parentShell) {
this(parentShell, null);
}
@@ -210,7 +210,7 @@
int ret = super.getShellStyle();
return ret | SWT.RESIZE;
}
-
+
protected void createButtonsForButtonBar(Composite parent) {
// create OK and Cancel buttons by default
super.createButtonsForButtonBar(parent);
@@ -220,7 +220,7 @@
checkErrors();
}
-
+
protected Control createDialogArea(Composite parent) {
main = (Composite)super.createDialogArea(parent);
main.setLayout(new FormLayout());
@@ -229,15 +229,15 @@
if( name != null ) nameText.setText(name);
if( attribute != null ) attributeText.setText(attribute);
if( xpath != null ) xpathText.setText(xpath);
-
+
proposalProvider = new XPathProposalProvider(repository);
- if( server != null )
+ if( server != null )
proposalProvider.setPath(getConfigFolder(server));
ContentProposalAdapter adapter = new
ContentProposalAdapter(xpathText, new TextContentAdapter(),
proposalProvider, null, null);
adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
-
+
XPathAttributeProposalProvider provider2 = new
XPathAttributeProposalProvider(repository, xpathText);
if( server != null )
provider2.setPath(getConfigFolder(server));
@@ -245,10 +245,10 @@
ContentProposalAdapter(attributeText, new TextContentAdapter(),
provider2, null, null);
adapter2.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
-
+
return main;
- }
-
+ }
+
protected void fillCombos() {
if( serverCombo != null ) {
IServer servers[] = ServerConverter.getJBossServersAsIServers();
@@ -258,39 +258,39 @@
}
serverCombo.setItems(names);
}
-
- if( categoryCombo != null ) {
+
+ if( categoryCombo != null ) {
refreshCategoryCombo();
}
}
-
+
protected void addListeners() {
nameText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
checkErrors();
name = nameText.getText();
- }
+ }
});
attributeText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
attribute = attributeText.getText();
- }
+ }
});
xpathText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
xpath = xpathText.getText();
- }
+ }
});
-
+
previewButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
previewPressed();
- }
+ }
});
-
-
+
+
if( serverCombo != null ) {
serverCombo.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
@@ -305,16 +305,16 @@
return;
}
}
- }
+ }
});
}
-
+
if( categoryCombo != null ) {
categoryCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
category = categoryCombo.getText();
checkErrors();
- }
+ }
});
categoryCombo.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
@@ -326,17 +326,17 @@
});
}
}
-
-
+
+
protected void checkErrors() {
ArrayList<String> errorList = getErrors();
- if( errorList.size() == 0 ) {
- setError(null);
+ if( errorList.size() == 0 ) {
+ setError(null);
getButton(IDialogConstants.OK_ID).setEnabled(true);
- return;
+ return;
}
setError(errorList.get(0));
- if( getButton(IDialogConstants.OK_ID) != null )
+ if( getButton(IDialogConstants.OK_ID) != null )
getButton(IDialogConstants.OK_ID).setEnabled(false);
return;
}
@@ -347,19 +347,19 @@
String categoryError = getCategoryError(); if( categoryError != null )
list.add(categoryError);
return list;
}
-
+
protected String getServerError() {
if( server == null ) return "Please Select a Server";
return null;
}
-
+
protected String getCategoryError() {
if( "".equals(category)) {
return "Category must not be blank";
}
return null;
}
-
+
protected void setError(String message) {
if( message == null ) {
errorImage.setVisible(false);
@@ -371,7 +371,7 @@
errorLabel.setText(message);
}
}
-
+
protected String getNameError() {
if( nameText.getText().equals("")) {
return Messages.XPathNameEmpty;
@@ -380,7 +380,7 @@
XPathCategory[] categories = XPathModel.getDefault().getCategories(server);
XPathCategory category = null;
for( int i = 0; i < categories.length; i++ ) {
- if( categories[i].getName().equals(this.category))
+ if( categories[i].getName().equals(this.category))
category = categories[i];
}
if( category != null ) {
@@ -388,8 +388,8 @@
boolean found = false;
for( int i = 0; i < queries.length; i++ ) {
if(nameText.getText().equals( ((XPathQuery)queries[i]).getName())) {
-
- if( originalName == null || !nameText.getText().equals(originalName))
+
+ if( originalName == null || !nameText.getText().equals(originalName))
return Messages.XPathNameInUse;
}
}
@@ -397,14 +397,14 @@
return null;
}
-
+
protected void setServer(IServer s) {
server = s;
proposalProvider.setPath(getConfigFolder(s));
refreshCategoryCombo();
checkErrors();
}
-
+
protected void refreshCategoryCombo() {
if( server != null ) {
XPathCategory[] categories = XPathModel.getDefault().getCategories(server);
@@ -415,21 +415,22 @@
categoryCombo.setItems(categoryNames);
}
}
-
+
protected void previewPressed() {
if( server == null ) {
checkErrors();
return;
}
-
+
+ final String xpText = xpathText.getText();
+ final String attText = attributeText.getText();
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException {
- final IProgressMonitor monitor2 = monitor;
- XPathQuery tmp = new XPathQuery("", getConfigFolder(server), null,
xpathText.getText(), attributeText.getText());
+ XPathQuery tmp = new XPathQuery("", getConfigFolder(server), null, xpText,
attText);
tmp.setRepository(repository);
final ArrayList<XPathFileResult> list = new
ArrayList<XPathFileResult>();
list.addAll(Arrays.asList(tmp.getResults()));
- Display.getDefault().asyncExec(new Runnable() {
+ Display.getDefault().asyncExec(new Runnable() {
public void run() {
previewTreeViewer.setInput(list);
if( list.size() == 0 ) {
@@ -447,7 +448,7 @@
}
};
try {
- new ProgressMonitorDialog(new Shell()).run(false, true, op);
+ new ProgressMonitorDialog(new Shell()).run(true, true, op);
} catch (InvocationTargetException e) {
} catch (InterruptedException e) {
}
@@ -455,25 +456,25 @@
protected void layoutWidgets(Composite c) {
// create widgets
descriptionLabel = new Label(c, SWT.WRAP);
- descriptionLabel.setText("An XPath is a way to find a specific XML element inside
an xml file. \n" +
+ descriptionLabel.setText("An XPath is a way to find a specific XML element inside
an xml file. \n" +
"This dialog will help you create one. These XPaths' values can then be
modified\n"
+ "by using the JBoss Servers View with the Properties View.");
descriptionLabel.setVisible(true);
errorLabel = new Label(c, SWT.NONE);
errorImage = new Label(c, SWT.NONE);
errorImage.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK));
-
-
+
+
Composite middleComposite = createMiddleComposite(c);
-
-
+
+
// Now do the tree and viewer
previewTree = new Tree(c, SWT.BORDER);
previewTree.setHeaderVisible(true);
previewTree.setLinesVisible(true);
column = new TreeColumn(previewTree, SWT.NONE);
column2 = new TreeColumn(previewTree, SWT.NONE);
-
+
column.setText(Messages.XPathColumnLocation);
column2.setText(Messages.XPathColumnAttributeVals);
@@ -485,35 +486,35 @@
c.layout();
int pixel = Math.max(Math.max(nameLabel.getSize().x, xpathLabel.getSize().x),
attributeLabel.getSize().x);
pixel += 5;
-
+
// Lay them out
FormData descriptionData = new FormData();
descriptionData.left = new FormAttachment(0, 5);
descriptionData.right = new FormAttachment(100, -5);
descriptionData.top = new FormAttachment(0,5);
descriptionLabel.setLayoutData(descriptionData);
-
+
FormData errorData = new FormData();
errorData.left = new FormAttachment(errorImage,5);
errorData.top = new FormAttachment(descriptionLabel,5);
errorData.right = new FormAttachment(0,300);
errorLabel.setLayoutData(errorData);
errorLabel.setVisible(false);
-
+
FormData errorImageData = new FormData();
errorImageData.left = new FormAttachment(0,5);
errorImageData.top = new FormAttachment(descriptionLabel,5);
errorImage.setLayoutData(errorImageData);
errorImage.setVisible(false);
-
-
+
+
FormData middleCompositeData = new FormData();
middleCompositeData.left = new FormAttachment(0,5);
middleCompositeData.right = new FormAttachment(100, -5);
middleCompositeData.top = new FormAttachment(errorLabel, 5);
middleComposite.setLayoutData(middleCompositeData);
-
+
// Tree layout data
FormData previewTreeData = new FormData();
previewTreeData.left = new FormAttachment(0,5);
@@ -521,20 +522,20 @@
previewTreeData.top = new FormAttachment(middleComposite,5);
previewTreeData.bottom = new FormAttachment(100,-5);
previewTree.setLayoutData(previewTreeData);
-
+
previewTreeViewer.setContentProvider(new ITreeContentProvider() {
public Object[] getChildren(Object parentElement) {
// we're a leaf
- if( parentElement instanceof XPathResultNode )
+ if( parentElement instanceof XPathResultNode )
return new Object[0];
-
- // we're a file node (blah.xml)
+
+ // we're a file node (blah.xml)
if( parentElement instanceof XPathFileResult ) {
- if( ((XPathFileResult)parentElement).getChildren().length > 1 )
+ if( ((XPathFileResult)parentElement).getChildren().length > 1 )
return ((XPathFileResult)parentElement).getChildren();
return new Object[0];
}
-
+
// we're the named element (JNDI)
if( parentElement instanceof XPathQuery ) {
XPathFileResult[] kids = ((XPathQuery)parentElement).getResults();
@@ -563,34 +564,34 @@
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
+ }
+
});
-
+
previewTreeViewer.setLabelProvider(new XPathPropertyLabelProvider());
-
+
}
protected Composite createMiddleComposite(Composite c) {
Composite gridComposite = new Composite(c, SWT.NONE);
gridComposite.setLayout(new GridLayout(2, false));
-
+
nameLabel = new Label(gridComposite, SWT.NONE);
nameText= new Text(gridComposite, SWT.BORDER);
nameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
-
+
if( server == null ) {
serverLabel = new Label(gridComposite, SWT.NONE);
serverCombo = new Combo(gridComposite, SWT.BORDER | SWT.READ_ONLY);
serverCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
}
-
+
if( category == null ) {
categoryLabel = new Label(gridComposite, SWT.NONE);
categoryCombo = new Combo(gridComposite, SWT.BORDER);
categoryCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
}
-
+
xpathLabel = new Label(gridComposite, SWT.NONE);
xpathText = new Text(gridComposite, SWT.BORDER);
xpathText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
@@ -607,7 +608,7 @@
attributeLabel.setText(Messages.XPathAttribute);
return gridComposite;
}
-
+
public String getAttribute() {
return attribute;
}
@@ -619,7 +620,7 @@
public String getXpath() {
return xpath;
}
-
+
public String getCategory() {
return category;
}
@@ -645,7 +646,7 @@
xpathText.setText(this.xpath);
}
}
-
+
public static class XPathAttributeProposalProvider extends XPathProposalProvider {
private Text elementText;
public XPathAttributeProposalProvider(XMLDocumentRepository repo, Text elementText) {
@@ -656,7 +657,7 @@
String[] strings = getAttributeNameProposalStrings(elementText.getText(),
contents.trim());
return convertProposals(strings);
}
-
+
public String[] getAttributeNameProposalStrings(String parentPath, String remainder) {
ArrayList<String> names = new ArrayList<String>();
XPathResultNode[] items = getXPath(parentPath);
@@ -664,14 +665,14 @@
for( int i = 0; i < items.length; i++ ) {
attributes = items[0].getElementAttributeNames();
for( int j = 0; j < attributes.length; j++ ) {
- if( attributes[j].startsWith(remainder) && !names.contains(attributes[j]))
+ if( attributes[j].startsWith(remainder) && !names.contains(attributes[j]))
names.add(attributes[j]);
}
}
return names.toArray(new String[names.size()]);
}
}
-
+
public static class XPathProposalProvider implements IContentProposalProvider {
protected static final int NEW_ELEMENT = 1;
@@ -681,25 +682,25 @@
protected static final int IN_ATTRIBUTE = 5;
protected static final int IN_ATTRIBUTE_VALUE = 6;
protected static final int CLOSE_ATTRIBUTE = 7;
-
+
private String path;
private HashMap<String, ArrayList<XPathResultNode>> xpathCache;
protected XMLDocumentRepository repository;
-
+
public XPathProposalProvider(XMLDocumentRepository repository) {
xpathCache = new HashMap<String, ArrayList<XPathResultNode>>();
this.repository = repository;
}
-
+
public void setPath(String path) {
this.path = path;
}
-
+
public IContentProposal[] getProposals(String contents, int position) {
if( contents.equals("") || contents.equals("/") ||
contents.equals(" ")) {
return new IContentProposal[] { new XPathContentProposal("/server/",
"/server/".length(), null, null)};
}
-
+
int type = getType(contents);
if( type == NEW_ELEMENT ) return getElementProposals(contents, "");
if( type == IN_ELEMENT ) return getElementProposals(contents);
@@ -709,11 +710,11 @@
if( type == IN_ATTRIBUTE_VALUE ) return getAttributeValueProposals(contents);
return new IContentProposal[]{};
}
-
+
protected XPathResultNode[] getXPath(String xpath) {
- if( path == null )
+ if( path == null )
return new XPathResultNode[0];
-
+
if( xpathCache.containsKey(xpath)) {
ArrayList list = xpathCache.get(xpath);
return (XPathResultNode[]) list.toArray(new XPathResultNode[list.size()]);
@@ -732,18 +733,18 @@
xpathCache.put(xpath, list);
return list.toArray(new XPathResultNode[list.size()]);
}
-
+
public IContentProposal[] getElementProposals(String path) {
String parentPath = path.substring(0, path.lastIndexOf('/') + 1);
String prefix = path.substring(path.lastIndexOf('/') + 1);
return getElementProposals(parentPath, prefix);
}
-
+
public IContentProposal[] getElementProposals(String parentPath, String elementPrefix )
{
String[] strings = getElementProposalStrings(parentPath, elementPrefix );
return convertProposals(strings);
}
-
+
public String[] getElementProposalStrings(String parentPath, String elementPrefix) {
TreeSet<String> set = new TreeSet<String>();
XPathResultNode[] items = getXPath(parentPath + "*");
@@ -758,14 +759,14 @@
}
return set.toArray(new String[set.size()]);
}
-
+
public IContentProposal[] getAttributeNameProposals(String path) {
String parent = path.substring(0, path.lastIndexOf('['));
int attName = path.lastIndexOf('[') > path.lastIndexOf('@') ?
path.lastIndexOf('[') : path.lastIndexOf('@');
String[] props = getAttributeNameProposalStrings(parent, path.substring(attName+1));
return convertProposals(props);
}
-
+
public IContentProposal[] getAttributeNameProposals(String parentPath, String
remainder) {
return convertProposals(getAttributeNameProposalStrings(parentPath, remainder));
}
@@ -777,18 +778,18 @@
for( int i = 0; i < items.length; i++ ) {
attributes = items[0].getElementAttributeNames();
for( int j = 0; j < attributes.length; j++ ) {
- if( attributes[j].startsWith(remainder) && !names.contains(attributes[j]))
+ if( attributes[j].startsWith(remainder) && !names.contains(attributes[j]))
names.add(attributes[j]);
}
}
-
+
String[] results = new String[names.size()];
for( int i = 0; i < results.length; i++ ) {
results[i] = parentPath + "[@" + names.get(i) + "=";
}
return results;
}
-
+
public IContentProposal[] getAttributeValueProposals(String path) {
return getAttributeValueProposals(path.substring(0, path.lastIndexOf('=')),
path.substring(path.lastIndexOf('=')+1));
}
@@ -807,11 +808,11 @@
for( int i = 0; i < items.length; i++ ) {
attributes = items[i].getElementAttributeValues(attName);
for( int j = 0; j < attributes.length; j++ ) {
- if( attributes[j].startsWith(remainder) && !values.contains(attributes[j]))
+ if( attributes[j].startsWith(remainder) && !values.contains(attributes[j]))
values.add(attributes[j]);
}
}
-
+
String[] results = new String[values.size()];
String prefix = parentElementPath + "[@" + attName + "='";
for( int i = 0; i < results.length; i++ ) {
@@ -820,7 +821,7 @@
Arrays.sort(results);
return convertProposals(results);
}
-
+
public int getType(String contents) {
switch(contents.charAt(contents.length()-1)) {
case '/':
@@ -837,7 +838,7 @@
int lastOpenBracket = contents.lastIndexOf('['); max = (lastOpenBracket >
max ? lastOpenBracket : max);
int lastCloseBracket = contents.lastIndexOf(']'); max = (lastCloseBracket
> max ? lastCloseBracket : max);
int lastEquals = contents.lastIndexOf('='); max = (lastEquals > max ?
lastEquals : max);
-
+
if( max == lastSlash ) return IN_ELEMENT;
if( max == lastOpenBracket ) return IN_ATTRIBUTE;
if( max == lastCloseBracket ) return CLOSE_ATTRIBUTE;
@@ -846,7 +847,7 @@
}
return -1;
}
-
+
public IContentProposal[] convertProposals(String[] strings) {
ArrayList<XPathContentProposal> list = new
ArrayList<XPathContentProposal>();
for( int i = 0; i < strings.length; i++ ) {
@@ -854,7 +855,7 @@
}
return list.toArray(new IContentProposal[list.size()]);
}
-
+
public class XPathContentProposal implements IContentProposal {
private String content,description,label;
private int position;
@@ -881,7 +882,7 @@
}
}
}
-
+
public static String getConfigFolder(IServer server) {
JBossServer jbs = (JBossServer)server.loadAdapter(JBossServer.class, new
NullProgressMonitor());
if( jbs != null ) {