Author: rob.stryker(a)jboss.com
Date: 2008-01-29 20:59:22 -0500 (Tue, 29 Jan 2008)
New Revision: 6021
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/ArchivePublishWizard.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/EditPublishAction.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/PublishAction.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
Log:
JBIDE-1404 - implementation
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/ArchivePublishWizard.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/ArchivePublishWizard.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/ArchivePublishWizard.java 2008-01-30
01:59:22 UTC (rev 6021)
@@ -0,0 +1,214 @@
+package org.jboss.ide.eclipse.as.ui.packages;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.as.core.modules.ArchivesBuildListener;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+
+public class ArchivePublishWizard extends Wizard {
+
+ private ArchivePublishWizardPage page;
+ private IArchive pack;
+ public ArchivePublishWizard(IArchive pack) {
+ this.pack = pack;
+ }
+ public boolean performFinish() {
+ if( new Boolean(page.getAlwaysPublish()).booleanValue() ) {
+ pack.setProperty(ArchivesBuildListener.DEPLOY_SERVERS, getServers());
+ pack.setProperty(ArchivesBuildListener.DEPLOY_AFTER_BUILD, getAutoDeploy());
+ IPath p = pack.getProjectPath();
+ ArchivesModel.instance().saveModel(p, null);
+ }
+ return true;
+ }
+ public void addPages() {
+ page = new ArchivePublishWizardPage(pack);
+ addPage(page);
+ }
+
+ protected String getServers() {
+ return page.getServers();
+ }
+ protected String getAutoDeploy() {
+ return page.getAutoDeploy();
+ }
+ protected String getAlwaysPublish() {
+ return page.getAlwaysPublish();
+ }
+
+
+ public class ArchivePublishWizardPage extends WizardPage {
+ protected IArchive pack;
+ protected ListViewer viewer;
+ protected Button autoDeploy, alwaysPublish;
+ protected String viewerResult = "";
+ protected String deployResult = Boolean.toString(false);
+ protected String alwaysPublishResult = Boolean.toString(false);
+
+ protected ArchivePublishWizardPage(IArchive pack) {
+ super("Select Server Wizard");
+ setDescription("Select the server to publish the archive to.");
+ setTitle("Publish archive to a server");
+ this.pack = pack;
+ }
+
+ public void createControl(Composite parent) {
+ Composite mainComposite = new Composite(parent, SWT.NONE);
+ mainComposite.setLayout(new FormLayout());
+ mainComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ fillComposite(mainComposite);
+ addListeners();
+ setControl(mainComposite);
+ getContainer().updateTitleBar();
+ setPackageDefaults();
+ }
+
+ protected void setPackageDefaults() {
+ String servers = pack.getProperty(ArchivesBuildListener.DEPLOY_SERVERS);
+ viewerResult = servers;
+ String deployAfterBuild = pack.getProperty(ArchivesBuildListener.DEPLOY_AFTER_BUILD);
+ if( servers != null ) {
+ alwaysPublish.setSelection(true);
+ alwaysPublishSelected();
+ boolean depAfterBld = !(deployAfterBuild == null || new
Boolean(deployAfterBuild).booleanValue() == false);
+ autoDeploy.setSelection(depAfterBld);
+ autoDeploySelected();
+
+ IDeployableServer[] depServers = ServerConverter.getAllDeployableServers();
+ String[] serverList = servers.split(",");
+ final ArrayList selected = new ArrayList();
+ for(int i = 0; i < serverList.length; i++ ) {
+ for( int j = 0; j < depServers.length; j++ ) {
+ if( serverList[i].equals(depServers[j].getServer().getId()))
+ selected.add(depServers[j]);
+ }
+ }
+ viewer.setSelection(new StructuredSelection(selected.toArray()));
+ }
+ }
+
+ protected void fillComposite(Composite mainComposite) {
+ viewer = new ListViewer(mainComposite);
+ FormData viewerData = new FormData();
+ viewerData.left = new FormAttachment(15,0);
+ viewerData.right = new FormAttachment(85,0);
+ viewerData.top = new FormAttachment(0,10);
+ viewerData.bottom = new FormAttachment(80,0);
+ viewer.getList().setLayoutData(viewerData);
+
+ this.alwaysPublish = new Button(mainComposite, SWT.CHECK);
+ FormData always = new FormData();
+ always.left = new FormAttachment(15,0);
+ always.top = new FormAttachment(viewer.getList(), 5);
+ alwaysPublish.setLayoutData(always);
+ alwaysPublish.setText("Always publish to these servers");
+
+ autoDeploy = new Button(mainComposite, SWT.CHECK);
+ FormData add = new FormData();
+ add.left = new FormAttachment(15,0);
+ add.top = new FormAttachment(alwaysPublish, 5);
+ autoDeploy.setLayoutData(add);
+ autoDeploy.setText("Auto-deploy to selected servers after builds");
+ }
+
+ protected void addListeners() {
+ autoDeploy.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ public void widgetSelected(SelectionEvent e) {
+ autoDeploySelected();
+ }
+ });
+ viewer.addPostSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ viewerSelected();
+ }
+ } );
+
+ alwaysPublish.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ public void widgetSelected(SelectionEvent e) {
+ alwaysPublishSelected();
+ }
+ });
+
+ viewer.setContentProvider(new ArrayContentProvider());
+ viewer.setLabelProvider(new ArchivePublishLabelProvider());
+ viewer.setInput(ServerConverter.getAllDeployableServers());
+ autoDeploy.setEnabled(false);
+ }
+
+ protected void autoDeploySelected() {
+ deployResult = Boolean.toString(autoDeploy.getSelection() &&
autoDeploy.getEnabled());
+ }
+
+ protected void alwaysPublishSelected() {
+ autoDeploy.setEnabled(alwaysPublish.getSelection());
+ deployResult = Boolean.toString(autoDeploy.getSelection() &&
autoDeploy.getEnabled());
+ alwaysPublishResult = Boolean.toString(alwaysPublish.getSelection());
+ }
+
+ protected void viewerSelected() {
+ ISelection sel = viewer.getSelection();
+ if( sel instanceof IStructuredSelection ) {
+ IStructuredSelection sel2 = (IStructuredSelection)sel;
+ Object[] os = sel2.toArray();
+ String tmp = "";
+ for( int i = 0; i < os.length; i++ ) {
+ tmp += ((IDeployableServer)os[i]).getServer().getId() + ",";
+ }
+ viewerResult = tmp;
+ }
+ }
+ protected String getServers() {
+ return viewerResult;
+ }
+ protected String getAutoDeploy() {
+ return deployResult;
+ }
+ protected String getAlwaysPublish() {
+ return alwaysPublishResult;
+ }
+ }
+
+ protected class ArchivePublishLabelProvider extends LabelProvider {
+ public Image getImage(Object element) {
+ return null;
+ }
+ public String getText(Object element) {
+ if( element instanceof IDeployableServer ) {
+ return ((IDeployableServer)element).getServer().getName();
+ }
+ return element == null ? "" : element.toString();//$NON-NLS-1$
+ }
+
+ }
+}
\ No newline at end of file
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/EditPublishAction.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/EditPublishAction.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/EditPublishAction.java 2008-01-30
01:59:22 UTC (rev 6021)
@@ -0,0 +1,22 @@
+package org.jboss.ide.eclipse.as.ui.packages;
+
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+import org.jboss.ide.eclipse.archives.ui.actions.INodeActionDelegate;
+
+public class EditPublishAction implements INodeActionDelegate {
+
+ public boolean isEnabledFor(IArchiveNode node) {
+ if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE)
+ return true;
+ return false;
+ }
+
+ public void run(IArchiveNode node) {
+ ArchivePublishWizard wiz = new ArchivePublishWizard((IArchive)node);
+ new WizardDialog(new Shell(), wiz).open();
+ }
+
+}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/PublishAction.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/PublishAction.java 2008-01-29
22:48:06 UTC (rev 6020)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/PublishAction.java 2008-01-30
01:59:22 UTC (rev 6021)
@@ -21,38 +21,15 @@
*/
package org.jboss.ide.eclipse.as.ui.packages;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.ListViewer;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.ServerCore;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
import org.jboss.ide.eclipse.archives.core.model.IArchive;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
import org.jboss.ide.eclipse.archives.ui.actions.INodeActionDelegate;
import org.jboss.ide.eclipse.as.core.modules.ArchivesBuildListener;
-import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
-import org.jboss.ide.eclipse.as.core.util.ServerConverter;
public class PublishAction implements INodeActionDelegate {
@@ -65,8 +42,7 @@
&& ((IArchive)node).isTopLevel()) {
IArchive pkg = (IArchive)node;
String servers = node.getProperty(ArchivesBuildListener.DEPLOY_SERVERS);
- if( !new
Boolean(pkg.getProperty(ArchivesBuildListener.DEPLOY_AFTER_BUILD)).booleanValue() ||
- servers == null || "".equals(servers) || anyServerDoesntExist(servers)){
+ if( servers == null || "".equals(servers) ||
anyServerDoesntExist(servers)){
servers = showSelectServersDialog(pkg);
}
if( servers != null )
@@ -92,155 +68,11 @@
}
protected String showSelectServersDialog(IArchive node) {
- SelectServerWizard wiz = new SelectServerWizard(node);
+ ArchivePublishWizard wiz = new ArchivePublishWizard(node);
int result = new WizardDialog(new Shell(), wiz).open();
if( result == Window.OK) {
return wiz.getServers();
}
return null;
}
-
-
- protected class SelectServerWizard extends Wizard {
- private SelectServerWizardPage page;
- private IArchive pack;
- protected SelectServerWizard(IArchive pack) {
- this.pack = pack;
- }
- public boolean performFinish() {
- pack.setProperty(ArchivesBuildListener.DEPLOY_SERVERS, getServers());
- pack.setProperty(ArchivesBuildListener.DEPLOY_AFTER_BUILD, getAutoDeploy());
- IPath p = pack.getProjectPath();
- ArchivesModel.instance().saveModel(p, null);
- return true;
- }
- public void addPages() {
- page = new SelectServerWizardPage(pack);
- addPage(page);
- }
-
- protected String getServers() {
- return page.getServers();
- }
- protected String getAutoDeploy() {
- return page.getAutoDeploy();
- }
- protected String getAlwaysPublish() {
- return page.getAlwaysPublish();
- }
- }
-
- protected class SelectServerWizardPage extends WizardPage {
- protected IArchive pack;
- protected ListViewer viewer;
- protected Button autoDeploy, alwaysPublish;
- protected String viewerResult = "";
- protected String deployResult = Boolean.toString(false);
- protected String alwaysPublishResult = Boolean.toString(false);
-
- protected SelectServerWizardPage(IArchive pack) {
- super("Select Server Wizard");
- setDescription("Select the server to publish the archive to.");
- setTitle("Publish archive to a server");
- this.pack = pack;
- }
-
- public void createControl(Composite parent) {
- Composite mainComposite = new Composite(parent, SWT.NONE);
- mainComposite.setLayout(new FormLayout());
- mainComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- fillComposite(mainComposite);
- addListeners();
- setControl(mainComposite);
- getContainer().updateTitleBar();
- }
-
- protected void fillComposite(Composite mainComposite) {
- viewer = new ListViewer(mainComposite);
- FormData viewerData = new FormData();
- viewerData.left = new FormAttachment(15,0);
- viewerData.right = new FormAttachment(85,0);
- viewerData.top = new FormAttachment(0,10);
- viewerData.bottom = new FormAttachment(80,0);
- viewer.getList().setLayoutData(viewerData);
-
- this.alwaysPublish = new Button(mainComposite, SWT.CHECK);
- FormData always = new FormData();
- always.left = new FormAttachment(15,0);
- always.top = new FormAttachment(viewer.getList(), 5);
- alwaysPublish.setLayoutData(always);
- alwaysPublish.setText("Always publish to these servers");
-
- autoDeploy = new Button(mainComposite, SWT.CHECK);
- FormData add = new FormData();
- add.left = new FormAttachment(15,0);
- add.top = new FormAttachment(alwaysPublish, 5);
- autoDeploy.setLayoutData(add);
- autoDeploy.setText("Auto-deploy to selected servers after builds");
- }
-
- protected void addListeners() {
- autoDeploy.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
- public void widgetSelected(SelectionEvent e) {
- deployResult = Boolean.toString(autoDeploy.getSelection() &&
autoDeploy.getEnabled());
- }
- });
- viewer.addPostSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- ISelection sel = viewer.getSelection();
- if( sel instanceof IStructuredSelection ) {
- IStructuredSelection sel2 = (IStructuredSelection)sel;
- Object[] os = sel2.toArray();
- String tmp = "";
- for( int i = 0; i < os.length; i++ ) {
- tmp += ((IDeployableServer)os[i]).getServer().getId() + ",";
- }
- viewerResult = tmp;
- }
- }
- } );
-
- alwaysPublish.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
- public void widgetSelected(SelectionEvent e) {
- autoDeploy.setEnabled(alwaysPublish.getSelection());
- deployResult = Boolean.toString(autoDeploy.getSelection() &&
autoDeploy.getEnabled());
- alwaysPublishResult = Boolean.toString(alwaysPublish.getSelection());
- }
- });
-
- viewer.setContentProvider(new ArrayContentProvider());
- viewer.setLabelProvider(new PublishServerLabelProvider());
- viewer.setInput(ServerConverter.getAllDeployableServers());
- autoDeploy.setEnabled(false);
- }
-
- protected String getServers() {
- return viewerResult;
- }
- protected String getAutoDeploy() {
- return deployResult;
- }
- protected String getAlwaysPublish() {
- return alwaysPublishResult;
- }
- }
- protected class PublishServerLabelProvider extends LabelProvider {
- public Image getImage(Object element) {
- return null;
- }
- public String getText(Object element) {
- if( element instanceof IDeployableServer ) {
- return ((IDeployableServer)element).getServer().getName();
- }
- return element == null ? "" : element.toString();//$NON-NLS-1$
- }
-
- }
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2008-01-29 22:48:06 UTC (rev
6020)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml 2008-01-30 01:59:22 UTC (rev
6021)
@@ -268,9 +268,15 @@
<nodeContribution
class="org.jboss.ide.eclipse.as.ui.packages.PublishAction"
icon="icons/publish.gif"
- id="org.jboss.ide.eclipse.as.ui.nodeContextContrib"
+ id="org.jboss.ide.eclipse.as.ui.publishNodeContextContrib"
label="Publish To Server"
weight="1"/>
+ <nodeContribution
+ class="org.jboss.ide.eclipse.as.ui.packages.EditPublishAction"
+ icon="icons/publishDetails.gif"
+ id="org.jboss.ide.eclipse.as.ui.modifyPublishNodeContextContrib"
+ label="Edit publish settings...">
+ </nodeContribution>
</extension>
<extension
point="org.jboss.ide.eclipse.archives.ui.newArchiveActions">