Author: elvisisking
Date: 2010-11-16 15:31:23 -0500 (Tue, 16 Nov 2010)
New Revision: 26639
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.properties
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/jobs/PublishJob.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/wizards/PublishPage.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/wizards/PublishWizard.java
Log:
JBDS-1402 Cannot enter the ModeShape workspace path. The ModeShape workspace area is a
path segment that is prepended to the resource project path. The workspace area is
configurable in ModeShape. For beta 2 I'm putting a textfield in the PublishingWizard
to allow the user to put in the area.
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.java 2010-11-16
19:36:50 UTC (rev 26638)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.java 2010-11-16
20:31:23 UTC (rev 26639)
@@ -126,6 +126,9 @@
public static I18n publishPageWorkspaceLabel;
public static I18n publishPageWorkspacePublishToolTip;
public static I18n publishPageWorkspaceUnpublishToolTip;
+ public static I18n publishPageWorkspaceAreaLabel;
+ public static I18n publishPageWorkspaceAreaToolTip;
+ public static I18n publishPageFinishedErrorMsg;
public static I18n publishWizardPublishErrorMsg;
public static I18n publishWizardPublishTitle;
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.properties
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.properties 2010-11-16
19:36:50 UTC (rev 26638)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.properties 2010-11-16
20:31:23 UTC (rev 26639)
@@ -118,6 +118,9 @@
publishPageWorkspaceLabel = Workspace:
publishPageWorkspacePublishToolTip = The workspace where the resources are being
published
publishPageWorkspaceUnpublishToolTip = The workspace where the resources are being
unpublished
+publishPageWorkspaceAreaLabel = Workspace Area:
+publishPageWorkspaceAreaToolTip = Enter a ModeShape workspace path segment to prepend to
each resource project path
+publishPageFinishedErrorMsg = Unexpected error in PublishPage after successfully
finishing the publishing wizard.
publishWizardPublishErrorMsg = Error Publishing
publishWizardPublishTitle = Publish
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/jobs/PublishJob.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/jobs/PublishJob.java 2010-11-16
19:36:50 UTC (rev 26638)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/jobs/PublishJob.java 2010-11-16
20:31:23 UTC (rev 26639)
@@ -105,6 +105,11 @@
*/
private final Workspace workspace;
+ /**
+ * The path segment prepended to the resource project path (never
<code>null</code> but can be empty)
+ */
+ private final String workspaceArea;
+
//
===========================================================================================================================
// Constructors
//
===========================================================================================================================
@@ -113,10 +118,12 @@
* @param type the job type (never <code>null</code>)
* @param files the files being published or unpublished (never
<code>null</code>)
* @param workspace the workspace to use when publishing or unpublishing (never
<code>null</code>)
+ * @param workspaceArea the path segment prepended to the file project path (maybe be
<code>null</code> or empty)
*/
public PublishJob( Type type,
List<IFile> files,
- Workspace workspace ) {
+ Workspace workspace,
+ String workspaceArea ) {
super(getJobName(type, JOB_ID.incrementAndGet()));
CheckArg.isNotNull(files, "files");
@@ -126,7 +133,16 @@
this.files = files;
this.workspace = workspace;
this.jobId = JOB_ID.get();
+
+ // setup the workspace area and remove trailing separator if necessary
+ String temp = ((workspaceArea == null) ? "" : workspaceArea);
+ if (temp.endsWith(File.separator)) {
+ this.workspaceArea = temp.substring(0, (temp.length() - 1));
+ } else {
+ this.workspaceArea = temp;
+ }
+
setUser(true); // allow user to run in background
}
@@ -184,16 +200,16 @@
// write initial message to console
if (isPublishing()) {
ModeShapeMessageConsole.writeln(RestClientI18n.publishJobPublish.text(this.jobId,
-
serverUrl,
-
repositoryName,
-
workspaceName,
-
fileCount));
+
serverUrl,
+
repositoryName,
+
workspaceName,
+
fileCount));
} else {
ModeShapeMessageConsole.writeln(RestClientI18n.publishJobUnpublish.text(this.jobId,
-
serverUrl,
-
repositoryName,
-
workspaceName,
-
fileCount));
+
serverUrl,
+
repositoryName,
+
workspaceName,
+
fileCount));
}
PublishedResourceHelper resourceHelper = new
PublishedResourceHelper(getServerManager());
@@ -206,7 +222,7 @@
}
File file = eclipseFile.getLocation().toFile();
- String path = eclipseFile.getParent().getFullPath().toString();
+ String path = this.workspaceArea +
eclipseFile.getParent().getFullPath().toString();
Status status = null;
if (isPublishing()) {
@@ -278,14 +294,14 @@
if (canceled) {
if (isPublishing()) {
ModeShapeMessageConsole.writeln(RestClientI18n.publishJobPublishCanceledMsg.text(this.jobId,
-
numProcessed,
-
this.files.size(),
-
duration));
+
numProcessed,
+
this.files.size(),
+
duration));
} else {
ModeShapeMessageConsole.writeln(RestClientI18n.publishJobUnpublishCanceledMsg.text(this.jobId,
-
numProcessed,
-
this.files.size(),
-
duration));
+
numProcessed,
+
this.files.size(),
+
duration));
}
} else {
if (isPublishing()) {
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/wizards/PublishPage.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/wizards/PublishPage.java 2010-11-16
19:36:50 UTC (rev 26638)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/wizards/PublishPage.java 2010-11-16
20:31:23 UTC (rev 26639)
@@ -41,6 +41,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.help.IWorkbenchHelpSystem;
import org.jboss.tools.modeshape.rest.Activator;
import org.jboss.tools.modeshape.rest.IServerRegistryListener;
@@ -67,10 +68,20 @@
//
===========================================================================================================================
/**
+ * The default repository workspace area where files are published.
+ */
+ private static final String DEFAULT_WORKSPACE_AREA = "/files";
+
+ /**
* The key in the wizard <code>IDialogSettings</code> for the recurse
flag.
*/
private static final String RECURSE_KEY = "recurse";
+ /**
+ * The key in the wizard <code>IDialogSettings</code> for the workspace
area path segment.
+ */
+ private static final String WORKSPACE_AREA_KEY = "workspaceArea";
+
//
===========================================================================================================================
// Class Fields
//
===========================================================================================================================
@@ -289,9 +300,9 @@
private org.eclipse.swt.widgets.List lstResources;
/**
- * The flag indicating if child containers should be traversed.
+ * Indicates if resources should be found recursively.
*/
- private boolean recurse;
+ private boolean recurse = true;
/**
* A collection of repositories for the selected server (never
<code>null</code>).
@@ -334,6 +345,11 @@
private Workspace workspace;
/**
+ * The path segment prepended to the resource project path.
+ */
+ private String workspaceArea;
+
+ /**
* A collection of workspaces for the selected server repository (never
<code>null</code>).
*/
private List<Workspace> workspaces;
@@ -375,6 +391,7 @@
// row 1: label combobox button
// row 2: label combobox
// row 3: label combobox
+ // row 4: label textbox
{ // row 1: server row
Composite pnlServer = new Composite(pnl, SWT.NONE);
@@ -450,6 +467,32 @@
this.cbxWorkspace.setToolTipText(RestClientI18n.publishPageWorkspaceUnpublishToolTip.text());
}
}
+
+ { // row 4: workspace area
+ Label lblWorkspaceArea = new Label(pnl, SWT.LEFT);
+ lblWorkspaceArea.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false,
false));
+
lblWorkspaceArea.setText(RestClientI18n.publishPageWorkspaceAreaLabel.text());
+
+ Text txtWorkspaceArea = new Text(pnl, SWT.BORDER);
+ txtWorkspaceArea.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
false));
+
txtWorkspaceArea.setToolTipText(RestClientI18n.publishPageWorkspaceAreaToolTip.text());
+ txtWorkspaceArea.addModifyListener(new ModifyListener() {
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ @Override
+ public void modifyText( ModifyEvent e ) {
+ handleWorkspaceAreaModified(((Text)e.widget).getText());
+ }
+ });
+
+ // set the workspace area from the dialog settings
+ String temp = getDialogSettings().get(WORKSPACE_AREA_KEY);
+ this.workspaceArea = ((temp == null) ? DEFAULT_WORKSPACE_AREA : temp);
+ txtWorkspaceArea.setText(this.workspaceArea);
+ }
}
private void constructResourcesPanel( Composite parent ) {
@@ -500,10 +543,16 @@
}
{ // row 3
- final Button chkRecurse = new Button(pnl, SWT.CHECK);
+ Button chkRecurse = new Button(pnl, SWT.CHECK);
chkRecurse.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
chkRecurse.setText(RestClientI18n.publishPageRecurseCheckBox.text());
chkRecurse.setToolTipText(RestClientI18n.publishPageRecurseCheckBoxToolTip.text());
+
+ // set the recurse flag based on dialog settings
+ if (getDialogSettings().get(RECURSE_KEY) != null) {
+ this.recurse = getDialogSettings().getBoolean(RECURSE_KEY);
+ }
+
chkRecurse.setSelection(this.recurse);
chkRecurse.addSelectionListener(new SelectionAdapter() {
/**
@@ -513,7 +562,7 @@
*/
@Override
public void widgetSelected( SelectionEvent e ) {
- handleRecurseChanged(chkRecurse.getSelection());
+ handleRecurseChanged(((Button)e.widget).getSelection());
}
});
@@ -527,7 +576,7 @@
@Override
public void widgetSelected( SelectionEvent e ) {
updateInitialMessage();
- chkRecurse.removeSelectionListener(this);
+ ((Button)e.widget).removeSelectionListener(this);
}
});
}
@@ -574,23 +623,11 @@
/**
* @return the files to publish or unpublish (never <code>null</code>)
*/
- public List<IFile> getFiles() {
+ List<IFile> getFiles() {
return this.files;
}
/**
- * Updates the initial page message.
- */
- void updateInitialMessage() {
- String msg = ((this.type == Type.PUBLISH) ?
RestClientI18n.publishPagePublishOkStatusMsg.text()
- :
RestClientI18n.publishPageUnpublishOkStatusMsg.text());
-
- if (msg.equals(getMessage())) {
- updateState();
- }
- }
-
- /**
* @return the server manager obtained from the wizard
*/
private ServerManager getServerManager() {
@@ -600,19 +637,25 @@
/**
* @return thw workspace to use when publishing or unpublishing (page must be
complete)
*/
- public Workspace getWorkspace() {
+ Workspace getWorkspace() {
assert isPageComplete();
return this.workspace;
}
/**
+ * @return the path segment prepended to the resource project path (never
<code>null</code> but can be empty)
+ */
+ String getWorkspaceArea() {
+ return this.workspaceArea;
+ }
+
+ /**
* Saves the recurse setting and reloads the files to be published or unpublished.
*
* @param selected the flag indicating the new recurse setting
*/
void handleRecurseChanged( boolean selected ) {
this.recurse = selected;
- saveRecurseSetting();
try {
this.files = processResources(this.resources, isRecursing(), filter);
@@ -665,8 +708,17 @@
}
/**
- * Handler for when the workspace control value is modified
+ * Handler for when the workspace area value is modified.
+ *
+ * @param workspaceArea the new workspace area (never <code>null</code>)
*/
+ void handleWorkspaceAreaModified( String workspaceArea ) {
+ this.workspaceArea = workspaceArea.trim();
+ }
+
+ /**
+ * Handler for when the workspace control value is modified.
+ */
void handleWorkspaceModified() {
int index = this.cbxWorkspace.getSelectionIndex();
@@ -679,17 +731,10 @@
}
/**
- * @return the flag indicating if resources found recursively under projects and
folders should also be published or
- * unpublished
+ * @return <code>true</code> if resources found recursively under
projects and folders should also be published or unpublished
*/
- protected boolean isRecursing() {
- boolean recurse = true;
-
- if (getDialogSettings().get(RECURSE_KEY) != null) {
- recurse = getDialogSettings().getBoolean(RECURSE_KEY);
- }
-
- return recurse;
+ boolean isRecursing() {
+ return this.recurse;
}
/**
@@ -874,15 +919,8 @@
}
/**
- * Saves the current recurse value to the wizard
<code>IDialogSettings</code>.
- */
- protected void saveRecurseSetting() {
- getDialogSettings().put(RECURSE_KEY, this.recurse);
- }
-
- /**
* {@inheritDoc}
- *
+ *
* @see
org.jboss.tools.modeshape.rest.IServerRegistryListener#serverRegistryChanged(org.jboss.tools.modeshape.rest.ServerRegistryEvent)
*/
@Override
@@ -932,17 +970,26 @@
public void setWizard( IWizard newWizard ) {
super.setWizard(newWizard);
- // need to make sure the wizard has been set on the page since the recurse value
is saved in the wizard dialog settings
- this.recurse = isRecursing();
-
try {
- this.files = processResources(this.resources, this.recurse, this.filter);
+ this.files = processResources(this.resources, isRecursing(), this.filter);
} catch (CoreException e) {
Activator.getDefault().log(new Status(Severity.ERROR,
RestClientI18n.publishPageRecurseProcessingErrorMsg.text(), e));
}
}
/**
+ * Updates the initial page message.
+ */
+ void updateInitialMessage() {
+ String msg = ((this.type == Type.PUBLISH) ?
RestClientI18n.publishPagePublishOkStatusMsg.text()
+ :
RestClientI18n.publishPageUnpublishOkStatusMsg.text());
+
+ if (msg.equals(getMessage())) {
+ updateState();
+ }
+ }
+
+ /**
* Updates message, message icon, and OK button enablement based on validation
results
*/
void updateState() {
@@ -997,4 +1044,13 @@
this.status = new Status(severity, msg, null);
}
+ /**
+ * Processing done after wizard is finished. Wizard was not canceled.
+ */
+ void wizardFinished() {
+ // update dialog settings
+ getDialogSettings().put(RECURSE_KEY, this.recurse);
+ getDialogSettings().put(WORKSPACE_AREA_KEY, this.workspaceArea);
+ }
+
}
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/wizards/PublishWizard.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/wizards/PublishWizard.java 2010-11-16
19:36:50 UTC (rev 26638)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/wizards/PublishWizard.java 2010-11-16
20:31:23 UTC (rev 26639)
@@ -24,6 +24,8 @@
import org.jboss.tools.modeshape.rest.jobs.PublishJob;
import org.jboss.tools.modeshape.rest.jobs.PublishJob.Type;
import org.modeshape.common.util.CheckArg;
+import org.modeshape.web.jcr.rest.client.Status;
+import org.modeshape.web.jcr.rest.client.Status.Severity;
import org.modeshape.web.jcr.rest.client.domain.Workspace;
/**
@@ -127,9 +129,19 @@
*/
@Override
public boolean performFinish() {
+ // let page know that wizard finished and was not canceled
+ try {
+ this.page.wizardFinished();
+ } catch (Exception e) {
+ // don't let this error stop the publishing operation
+ Activator.getDefault().log(new Status(Severity.ERROR,
RestClientI18n.publishPageFinishedErrorMsg.text(), e));
+ }
+
+ // run publish job
Workspace workspace = this.page.getWorkspace();
List<IFile> files = this.page.getFiles();
- PublishJob job = new PublishJob(this.type, files, workspace);
+ String workspaceArea = this.page.getWorkspaceArea();
+ PublishJob job = new PublishJob(this.type, files, workspace, workspaceArea);
job.schedule();
return true;