JBoss Tools SVN: r4366 - trunk/vpe/tests.
by jbosstools-commits@lists.jboss.org
Author: svasilyev
Date: 2007-10-19 05:22:03 -0400 (Fri, 19 Oct 2007)
New Revision: 4366
Added:
trunk/vpe/tests/org.jboss.tools.vpe.xulrunner.test/
Log:
Copy xulrunner test from branch jbosstools_xulrunner
Copied: trunk/vpe/tests/org.jboss.tools.vpe.xulrunner.test (from rev 4365, branches/jbosstools_xulrunner/vpe/tests/org.jboss.tools.vpe.xulrunner.test)
17 years, 2 months
JBoss Tools SVN: r4365 - trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template.
by jbosstools-commits@lists.jboss.org
Author: ezheleznyakov
Date: 2007-10-19 05:05:10 -0400 (Fri, 19 Oct 2007)
New Revision: 4365
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-847
Code refactoring.
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java 2007-10-19 08:27:14 UTC (rev 4364)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java 2007-10-19 09:05:10 UTC (rev 4365)
@@ -22,7 +22,6 @@
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMText;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -76,6 +75,18 @@
private static final String ITEM_STYLE = "itemStyle";
+ private static final String ICON_DISABLED = "iconDisabled";
+
+ private static final String ICON = "icon";
+
+ private static final String STYLE_CLASS = "styleClass";
+
+ private static final String STYLE = "style";
+
+ private static final String DISABLED = "disabledClass";
+
+ private static final String DISABLED_STYLE = "disabledStyle";
+
public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument) {
nsIDOMElement div = visualDocument
@@ -135,6 +146,7 @@
PANEL_MENU_LABLE_CLASS);
tdLable.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
"element.style");
+
String value = sourceElement.getAttribute("label");
nsIDOMText text = visualDocument.createTextNode(value == null ? ""
: value);
@@ -160,48 +172,53 @@
if (sourceElement.getParentNode().getNodeName().endsWith(
":panelMenu")) {
- String icon = sourceElement.getAttribute("icon");
- if (icon == null || icon.length() == 0) {
- setItemImage(sourceElement, sourceParentElement, td,
- tdNowrap, ICON_ITEM_TOP_POSITION, pageContext,
- visualDocument, sourceParentElement
- .getAttribute(ICON_TOP_ITEM), imgPoints,
- imgSpacer2);
+
+ if (isDisabledItem(sourceElement.getAttribute("disabled"))) {
+ setIcon(pageContext, imgPoints, sourceElement,
+ sourceParentElement, ICON_TOP_DISABLED_ITEM,
+ ICON_DISABLED);
+ setItemClassAndStyle(table, sourceParentElement
+ .getAttribute(DISABLE_ITEM_CLASS), sourceElement
+ .getAttribute(DISABLED), DISABLED_CLASS,
+ sourceParentElement
+ .getAttribute(DISABLED_ITEM_STYLE),
+ sourceElement.getAttribute(DISABLED_STYLE));
} else {
- setItemImage(sourceElement, sourceParentElement, td,
- tdNowrap, ICON_ITEM_TOP_POSITION, pageContext,
- visualDocument, icon, imgPoints, imgSpacer2);
+ setIcon(pageContext, imgPoints, sourceElement,
+ sourceParentElement, ICON_TOP_ITEM, ICON);
+ setItemClassAndStyle(table, sourceParentElement
+ .getAttribute(TOP_ITEM_CLASS), sourceElement
+ .getAttribute(STYLE_CLASS), PANEL_MENU_ITEM_CLASS,
+ sourceParentElement.getAttribute(TOP_ITEM_STYLE),
+ sourceElement.getAttribute(STYLE));
}
+ setIconPosition(sourceParentElement
+ .getAttribute(ICON_ITEM_TOP_POSITION), td, tdNowrap,
+ imgPoints, imgSpacer2);
- setItemClassAndStyle(sourceElement, sourceParentElement,
- imgPoints, pageContext, table, sourceParentElement
- .getAttribute(TOP_ITEM_CLASS),
- sourceParentElement.getAttribute(TOP_ITEM_STYLE),
- sourceParentElement
- .getAttribute(ICON_TOP_DISABLED_ITEM));
-
} else {
- if (sourceElement.getParentNode().getNodeName().endsWith(
- ":panelMenuGroup")) {
- String icon = sourceElement.getAttribute("icon");
- if (icon == null || icon.length() == 0) {
- setItemImage(sourceElement, sourceParentElement, td,
- tdNowrap, ICON_ITEM_POSITION, pageContext,
- visualDocument, sourceParentElement
- .getAttribute(ICON_ITEM), imgPoints,
- imgSpacer2);
- } else {
- setItemImage(sourceElement, sourceParentElement, td,
- tdNowrap, ICON_ITEM_POSITION, pageContext,
- visualDocument, icon, imgPoints, imgSpacer2);
- }
+ if (isDisabledItem(sourceElement.getAttribute("disabled"))) {
+ setIcon(pageContext, imgPoints, sourceElement,
+ sourceParentElement, ICON_DISABLED_ITEM,
+ ICON_DISABLED);
+ setItemClassAndStyle(table, sourceParentElement
+ .getAttribute(DISABLE_ITEM_CLASS), sourceElement
+ .getAttribute(DISABLED), DISABLED_CLASS,
+ sourceParentElement
+ .getAttribute(DISABLED_ITEM_STYLE),
+ sourceElement.getAttribute(DISABLED_STYLE));
+ } else {
+ setIcon(pageContext, imgPoints, sourceElement,
+ sourceParentElement, ICON_ITEM, ICON);
+ setItemClassAndStyle(table, sourceParentElement
+ .getAttribute(ITEM_CLASS), sourceElement
+ .getAttribute(STYLE_CLASS), PANEL_MENU_ITEM_CLASS,
+ sourceParentElement.getAttribute(ITEM_STYLE),
+ sourceElement.getAttribute(STYLE));
}
-
- setItemClassAndStyle(sourceElement, sourceParentElement,
- imgPoints, pageContext, table, sourceParentElement
- .getAttribute(ITEM_CLASS), sourceParentElement
- .getAttribute(ITEM_STYLE), sourceParentElement
- .getAttribute(ICON_DISABLED_ITEM));
+ setIconPosition(sourceParentElement
+ .getAttribute(ICON_ITEM_POSITION), td, tdNowrap,
+ imgPoints, imgSpacer2);
}
List<Node> children = ComponentUtil.getChildren(sourceElement);
@@ -221,8 +238,8 @@
}
public boolean isRecreateAtAttrChange(VpePageContext pageContext,
- Element sourceElement, Document visualDocument, Node visualNode,
- Object data, String name, String value) {
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMElement visualNode, Object data, String name, String value) {
return true;
}
@@ -235,114 +252,77 @@
DEFAULT_SIZE_VALUE);
}
- private static void setImagePosition(nsIDOMElement place,
- nsIDOMElement image, VpePageContext pageContext, String icon) {
+ private static void setItemImage(nsIDOMElement place, nsIDOMElement image) {
place.appendChild(image);
setDefaultImgAttributes(image);
+ }
+
+ private static boolean isDisabledItem(String disabled) {
+ if ("true".equals(disabled)) {
+ return true;
+ }
+ return false;
+ }
+
+ private static void setIcon(VpePageContext pageContext,
+ nsIDOMElement imgPoints, Element sourceElement,
+ Element parentElement, String parentIconAttribute,
+ String iconAttribute) {
+ String icon = sourceElement.getAttribute(iconAttribute);
+ String parentIcon = parentElement.getAttribute(parentIconAttribute);
if (icon == null || icon.length() == 0) {
- ComponentUtil.setImg(image, IMG_POINTS_SRC);
+ if (!(parentIcon == null || parentIcon.length() == 0)) {
+ ComponentUtil.setImgFromResources(pageContext, imgPoints,
+ parentIcon, IMG_SPACER_SRC);
+ } else {
+ ComponentUtil.setImg(imgPoints, IMG_POINTS_SRC);
+ }
} else {
- ComponentUtil.setImgFromResources(pageContext, image, icon,
+ ComponentUtil.setImgFromResources(pageContext, imgPoints, icon,
IMG_SPACER_SRC);
}
}
- private static void setItemImage(Element sourceElement,
- Element sourceParentElement, nsIDOMElement td,
- nsIDOMElement tdNowrap, String attribute,
- VpePageContext pageContext, nsIDOMDocument visualDocument,
- String image, nsIDOMElement imgPoints, nsIDOMElement imgSpacer2) {
- String iconPosition = sourceParentElement.getAttribute(attribute);
+ private static void setIconPosition(String iconPosition,
+ nsIDOMElement right, nsIDOMElement left, nsIDOMElement imgPoints,
+ nsIDOMElement imgSpacer2) {
if (!(iconPosition == null)) {
if (iconPosition.equals("right")) {
-
- setImagePosition(td, imgPoints, pageContext, image);
-
+ setItemImage(right, imgPoints);
} else {
- td.appendChild(imgSpacer2);
- setDefaultImgAttributes(imgSpacer2);
+ setItemImage(right, imgSpacer2);
ComponentUtil.setImg(imgSpacer2, IMG_SPACER_SRC);
if (iconPosition.equals("left")) {
- setImagePosition(tdNowrap, imgPoints, pageContext, image);
+ setItemImage(left, imgPoints);
}
}
} else {
- setImagePosition(tdNowrap, imgPoints, pageContext, image);
- td.appendChild(imgSpacer2);
- setDefaultImgAttributes(imgSpacer2);
+ setItemImage(left, imgPoints);
+ setItemImage(right, imgSpacer2);
ComponentUtil.setImg(imgSpacer2, IMG_SPACER_SRC);
}
}
- private static void setItemClassAndStyle(Element sourceElement,
- Element sourceParentElement, nsIDOMElement imgPoints,
- VpePageContext pageContext, nsIDOMElement table,
- String parentClass, String parentStyle, String icon) {
+ private static void setItemClassAndStyle(nsIDOMElement table,
+ String parentClass, String itemClass, String defaultClass,
+ String parentStyle, String itemStyle) {
+ String resultClass = "";
+ if (!(parentClass == null || parentClass.length() == 0)) {
+ resultClass += parentClass;
+ }
+ if (!(itemClass == null || itemClass.length() == 0)) {
+ resultClass += itemClass;
+ }
+ table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, defaultClass
+ + " " + resultClass);
- if ("true".equals(sourceElement.getAttribute("disabled"))) {
-
- String iconDisabled = sourceElement.getAttribute("iconDisabled");
- if (iconDisabled == null || iconDisabled.length() == 0) {
- if (!(icon == null || icon.length() == 0)) {
- ComponentUtil.setImgFromResources(pageContext, imgPoints,
- icon, IMG_POINTS_SRC);
- } else {
- ComponentUtil.setImg(imgPoints, IMG_POINTS_SRC);
- }
- } else {
- ComponentUtil.setImgFromResources(pageContext, imgPoints,
- iconDisabled, IMG_SPACER_SRC);
- }
-
- String resultDisabledClass = "";
- String disabledItemClass = sourceParentElement
- .getAttribute(DISABLE_ITEM_CLASS);
- if (!(disabledItemClass == null || disabledItemClass.length() == 0)) {
- resultDisabledClass += disabledItemClass;
- }
- String disabledClass = sourceElement.getAttribute("disabledClass");
- if (!(disabledClass == null || disabledClass.length() == 0)) {
- resultDisabledClass += disabledClass;
- }
- table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
- DISABLED_CLASS + " " + resultDisabledClass);
-
- String resultDisabledStyle = "";
- String disabledItemStyle = sourceParentElement
- .getAttribute(DISABLED_ITEM_STYLE);
- if (!(disabledItemStyle == null || disabledItemStyle.length() == 0)) {
- resultDisabledStyle += disabledItemStyle;
- }
- String disabledStyle = sourceElement.getAttribute("disabledStyle");
- if (!(disabledStyle == null || disabledStyle.length() == 0)) {
- resultDisabledStyle += disabledStyle;
- }
- table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
- resultDisabledStyle);
-
- } else {
- String resultClass = "";
- String itemClass = parentClass;
- if (!(itemClass == null || itemClass.length() == 0)) {
- resultClass += itemClass;
- }
- String styleClass = sourceElement.getAttribute("styleClass");
- if (!(styleClass == null || styleClass.length() == 0)) {
- resultClass += styleClass;
- }
- table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
- PANEL_MENU_ITEM_CLASS + " " + resultClass);
-
- String resultStyle = "";
- String itemStyle = parentStyle;
- if (!(itemStyle == null || itemStyle.length() == 0)) {
- resultStyle += itemStyle;
- }
- String style = sourceElement.getAttribute("style");
- if (!(style == null || style.length() == 0)) {
- resultStyle += style;
- }
- table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, resultStyle);
+ String resultStyle = "";
+ if (!(parentStyle == null || parentStyle.length() == 0)) {
+ resultStyle += parentStyle;
}
+ if (!(itemStyle == null || itemStyle.length() == 0)) {
+ resultStyle += itemStyle;
+ }
+ table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, resultStyle);
}
}
\ No newline at end of file
17 years, 2 months
JBoss Tools SVN: r4364 - trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2007-10-19 04:27:14 -0400 (Fri, 19 Oct 2007)
New Revision: 4364
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
Log:
code adjustment
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2007-10-19 08:12:37 UTC (rev 4363)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2007-10-19 08:27:14 UTC (rev 4364)
@@ -750,13 +750,13 @@
//we shouldn't change selection when we click on <input type="text" /> element,
//because if we change after resizing the input element lost selection
- if(HTML.TAG_INPUT.equalsIgnoreCase(visualDragElement.getNodeName())&&
- !HTML.ATTR_TEXT.equalsIgnoreCase(visualDragElement.getAttribute(HTML.ATTR_TYPE))
- &&visualDragElement.getAttribute(HTML.ATTR_TYPE)!=null) {
+ if(!(HTML.TAG_INPUT.equalsIgnoreCase(visualDragElement.getNodeName())&&
+ HTML.ATTR_TEXT.equalsIgnoreCase(visualDragElement.getAttribute(HTML.ATTR_TYPE))
+ &&visualDragElement.getAttribute(HTML.ATTR_TYPE)!=null)) {
- selectionBuilder.setVisualElementSelection(visualDragElement);
- }
- mouseDownSelectionFlag = true;
+ selectionBuilder.setVisualElementSelection(visualDragElement);
+ mouseDownSelectionFlag = true;
+ }
} else {
selectionBuilder.setCaretAtMouse(mouseEvent);
}
17 years, 2 months
JBoss Tools SVN: r4363 - trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2007-10-19 04:12:37 -0400 (Fri, 19 Oct 2007)
New Revision: 4363
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java
Log:
http://jira.jboss.org/jira/browse/JBIDE-1120
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java 2007-10-19 07:44:53 UTC (rev 4362)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java 2007-10-19 08:12:37 UTC (rev 4363)
@@ -174,7 +174,8 @@
public static AntCopyUtils.FileSet JBOOS_EJB_WEB_INF_CLASSES_SET = new AntCopyUtils.FileSet()
.include("import\\.sql") //$NON-NLS-1$
- .include("seam\\.properties"); //$NON-NLS-1$
+ .include("seam\\.properties")
+ .exclude(".*/WEB-INF"); //$NON-NLS-1$
public static AntCopyUtils.FileSet JBOSS_EAR_META_INF_SET = new AntCopyUtils.FileSet()
.include("META-INF/jboss-app\\.xml"); //$NON-NLS-1$
17 years, 2 months
JBoss Tools SVN: r4362 - in trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui: editor and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2007-10-19 03:44:53 -0400 (Fri, 19 Oct 2007)
New Revision: 4362
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/editor/DeploySection.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossServerWizardFragment.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/StrippedServerWizardFragment.java
Log:
JBIDE-1118, JBIDE-1047
Fixed issue with designating a non-existant folder as a deploy folder
Provided user with a UI to set the temporary deploy folder to one on the same filesystem as the actual deploy folder.
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 2007-10-19 07:24:33 UTC (rev 4361)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.java 2007-10-19 07:44:53 UTC (rev 4362)
@@ -53,7 +53,10 @@
public static String swf_Password;
public static String swf_BaseName;
public static String swf_NameInUse;
- public static String sswf_DeployDirectory;
+ public static String swf_DeployEditorHeading;
+ public static String swf_DeploymentDescription;
+ public static String swf_DeployDirectory;
+ public static String swf_TempDeployDirectory;
public static String sswf_Title;
public static String sswf_BaseName;
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 2007-10-19 07:24:33 UTC (rev 4361)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/Messages.properties 2007-10-19 07:44:53 UTC (rev 4362)
@@ -25,7 +25,10 @@
swf_BaseName=JBoss _VERSION_ Server
swf_NameInUse=Server name already in use
swf_DeployGroup=Deployment
-sswf_DeployDirectory=Deploy Directory
+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_DeployDirectory=Deploy Directory
+swf_TempDeployDirectory=Temporary Deploy Directory
sswf_Title=Create a new System Copy Server
sswf_BaseName=Local Deployer
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploySection.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploySection.java 2007-10-19 07:24:33 UTC (rev 4361)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/editor/DeploySection.java 2007-10-19 07:44:53 UTC (rev 4362)
@@ -35,7 +35,6 @@
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
@@ -43,9 +42,11 @@
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.core.internal.ServerPlugin;
import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
import org.eclipse.wst.server.ui.editor.ServerEditorSection;
import org.eclipse.wst.server.ui.internal.command.ServerCommand;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.internal.DeployableServer;
import org.jboss.ide.eclipse.as.ui.Messages;
@@ -71,14 +72,16 @@
FormToolkit toolkit = new FormToolkit(parent.getDisplay());
Section section = toolkit.createSection(parent, ExpandableComposite.TWISTIE|ExpandableComposite.EXPANDED|ExpandableComposite.TITLE_BAR);
- section.setText(Messages.sswf_DeployDirectory);
+ section.setText(Messages.swf_DeployEditorHeading);
section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));
Composite composite = toolkit.createComposite(section);
composite.setLayout(new FormLayout());
- Label label = toolkit.createLabel(composite, Messages.sswf_DeployDirectory);
+ Label descriptionLabel = toolkit.createLabel(composite, Messages.swf_DeploymentDescription);
+
+ Label label = toolkit.createLabel(composite, Messages.swf_DeployDirectory);
final Text text = toolkit.createText(composite, getDeployDir(), SWT.BORDER);
text.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
@@ -98,34 +101,91 @@
text.setText(x);
}
});
+
+ Label tempDeployLabel = toolkit.createLabel(composite, Messages.swf_TempDeployDirectory);
+ final Text tempDeployText = toolkit.createText(composite, getTempDeployDir(), SWT.BORDER);
+ tempDeployText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ execute(new SetTempDeployDirCommand(server, tempDeployText, tempDeployText.getText()));
+ }
+ });
+ Button tempDeployButton = toolkit.createButton(composite, Messages.browse, SWT.PUSH);
+ tempDeployButton.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ public void widgetSelected(SelectionEvent e) {
+ DirectoryDialog d = new DirectoryDialog(new Shell());
+ d.setFilterPath(tempDeployText.getText());
+ String x = d.open();
+ if( x != null )
+ tempDeployText.setText(x);
+ }
+ });
+
+ FormData descriptionLabelData = new FormData();
+ descriptionLabelData.left = new FormAttachment(0,5);
+ descriptionLabelData.top = new FormAttachment(0,5);
+ descriptionLabel.setLayoutData(descriptionLabelData);
+
+ // first row
FormData labelData = new FormData();
labelData.left = new FormAttachment(0,5);
- labelData.top = new FormAttachment(0,5);
+ labelData.top = new FormAttachment(descriptionLabel,5);
label.setLayoutData(labelData);
FormData textData = new FormData();
textData.left = new FormAttachment(label, 5);
- textData.top = new FormAttachment(0,5);
- textData.right = new FormAttachment(button,-5);
+ textData.top = new FormAttachment(descriptionLabel,5);
+ textData.right = new FormAttachment(0,300);
text.setLayoutData(textData);
FormData buttonData = new FormData();
buttonData.right = new FormAttachment(100,-5);
- buttonData.top = new FormAttachment(0,5);
+ buttonData.top = new FormAttachment(descriptionLabel,5);
button.setLayoutData(buttonData);
+
+ // second row
+ FormData tempLabelData = new FormData();
+ tempLabelData.left = new FormAttachment(0,5);
+ tempLabelData.top = new FormAttachment(text,5);
+ tempDeployLabel.setLayoutData(tempLabelData);
+
+ FormData tempTextData = new FormData();
+ tempTextData.left = new FormAttachment(tempDeployLabel, 5);
+ tempTextData.top = new FormAttachment(text,5);
+ tempTextData.right = new FormAttachment(0, 300);
+ tempDeployText.setLayoutData(tempTextData);
+
+ FormData tempButtonData = new FormData();
+ tempButtonData.right = new FormAttachment(100,-5);
+ tempButtonData.top = new FormAttachment(text,5);
+ tempDeployButton.setLayoutData(tempButtonData);
+
+
+ text.setEditable(false);
+ tempDeployText.setEditable(false);
+
toolkit.paintBordersFor(composite);
section.setClient(composite);
}
private String getDeployDir() {
if( server instanceof ServerWorkingCopy ) {
- return ((ServerWorkingCopy)server).getAttribute(DeployableServer.DEPLOY_DIRECTORY, "");
+ return ((ServerWorkingCopy)server).getAttribute(IDeployableServer.DEPLOY_DIRECTORY, "");
}
return "";
}
+ private String getTempDeployDir() {
+ if( server instanceof ServerWorkingCopy ) {
+ return ((ServerWorkingCopy)server).getAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY,
+ ServerPlugin.getInstance().getStateLocation().toFile().getAbsolutePath());
+ }
+ return "";
+ }
+
public static class SetDeployDirCommand extends ServerCommand {
@@ -150,7 +210,30 @@
text.setText(oldDir);
}
}
-
+
+ public static class SetTempDeployDirCommand extends ServerCommand {
+ private String oldDir;
+ private String newDir;
+ private Text text;
+ public SetTempDeployDirCommand(IServerWorkingCopy wc, Text text, String newDir) {
+ super(wc, "SetDeployDirCommand");
+ this.text = text;
+ this.newDir = newDir;
+ if( wc instanceof ServerWorkingCopy ) {
+ this.oldDir = ((ServerWorkingCopy)wc).getAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY, "");
+ }
+ }
+ public void execute() {
+ if( server instanceof ServerWorkingCopy )
+ ((ServerWorkingCopy)server).setAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY, newDir);
+ }
+ public void undo() {
+ if( server instanceof ServerWorkingCopy )
+ ((ServerWorkingCopy)server).setAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY, oldDir);
+ text.setText(oldDir);
+ }
+ }
+
public void dispose() {
// ignore
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossServerWizardFragment.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossServerWizardFragment.java 2007-10-19 07:24:33 UTC (rev 4361)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossServerWizardFragment.java 2007-10-19 07:44:53 UTC (rev 4362)
@@ -284,7 +284,7 @@
deployGroup.setLayout(new GridLayout(3, false));
deployLabel = new Label(deployGroup, SWT.NONE);
deployText = new Text(deployGroup, SWT.BORDER);
- deployLabel.setText(Messages.sswf_DeployDirectory);
+ deployLabel.setText(Messages.swf_DeployDirectory);
deployBrowseButton = new Button(deployGroup, SWT.PUSH);
deployBrowseButton.setText(Messages.browse);
@@ -307,11 +307,7 @@
}
});
- deployText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- deployVal = deployText.getText();
- }
- });
+ deployText.setEditable(false);
}
protected File getDirectory(File startingDirectory, Shell shell) {
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/StrippedServerWizardFragment.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/StrippedServerWizardFragment.java 2007-10-19 07:24:33 UTC (rev 4361)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/StrippedServerWizardFragment.java 2007-10-19 07:44:53 UTC (rev 4362)
@@ -83,7 +83,7 @@
deployLabel = new Label(main, SWT.NONE);
deployText = new Text(main, SWT.BORDER);
browse = new Button(main, SWT.PUSH);
- deployLabel.setText(Messages.sswf_DeployDirectory);
+ deployLabel.setText(Messages.swf_DeployDirectory);
browse.setText(Messages.browse);
FormData lData = new FormData();
17 years, 2 months
JBoss Tools SVN: r4361 - trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2007-10-19 03:24:33 -0400 (Fri, 19 Oct 2007)
New Revision: 4361
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/PropertyEditorDialog.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-727
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/PropertyEditorDialog.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/PropertyEditorDialog.java 2007-10-19 07:18:47 UTC (rev 4360)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/PropertyEditorDialog.java 2007-10-19 07:24:33 UTC (rev 4361)
@@ -125,14 +125,4 @@
}
}
-
- public void create() {
- super.create();
- Point p = getShell().getSize();
- if(p.y > 400) {
- p.y = 400;
- getShell().setSize(p);
- }
- }
-
}
17 years, 2 months
JBoss Tools SVN: r4360 - trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2007-10-19 03:18:47 -0400 (Fri, 19 Oct 2007)
New Revision: 4360
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/ServerViewProvider.java
Log:
View Provider failing bc of no icon? INCONCEIVABLE!
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/ServerViewProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/ServerViewProvider.java 2007-10-19 05:32:39 UTC (rev 4359)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/extensions/ServerViewProvider.java 2007-10-19 07:18:47 UTC (rev 4360)
@@ -48,8 +48,11 @@
setWeight( prefs.contains(weightKey) ? prefs.getInt(weightKey) : 0 );
Bundle pluginBundle = JBossServerUIPlugin.getDefault().getBundle();
- iconDescriptor =
- ImageDescriptor.createFromURL(pluginBundle.getEntry(getIconLocation()));
+ String iconLoc = getIconLocation();
+ if( iconLoc != null ) {
+ iconDescriptor =
+ ImageDescriptor.createFromURL(pluginBundle.getEntry(iconLoc));
+ }
}
public String getId() {
17 years, 2 months
JBoss Tools SVN: r4359 - trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2007-10-19 01:32:39 -0400 (Fri, 19 Oct 2007)
New Revision: 4359
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java
Log:
JBIDE-1047
Forked PublishUtil
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java 2007-10-19 05:31:19 UTC (rev 4358)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/JstPublisher.java 2007-10-19 05:32:39 UTC (rev 4359)
@@ -42,7 +42,6 @@
import org.eclipse.wst.server.core.model.ModuleDelegate;
import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
import org.eclipse.wst.server.core.util.ProjectModule;
-import org.eclipse.wst.server.core.util.PublishUtil;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel;
import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
@@ -50,6 +49,7 @@
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
import org.jboss.ide.eclipse.as.core.server.xpl.ModulePackager;
+import org.jboss.ide.eclipse.as.core.server.xpl.PublishUtil;
import org.jboss.ide.eclipse.as.core.util.FileUtil;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
import org.jboss.ide.eclipse.as.core.util.FileUtil.IFileUtilListener;
@@ -125,7 +125,7 @@
localSafeDelete(deployPath, eventRoot);
IStatus[] results = new IStatus[0];
if( !deployPackaged(moduleTree))
- results = PublishUtil.publishFull(members, deployPath, monitor);
+ results = new PublishUtil(server.getServer()).publishFull(members, deployPath, monitor);
else
results = packModuleIntoJar(moduleTree[moduleTree.length-1], getDeployPath(moduleTree));
@@ -150,7 +150,7 @@
protected IStatus incrementalPublish(IModule[] moduleTree, IModule module, IProgressMonitor monitor) throws CoreException {
IStatus[] results = new IStatus[] {};
if( !deployPackaged(moduleTree))
- results = PublishUtil.publishDelta(delta, getDeployPath(moduleTree), monitor);
+ results = new PublishUtil(server.getServer()).publishDelta(delta, getDeployPath(moduleTree), monitor);
else if( delta.length > 0 )
results = packModuleIntoJar(moduleTree[moduleTree.length-1], getDeployPath(moduleTree));
17 years, 2 months
JBoss Tools SVN: r4358 - trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2007-10-19 01:31:19 -0400 (Fri, 19 Oct 2007)
New Revision: 4358
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishUtil.java
Log:
JBIDE-1047
Forked PublishUtil
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishUtil.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishUtil.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishUtil.java 2007-10-19 05:31:19 UTC (rev 4358)
@@ -0,0 +1,780 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.jboss.ide.eclipse.as.core.server.xpl;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.internal.Messages;
+import org.eclipse.wst.server.core.internal.ProgressUtil;
+import org.eclipse.wst.server.core.internal.ServerPlugin;
+import org.eclipse.wst.server.core.internal.Trace;
+import org.eclipse.wst.server.core.model.IModuleFile;
+import org.eclipse.wst.server.core.model.IModuleFolder;
+import org.eclipse.wst.server.core.model.IModuleResource;
+import org.eclipse.wst.server.core.model.IModuleResourceDelta;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.ide.eclipse.as.core.server.internal.ServerAttributeHelper;
+/**
+ * Utility class with an assortment of useful file methods.
+ * <p>
+ * This class provides all its functionality through static members.
+ * It is not intended to be subclassed or instantiated.
+ * </p>
+ * <p>
+ * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to
+ * change significantly before reaching stability. It is being made available at this early stage to solicit feedback
+ * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
+ * (repeatedly) as the API evolves.
+ * </p>
+ * @since 2.0
+ */
+public final class PublishUtil {
+ // size of the buffer
+ private static final int BUFFER = 65536;
+
+ // the buffer
+ private static byte[] buf = new byte[BUFFER];
+
+ private static final IStatus[] EMPTY_STATUS = new IStatus[0];
+
+ private static final File tempDir = ServerPlugin.getInstance().getStateLocation().toFile();
+
+ private static final String TEMPFILE_PREFIX = "tmp";
+
+ /**
+ * PublishUtil cannot be created. Use static methods.
+ */
+ private IServer server;
+ public PublishUtil(IServer server) {
+ this.server = server;
+ }
+
+ /**
+ * Copy a file from a to b. Closes the input stream after use.
+ *
+ * @param in an input stream
+ * @param to a path to copy to. the directory must already exist
+ * @param ts timestamp
+ * @throws CoreException if anything goes wrong
+ */
+ private void copyFile(InputStream in, IPath to, long ts, IModuleFile mf) throws CoreException {
+ OutputStream out = null;
+
+ File tempFile = null;
+ try {
+ File file = to.toFile();
+
+ // Change from original PublishUtil, will require
+ tempFile = File.createTempFile(TEMPFILE_PREFIX, "." + to.getFileExtension(), getTempFolder());
+
+ out = new FileOutputStream(tempFile);
+
+ int avail = in.read(buf);
+ while (avail > 0) {
+ out.write(buf, 0, avail);
+ avail = in.read(buf);
+ }
+
+ out.close();
+ out = null;
+
+ moveTempFile(tempFile, file);
+
+ if (ts != IResource.NULL_STAMP && ts != 0)
+ file.setLastModified(ts);
+ } catch (CoreException e) {
+ throw e;
+ } catch (Exception e) {
+ IPath path = mf.getModuleRelativePath().append(mf.getName());
+ Trace.trace(Trace.SEVERE, "Error copying file: " + to.toOSString() + " to " + path.toOSString(), e);
+ throw new CoreException(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCopyingFile, path.toOSString(), e.getLocalizedMessage()), null));
+ } finally {
+ if (tempFile != null && tempFile.exists())
+ tempFile.deleteOnExit();
+ try {
+ if (in != null)
+ in.close();
+ } catch (Exception ex) {
+ // ignore
+ }
+ try {
+ if (out != null)
+ out.close();
+ } catch (Exception ex) {
+ // ignore
+ }
+ }
+ }
+
+ /**
+ * Utility method to recursively delete a directory.
+ *
+ * @param dir a directory
+ * @param monitor a progress monitor, or <code>null</code> if progress
+ * reporting and cancellation are not desired
+ * @return a possibly-empty array of error and warning status
+ */
+ public IStatus[] deleteDirectory(File dir, IProgressMonitor monitor) {
+ if (!dir.exists() || !dir.isDirectory())
+ return new IStatus[] { new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorNotADirectory, dir.getAbsolutePath()), null) };
+
+ List status = new ArrayList(2);
+
+ try {
+ File[] files = dir.listFiles();
+ int size = files.length;
+ monitor = ProgressUtil.getMonitorFor(monitor);
+ monitor.beginTask(NLS.bind(Messages.deletingTask, new String[] { dir.getAbsolutePath() }), size * 10);
+
+ // cycle through files
+ boolean deleteCurrent = true;
+ for (int i = 0; i < size; i++) {
+ File current = files[i];
+ if (current.isFile()) {
+ if (!current.delete()) {
+ status.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorDeleting, files[i].getAbsolutePath()), null));
+ deleteCurrent = false;
+ }
+ monitor.worked(10);
+ } else if (current.isDirectory()) {
+ monitor.subTask(NLS.bind(Messages.deletingTask, new String[] {current.getAbsolutePath()}));
+ IStatus[] stat = deleteDirectory(current, ProgressUtil.getSubMonitorFor(monitor, 10));
+ if (stat != null && stat.length > 0) {
+ deleteCurrent = false;
+ addArrayToList(status, stat);
+ }
+ }
+ }
+ if (deleteCurrent && !dir.delete())
+ status.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorDeleting, dir.getAbsolutePath()), null));
+ monitor.done();
+ } catch (Exception e) {
+ Trace.trace(Trace.SEVERE, "Error deleting directory " + dir.getAbsolutePath(), e);
+ status.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, e.getLocalizedMessage(), null));
+ }
+
+ IStatus[] stat = new IStatus[status.size()];
+ status.toArray(stat);
+ return stat;
+ }
+
+ /**
+ * Smart copy the given module resources to the given path.
+ *
+ * @param resources an array of module resources
+ * @param path an external path to copy to
+ * @param monitor a progress monitor, or <code>null</code> if progress
+ * reporting and cancellation are not desired
+ * @return a possibly-empty array of error and warning status
+ */
+ public IStatus[] publishSmart(IModuleResource[] resources, IPath path, IProgressMonitor monitor) {
+ if (resources == null)
+ return EMPTY_STATUS;
+
+ monitor = ProgressUtil.getMonitorFor(monitor);
+
+ List status = new ArrayList(2);
+ File toDir = path.toFile();
+ int fromSize = resources.length;
+ String[] fromFileNames = new String[fromSize];
+ for (int i = 0; i < fromSize; i++)
+ fromFileNames[i] = resources[i].getName();
+
+ // cache files and file names for performance
+ File[] toFiles = null;
+ String[] toFileNames = null;
+
+ boolean foundExistingDir = false;
+ if (toDir.exists()) {
+ if (toDir.isDirectory()) {
+ foundExistingDir = true;
+ toFiles = toDir.listFiles();
+ int toSize = toFiles.length;
+ toFileNames = new String[toSize];
+
+ // check if this exact file exists in the new directory
+ for (int i = 0; i < toSize; i++) {
+ toFileNames[i] = toFiles[i].getName();
+ boolean isDir = toFiles[i].isDirectory();
+ boolean found = false;
+ for (int j = 0; j < fromSize; j++) {
+ if (toFileNames[i].equals(fromFileNames[j]) && isDir == resources[j] instanceof IModuleFolder)
+ found = true;
+ }
+
+ // delete file if it can't be found or isn't the correct type
+ if (!found) {
+ if (isDir) {
+ IStatus[] stat = deleteDirectory(toFiles[i], null);
+ addArrayToList(status, stat);
+ } else {
+ if (!toFiles[i].delete())
+ status.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorDeleting, toFiles[i].getAbsolutePath()), null));
+ }
+ toFiles[i] = null;
+ toFileNames[i] = null;
+ }
+ }
+ } else { //if (toDir.isFile())
+ if (!toDir.delete()) {
+ status.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorDeleting, toDir.getAbsolutePath()), null));
+ IStatus[] stat = new IStatus[status.size()];
+ status.toArray(stat);
+ return stat;
+ }
+ }
+ }
+ if (!foundExistingDir && !toDir.mkdirs()) {
+ status.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorMkdir, toDir.getAbsolutePath()), null));
+ IStatus[] stat = new IStatus[status.size()];
+ status.toArray(stat);
+ return stat;
+ }
+
+ if (monitor.isCanceled())
+ return new IStatus[] { Status.CANCEL_STATUS };
+
+ monitor.worked(50);
+
+ // cycle through files and only copy when it doesn't exist
+ // or is newer
+ if (toFiles == null)
+ toFiles = toDir.listFiles();
+ int toSize = 0;
+ if (toFiles != null)
+ toSize = toFiles.length;
+
+ int dw = 0;
+ if (toSize > 0)
+ dw = 500 / toSize;
+
+ // cache file names and last modified dates for performance
+ if (toFileNames == null)
+ toFileNames = new String[toSize];
+ long[] toFileMod = new long[toSize];
+ for (int i = 0; i < toSize; i++) {
+ if (toFiles[i] != null) {
+ if (toFileNames[i] != null)
+ toFileNames[i] = toFiles[i].getName();
+ toFileMod[i] = toFiles[i].lastModified();
+ }
+ }
+
+ for (int i = 0; i < fromSize; i++) {
+ IModuleResource current = resources[i];
+ String name = fromFileNames[i];
+ boolean currentIsDir = current instanceof IModuleFolder;
+
+ if (!currentIsDir) {
+ // check if this is a new or newer file
+ boolean copy = true;
+ IModuleFile mf = (IModuleFile) current;
+
+ long mod = -1;
+ IFile file = (IFile) mf.getAdapter(IFile.class);
+ if (file != null) {
+ mod = file.getLocalTimeStamp();
+ } else {
+ File file2 = (File) mf.getAdapter(File.class);
+ mod = file2.lastModified();
+ }
+
+ for (int j = 0; j < toSize; j++) {
+ if (name.equals(toFileNames[j]) && mod == toFileMod[j])
+ copy = false;
+ }
+
+ if (copy) {
+ try {
+ copyFile(mf, path.append(name));
+ } catch (CoreException ce) {
+ status.add(ce.getStatus());
+ }
+ }
+ monitor.worked(dw);
+ } else { //if (currentIsDir) {
+ IModuleFolder folder = (IModuleFolder) current;
+ IModuleResource[] children = folder.members();
+ monitor.subTask(NLS.bind(Messages.copyingTask, new String[] {name, name}));
+ IStatus[] stat = publishSmart(children, path.append(name), ProgressUtil.getSubMonitorFor(monitor, dw));
+ addArrayToList(status, stat);
+ }
+ }
+ if (monitor.isCanceled())
+ return new IStatus[] { Status.CANCEL_STATUS };
+
+ monitor.worked(500 - dw * toSize);
+ monitor.done();
+
+ IStatus[] stat = new IStatus[status.size()];
+ status.toArray(stat);
+ return stat;
+ }
+
+ /**
+ * Handle a delta publish.
+ *
+ * @param delta a module resource delta
+ * @param path the path to publish to
+ * @param monitor a progress monitor, or <code>null</code> if progress
+ * reporting and cancellation are not desired
+ * @return a possibly-empty array of error and warning status
+ */
+ public IStatus[] publishDelta(IModuleResourceDelta[] delta, IPath path, IProgressMonitor monitor) {
+ if (delta == null)
+ return EMPTY_STATUS;
+
+ monitor = ProgressUtil.getMonitorFor(monitor);
+
+ List status = new ArrayList(2);
+ int size2 = delta.length;
+ for (int i = 0; i < size2; i++) {
+ IStatus[] stat = publishDelta(delta[i], path, monitor);
+ addArrayToList(status, stat);
+ }
+
+ IStatus[] stat = new IStatus[status.size()];
+ status.toArray(stat);
+ return stat;
+ }
+
+ /**
+ * Handle a delta publish.
+ *
+ * @param delta a module resource delta
+ * @param path the path to publish to
+ * @param monitor a progress monitor, or <code>null</code> if progress
+ * reporting and cancellation are not desired
+ * @return a possibly-empty array of error and warning status
+ */
+ public IStatus[] publishDelta(IModuleResourceDelta delta, IPath path, IProgressMonitor monitor) {
+ List status = new ArrayList(2);
+
+ IModuleResource resource = delta.getModuleResource();
+ int kind2 = delta.getKind();
+
+ if (resource instanceof IModuleFile) {
+ IModuleFile file = (IModuleFile) resource;
+ try {
+ if (kind2 == IModuleResourceDelta.REMOVED)
+ deleteFile2(path, file);
+ else {
+ IPath path2 = path.append(file.getModuleRelativePath()).append(file.getName());
+ File f = path2.toFile().getParentFile();
+ if (!f.exists())
+ f.mkdirs();
+
+ copyFile(file, path2);
+ }
+ } catch (CoreException ce) {
+ status.add(ce.getStatus());
+ }
+ IStatus[] stat = new IStatus[status.size()];
+ status.toArray(stat);
+ return stat;
+ }
+
+ if (kind2 == IModuleResourceDelta.ADDED) {
+ IPath path2 = path.append(resource.getModuleRelativePath()).append(resource.getName());
+ File file = path2.toFile();
+ if (!file.exists() && !file.mkdirs()) {
+ status.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorMkdir, path2), null));
+ IStatus[] stat = new IStatus[status.size()];
+ status.toArray(stat);
+ return stat;
+ }
+ }
+
+ IModuleResourceDelta[] childDeltas = delta.getAffectedChildren();
+ int size = childDeltas.length;
+ for (int i = 0; i < size; i++) {
+ IStatus[] stat = publishDelta(childDeltas[i], path, monitor);
+ addArrayToList(status, stat);
+ }
+
+ if (kind2 == IModuleResourceDelta.REMOVED) {
+ IPath path2 = path.append(resource.getModuleRelativePath()).append(resource.getName());
+ File file = path2.toFile();
+ if (file.exists() && !file.delete()) {
+ status.add(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorDeleting, path2), null));
+ }
+ }
+
+ IStatus[] stat = new IStatus[status.size()];
+ status.toArray(stat);
+ return stat;
+ }
+
+ private void deleteFile2(IPath path, IModuleFile file) throws CoreException {
+ Trace.trace(Trace.PUBLISHING, "Deleting: " + file.getName() + " from " + path.toString());
+ IPath path2 = path.append(file.getModuleRelativePath()).append(file.getName());
+ if (path2.toFile().exists() && !path2.toFile().delete())
+ throw new CoreException(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorDeleting, path2), null));
+ }
+
+ private void copyFile(IModuleFile mf, IPath path) throws CoreException {
+ Trace.trace(Trace.PUBLISHING, "Copying: " + mf.getName() + " to " + path.toString());
+
+ IFile file = (IFile) mf.getAdapter(IFile.class);
+ if (file != null)
+ copyFile(file.getContents(), path, file.getLocalTimeStamp(), mf);
+ else {
+ File file2 = (File) mf.getAdapter(File.class);
+ InputStream in = null;
+ try {
+ in = new FileInputStream(file2);
+ } catch (IOException e) {
+ throw new CoreException(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorReading, file2.getAbsolutePath()), e));
+ }
+ copyFile(in, path, file2.lastModified(), mf);
+ }
+ }
+
+ /**
+ * Publish the given module resources to the given path.
+ *
+ * @param resources an array of module resources
+ * @param path a path to publish to
+ * @param monitor a progress monitor, or <code>null</code> if progress
+ * reporting and cancellation are not desired
+ * @return a possibly-empty array of error and warning status
+ */
+ public IStatus[] publishFull(IModuleResource[] resources, IPath path, IProgressMonitor monitor) {
+ if (resources == null)
+ return EMPTY_STATUS;
+
+ monitor = ProgressUtil.getMonitorFor(monitor);
+
+ List status = new ArrayList(2);
+ int size = resources.length;
+ for (int i = 0; i < size; i++) {
+ IStatus[] stat = copy(resources[i], path, monitor);
+ addArrayToList(status, stat);
+ }
+
+ IStatus[] stat = new IStatus[status.size()];
+ status.toArray(stat);
+ return stat;
+ }
+
+ private IStatus[] copy(IModuleResource resource, IPath path, IProgressMonitor monitor) {
+ String name = resource.getName();
+ Trace.trace(Trace.PUBLISHING, "Copying: " + name + " to " + path.toString());
+ List status = new ArrayList(2);
+ if (resource instanceof IModuleFolder) {
+ IModuleFolder folder = (IModuleFolder) resource;
+ IStatus[] stat = publishFull(folder.members(), path, monitor);
+ addArrayToList(status, stat);
+ } else {
+ IModuleFile mf = (IModuleFile) resource;
+ path = path.append(mf.getModuleRelativePath()).append(name);
+ File f = path.toFile().getParentFile();
+ if (!f.exists())
+ f.mkdirs();
+ try {
+ copyFile(mf, path);
+ } catch (CoreException ce) {
+ status.add(ce.getStatus());
+ }
+ }
+ IStatus[] stat = new IStatus[status.size()];
+ status.toArray(stat);
+ return stat;
+ }
+
+ /**
+ * Creates a new zip file containing the given module resources. Deletes the existing file
+ * (and doesn't create a new one) if resources is null or empty.
+ *
+ * @param resources an array of module resources
+ * @param path the path where the zip file should be created
+ * @param monitor a progress monitor, or <code>null</code> if progress
+ * reporting and cancellation are not desired
+ * @return a possibly-empty array of error and warning status
+ */
+ public IStatus[] publishZip(IModuleResource[] resources, IPath path, IProgressMonitor monitor) {
+ if (resources == null || resources.length == 0) {
+ // should also check if resources consists of all empty directories
+ File file = path.toFile();
+ if (file.exists())
+ file.delete();
+ return EMPTY_STATUS;
+ }
+
+ monitor = ProgressUtil.getMonitorFor(monitor);
+
+ File tempFile = null;
+ try {
+ File file = path.toFile();
+ tempFile = File.createTempFile(TEMPFILE_PREFIX, "." + path.getFileExtension(), getTempFolder());
+ BufferedOutputStream bout = new BufferedOutputStream(new FileOutputStream(tempFile));
+ ZipOutputStream zout = new ZipOutputStream(bout);
+ addZipEntries(zout, resources);
+ zout.close();
+
+ moveTempFile(tempFile, file);
+ } catch (CoreException e) {
+ return new IStatus[] { e.getStatus() };
+ } catch (Exception e) {
+ Trace.trace(Trace.SEVERE, "Error zipping", e);
+ return new Status[] { new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCreatingZipFile, path.lastSegment(), e.getLocalizedMessage()), e) };
+ } finally {
+ if (tempFile != null && tempFile.exists())
+ tempFile.deleteOnExit();
+ }
+ return EMPTY_STATUS;
+ }
+
+ private void addZipEntries(ZipOutputStream zout, IModuleResource[] resources) throws Exception {
+ if (resources == null)
+ return;
+
+ int size = resources.length;
+ for (int i = 0; i < size; i++) {
+ if (resources[i] instanceof IModuleFolder) {
+ IModuleFolder mf = (IModuleFolder) resources[i];
+ IModuleResource[] res = mf.members();
+
+ IPath path = mf.getModuleRelativePath().append(mf.getName());
+ String entryPath = path.toPortableString();
+ if (!entryPath.endsWith("/"))
+ entryPath += '/';
+
+ ZipEntry ze = new ZipEntry(entryPath);
+
+ long ts = 0;
+ IContainer folder = (IContainer) mf.getAdapter(IContainer.class);
+ if (folder != null)
+ ts = folder.getLocalTimeStamp();
+
+ if (ts != IResource.NULL_STAMP && ts != 0)
+ ze.setTime(ts);
+
+ zout.putNextEntry(ze);
+ zout.closeEntry();
+
+ addZipEntries(zout, res);
+ continue;
+ }
+
+ IModuleFile mf = (IModuleFile) resources[i];
+ IPath path = mf.getModuleRelativePath().append(mf.getName());
+
+ ZipEntry ze = new ZipEntry(path.toPortableString());
+
+ InputStream in = null;
+ long ts = 0;
+ IFile file = (IFile) mf.getAdapter(IFile.class);
+ if (file != null) {
+ ts = file.getLocalTimeStamp();
+ in = file.getContents();
+ } else {
+ File file2 = (File) mf.getAdapter(File.class);
+ ts = file2.lastModified();
+ in = new FileInputStream(file2);
+ }
+
+ if (ts != IResource.NULL_STAMP && ts != 0)
+ ze.setTime(ts);
+
+ zout.putNextEntry(ze);
+
+ try {
+ int n = 0;
+ while (n > -1) {
+ n = in.read(buf);
+ if (n > 0)
+ zout.write(buf, 0, n);
+ }
+ } finally {
+ in.close();
+ }
+
+ zout.closeEntry();
+ }
+ }
+
+ /**
+ * Utility method to move a temp file into position by deleting the original and
+ * swapping in a new copy.
+ *
+ * @param tempFile
+ * @param file
+ * @throws CoreException
+ */
+ private void moveTempFile(File tempFile, File file) throws CoreException {
+ if (file.exists()) {
+ if (!safeDelete(file, 2)) {
+ // attempt to rewrite an existing file with the tempFile contents if
+ // the existing file can't be deleted to permit the move
+ try {
+ InputStream in = new FileInputStream(tempFile);
+ IStatus status = copyFile(in, file.getPath());
+ if (!status.isOK()) {
+ MultiStatus status2 = new MultiStatus(ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorDeleting, file.toString()), null);
+ status2.add(status);
+ throw new CoreException(status2);
+ }
+ return;
+ } catch (FileNotFoundException e) {
+ // shouldn't occur
+ } finally {
+ tempFile.delete();
+ }
+ /*if (!safeDelete(file, 8)) {
+ tempFile.delete();
+ throw new CoreException(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorDeleting, file.toString()), null));
+ }*/
+ }
+ }
+ if (!safeRename(tempFile, file, 10))
+ throw new CoreException(new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorRename, tempFile.toString()), null));
+ }
+
+ /**
+ * Copy a file from a to b. Closes the input stream after use.
+ *
+ * @param in java.io.InputStream
+ * @param to java.lang.String
+ * @return a status
+ */
+ private IStatus copyFile(InputStream in, String to) {
+ OutputStream out = null;
+
+ try {
+ out = new FileOutputStream(to);
+
+ int avail = in.read(buf);
+ while (avail > 0) {
+ out.write(buf, 0, avail);
+ avail = in.read(buf);
+ }
+ return Status.OK_STATUS;
+ } catch (Exception e) {
+ Trace.trace(Trace.SEVERE, "Error copying file", e);
+ return new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCopyingFile, new String[] {to, e.getLocalizedMessage()}), e);
+ } finally {
+ try {
+ if (in != null)
+ in.close();
+ } catch (Exception ex) {
+ // ignore
+ }
+ try {
+ if (out != null)
+ out.close();
+ } catch (Exception ex) {
+ // ignore
+ }
+ }
+ }
+
+ /**
+ * Safe delete. Tries to delete multiple times before giving up.
+ *
+ * @param f
+ * @return <code>true</code> if it succeeds, <code>false</code> otherwise
+ */
+ private boolean safeDelete(File f, int retrys) {
+ int count = 0;
+ while (count < retrys) {
+ if (!f.exists())
+ return true;
+
+ f.delete();
+
+ if (!f.exists())
+ return true;
+
+ count++;
+ // delay if we are going to try again
+ if (count < retrys) {
+ try {
+ Thread.sleep(100);
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Safe rename. Will try multiple times before giving up.
+ *
+ * @param from
+ * @param to
+ * @param retrys number of times to retry
+ * @return <code>true</code> if it succeeds, <code>false</code> otherwise
+ */
+ private boolean safeRename(File from, File to, int retrys) {
+ // make sure parent dir exists
+ File dir = to.getParentFile();
+ if (dir != null && !dir.exists())
+ dir.mkdirs();
+
+ int count = 0;
+ while (count < retrys) {
+ if (from.renameTo(to))
+ return true;
+
+ count++;
+ // delay if we are going to try again
+ if (count < retrys) {
+ try {
+ Thread.sleep(100);
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+ return false;
+ }
+
+ private void addArrayToList(List list, IStatus[] a) {
+ if (list == null || a == null || a.length == 0)
+ return;
+
+ int size = a.length;
+ for (int i = 0; i < size; i++)
+ list.add(a[i]);
+ }
+
+ protected File getTempFolder() {
+ if( server == null ) return tempDir;
+ String path =
+ ServerAttributeHelper.createHelper(server)
+ .getAttribute(IDeployableServer.TEMP_DEPLOY_DIRECTORY, tempDir.getAbsolutePath());
+ return new File(path);
+ }
+}
\ No newline at end of file
17 years, 2 months
JBoss Tools SVN: r4357 - trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2007-10-19 01:30:18 -0400 (Fri, 19 Oct 2007)
New Revision: 4357
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IDeployableServer.java
Log:
JBIDE-1047
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IDeployableServer.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IDeployableServer.java 2007-10-19 00:33:29 UTC (rev 4356)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IDeployableServer.java 2007-10-19 05:30:18 UTC (rev 4357)
@@ -30,6 +30,7 @@
*/
public interface IDeployableServer {
public static final String DEPLOY_DIRECTORY = "org.jboss.ide.eclipse.as.core.server.deployDirectory";
+ public static final String TEMP_DEPLOY_DIRECTORY = "org.jboss.ide.eclipse.as.core.server.tempDeployDirectory";
public String getDeployDirectory();
public String getConfigDirectory();
17 years, 2 months