JBoss Tools SVN: r9970 - in trunk/portlet/plugins/org.jboss.tools.portlet.ui: src/org/jboss/tools/portlet/operations and 5 other directories.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-08-31 19:57:33 -0400 (Sun, 31 Aug 2008)
New Revision: 9970
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/action/
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/action/xpl/
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/action/xpl/AddJavaEEArtifactOperationEx.java
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/action/xpl/AddWebClassOperationEx.java
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/xpl/
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/xpl/NewJavaClassWizardPageEx.java
Modified:
trunk/portlet/plugins/org.jboss.tools.portlet.ui/META-INF/MANIFEST.MF
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/operations/AddPortletOperation.java
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/PortletUIActivator.java
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletClassDataModelProvider.java
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletClassOptionsWizardPage.java
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletClassWizardPage.java
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletWizard.java
Log:
JBIDE-2621 Portlet wizards should not be restricted to portlet enabled projects
Modified: trunk/portlet/plugins/org.jboss.tools.portlet.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/META-INF/MANIFEST.MF 2008-08-30 00:06:07 UTC (rev 9969)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.ui/META-INF/MANIFEST.MF 2008-08-31 23:57:33 UTC (rev 9970)
@@ -26,5 +26,6 @@
org.eclipse.wst.xml.core,
org.eclipse.wst.sse.core,
org.eclipse.jdt.ui,
- org.eclipse.ui.ide
+ org.eclipse.ui.ide,
+ org.eclipse.ui.views
Bundle-ActivationPolicy: lazy
Modified: trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/operations/AddPortletOperation.java
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/operations/AddPortletOperation.java 2008-08-30 00:06:07 UTC (rev 9969)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/operations/AddPortletOperation.java 2008-08-31 23:57:33 UTC (rev 9970)
@@ -10,6 +10,7 @@
import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.EDIT_MODE;
import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.HELP_MODE;
import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.IF_EXISTS;
+import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.INITIAL_WINDOW_STATE;
import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.INSTANCE_NAME;
import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.IS_JSF_PORTLET;
import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.IS_SEAM_PORTLET;
@@ -19,7 +20,6 @@
import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.PAGE_REGION;
import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.PARENT_PORTAL;
import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.PORTLET_HEIGHT;
-import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.INITIAL_WINDOW_STATE;
import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.TITLE;
import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.VIEW_MODE;
import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.WINDOW_NAME;
@@ -46,7 +46,6 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jst.j2ee.internal.common.operations.NewJavaEEArtifactClassOperation;
-import org.eclipse.jst.j2ee.internal.web.operations.AddWebClassOperation;
import org.eclipse.ui.dialogs.IOverwriteQuery;
import org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider;
import org.eclipse.ui.wizards.datatransfer.ImportOperation;
@@ -64,6 +63,7 @@
import org.jboss.tools.portlet.core.PortletCoreActivator;
import org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties;
import org.jboss.tools.portlet.ui.PortletUIActivator;
+import org.jboss.tools.portlet.ui.internal.wizard.action.xpl.AddWebClassOperationEx;
import org.osgi.framework.Bundle;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -73,7 +73,7 @@
/**
* @author snjeza
*/
-public class AddPortletOperation extends AddWebClassOperation {
+public class AddPortletOperation extends AddWebClassOperationEx {
public static final IOverwriteQuery OVERWRITE_NO_QUERY = new IOverwriteQuery()
{
@@ -124,6 +124,10 @@
protected void generateMetaData(IDataModel aModel, String qualifiedClassName) {
// update the portlet.xml file
+ boolean isPortletProject = PortletUIActivator.isPortletProject(aModel);
+ if (!isPortletProject) {
+ return;
+ }
updatePortletXml(aModel);
boolean addPortlet = model.getBooleanProperty(ADD_PORTLET);
@@ -134,6 +138,11 @@
// generate/update *.object.xml
updatePortletObject(aModel);
}
+ boolean isJSFPortlet = model.getBooleanProperty(IS_JSF_PORTLET);
+ boolean isSeamPortlet = model.getBooleanProperty(IS_SEAM_PORTLET);
+ if (!isJSFPortlet && !isSeamPortlet) {
+ return;
+ }
boolean addJBossApp = model.getBooleanProperty(ADD_JBOSS_APP);
if (addJBossApp) {
updateJBossApp(aModel);
Modified: trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/PortletUIActivator.java
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/PortletUIActivator.java 2008-08-30 00:06:07 UTC (rev 9969)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/PortletUIActivator.java 2008-08-31 23:57:33 UTC (rev 9970)
@@ -1,13 +1,21 @@
package org.jboss.tools.portlet.ui;
+import static org.eclipse.wst.common.componentcore.internal.operation.IArtifactEditOperationDataModelProperties.PROJECT_NAME;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.wst.common.componentcore.ComponentCore;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.common.componentcore.resources.IVirtualFile;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.jboss.tools.portlet.core.IPortletConstants;
import org.jboss.tools.portlet.core.PortletCoreActivator;
import org.osgi.framework.BundleContext;
@@ -79,4 +87,27 @@
IStatus status = new Status(IStatus.ERROR,PLUGIN_ID,e.getLocalizedMessage(),e);
PortletCoreActivator.getDefault().getLog().log(status);
}
+
+ public static boolean isPortletProject(IDataModel model) {
+ String projectName = model.getStringProperty(PROJECT_NAME);
+ if(projectName != null && !"".equals(projectName.trim())){
+ IProject project = ProjectUtilities.getProject(projectName);
+ try {
+ IFacetedProject facetedProject = ProjectFacetsManager.create(project);
+ return facetedProject != null && facetedProject.hasProjectFacet(getPortletFacet());
+ } catch (CoreException e) {
+ PortletUIActivator.log(e);
+ }
+ }
+ return false;
+
+ }
+
+ private static IProjectFacet getPortletFacet() {
+ try {
+ return ProjectFacetsManager.getProjectFacet(IPortletConstants.PORTLET_FACET_ID);
+ } catch (IllegalArgumentException e) {
+ return null;
+ }
+ }
}
Modified: trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletClassDataModelProvider.java
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletClassDataModelProvider.java 2008-08-30 00:06:07 UTC (rev 9969)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletClassDataModelProvider.java 2008-08-31 23:57:33 UTC (rev 9970)
@@ -2,13 +2,32 @@
+import static org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties.SOURCE_FOLDER;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
+import org.eclipse.jem.util.logger.proxy.Logger;
+import org.eclipse.jst.j2ee.internal.common.J2EECommonMessages;
+import org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties;
+import org.eclipse.jst.j2ee.internal.common.operations.NewJavaClassDataModelProvider;
+import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
import org.eclipse.jst.j2ee.internal.web.operations.INewServletClassDataModelProperties;
import org.eclipse.jst.j2ee.internal.web.operations.NewServletClassDataModelProvider;
import org.eclipse.jst.j2ee.internal.web.operations.NewServletClassOperation;
@@ -260,11 +279,57 @@
if (propertyName.equals(IF_EXISTS)) {
return "overwrite";
}
-
+ if (propertyName.equals(INewJavaClassDataModelProperties.JAVA_SOURCE_FOLDER)) {
+ return getSourceFolder();
+ }
// Otherwise check super for default value for property
return super.getDefaultProperty(propertyName);
}
+ private Object getSourceFolder() {
+ Object result = getJavaSourceFolder();
+ if (result != null) {
+ return result;
+ }
+ return getDefaultJavaSourceFolder();
+ }
+
+ @Override
+ protected IFolder getDefaultJavaSourceFolder() {
+ IProject project = getTargetProject();
+ if (project == null)
+ return null;
+ IPackageFragmentRoot[] sources = J2EEProjectUtilities.getSourceContainers(project);
+ // Try and return the first source folder
+ if (sources.length > 0) {
+ try {
+ return (IFolder) sources[0].getCorrespondingResource();
+ } catch (Exception e) {
+ return null;
+ }
+ }
+ IJavaProject javaProject = JavaCore.create(project);
+ if (javaProject == null) {
+ return null;
+ }
+ try {
+ IClasspathEntry[] entries = javaProject.getResolvedClasspath(false);
+ for (int i = 0; i < entries.length; i++) {
+ IClasspathEntry entry = entries[i];
+ if (entry.getContentKind() == IPackageFragmentRoot.K_SOURCE) {
+ IPath path = entry.getPath();
+ IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
+ if (resource instanceof IFolder) {
+ return (IFolder) resource;
+ }
+ }
+ }
+ } catch (JavaModelException e) {
+ // ignore
+ }
+ return null;
+ }
+
private String getPortletPrefix() {
String prefix = null;
if (isSeamPortlet) {
@@ -365,5 +430,51 @@
}
return interfaceList;
}
+
+ @Override
+ protected boolean isAnnotationsSupported() {
+ return false;
+ }
+ @Override
+ protected IStatus validateJavaSourceFolder(String folderFullPath) {
+ // Ensure that the source folder path is not empty
+ if (folderFullPath == null || folderFullPath.length() == 0) {
+ String msg = J2EECommonMessages.ERR_JAVA_CLASS_FOLDER_NAME_EMPTY;
+ return WTPCommonPlugin.createErrorStatus(msg);
+ }
+ // Ensure that the source folder path is absolute
+ else if (!new Path(folderFullPath).isAbsolute()) {
+ String msg = J2EECommonMessages.ERR_JAVA_CLASS_FOLDER_NOT_ABSOLUTE;
+ return WTPCommonPlugin.createErrorStatus(msg);
+ }
+ IProject project = getTargetProject();
+ // Ensure project is not closed
+ if (project == null) {
+ String msg = J2EECommonMessages.ERR_JAVA_CLASS_FOLDER_NOT_EXIST;
+ return WTPCommonPlugin.createErrorStatus(msg);
+ }
+ // Ensure project is accessible.
+ if (!project.isAccessible()) {
+ String msg = J2EECommonMessages.ERR_JAVA_CLASS_FOLDER_NOT_EXIST;
+ return WTPCommonPlugin.createErrorStatus(msg);
+ }
+ // Ensure the project is a java project.
+ try {
+ if (!project.hasNature(JavaCore.NATURE_ID)) {
+ String msg = J2EECommonMessages.ERR_JAVA_CLASS_NOT_JAVA_PROJECT;
+ return WTPCommonPlugin.createErrorStatus(msg);
+ }
+ } catch (CoreException e) {
+ Logger.getLogger().log(e);
+ }
+ // Ensure the selected folder is a valid java source folder for the component
+ IFolder sourcefolder = (IFolder) getSourceFolder();
+ if (sourcefolder == null || (sourcefolder != null && !sourcefolder.getFullPath().equals(new Path(folderFullPath)))) {
+ String msg = J2EECommonMessages.getResourceString(J2EECommonMessages.ERR_JAVA_CLASS_FOLDER_NOT_SOURCE, new String[]{folderFullPath});
+ return WTPCommonPlugin.createErrorStatus(msg);
+ }
+ // Valid source is selected
+ return WTPCommonPlugin.OK_STATUS;
+ }
}
Modified: trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletClassOptionsWizardPage.java
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletClassOptionsWizardPage.java 2008-08-30 00:06:07 UTC (rev 9969)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletClassOptionsWizardPage.java 2008-08-31 23:57:33 UTC (rev 9970)
@@ -1,5 +1,10 @@
package org.jboss.tools.portlet.ui.internal.wizard;
+import static org.eclipse.wst.common.componentcore.internal.operation.IArtifactEditOperationDataModelProperties.PROJECT_NAME;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -16,7 +21,12 @@
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.jboss.tools.portlet.core.IPortletConstants;
import org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties;
+import org.jboss.tools.portlet.ui.PortletUIActivator;
public class NewPortletClassOptionsWizardPage extends
NewWebClassOptionsWizardPage implements ISelectionChangedListener {
@@ -141,4 +151,10 @@
private boolean canRemoveSelectedInterfaces(IStructuredSelection selection) {
return true;
}
+
+ @Override
+ public boolean canFlipToNextPage() {
+ return isPageComplete() && PortletUIActivator.isPortletProject(model);
+ }
+
}
Modified: trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletClassWizardPage.java
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletClassWizardPage.java 2008-08-30 00:06:07 UTC (rev 9969)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletClassWizardPage.java 2008-08-31 23:57:33 UTC (rev 9970)
@@ -10,60 +10,92 @@
* Kaloyan Raev, kaloyan.raev(a)sap.com
*******************************************************************************/
package org.jboss.tools.portlet.ui.internal.wizard;
+import static org.eclipse.jst.j2ee.application.internal.operations.IAnnotationsDataModel.USE_ANNOTATIONS;
+import static org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties.CLASS_NAME;
import static org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties.PROJECT;
-import static org.eclipse.jst.j2ee.internal.web.operations.INewServletClassDataModelProperties.IS_SERVLET_TYPE;
import static org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.USE_EXISTING_CLASS;
+import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.BROWSE_BUTTON_LABEL;
+import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.CLASS_NAME_LABEL;
import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
+import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.window.Window;
-import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
import org.eclipse.jst.j2ee.internal.war.ui.util.WebServletGroupItemProvider;
+import org.eclipse.jst.j2ee.internal.wizard.AnnotationsStandaloneGroup;
+import org.eclipse.jst.j2ee.internal.wizard.NewJavaClassWizardPage;
import org.eclipse.jst.j2ee.webapplication.WebApp;
import org.eclipse.jst.jee.ui.internal.navigator.web.GroupServletItemProvider;
import org.eclipse.jst.jee.ui.internal.navigator.web.WebAppProvider;
-import org.eclipse.jst.servlet.ui.internal.wizard.NewWebClassWizardPage;
+import org.eclipse.jst.servlet.ui.internal.plugin.WEBUIMessages;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.project.facet.core.FacetedProjectFramework;
-import org.eclipse.wst.common.project.facet.core.internal.FacetedProject;
import org.jboss.tools.portlet.core.IPortletConstants;
import org.jboss.tools.portlet.ui.MultiSelectFilteredFileSelectionDialog;
+import org.jboss.tools.portlet.ui.internal.wizard.xpl.NewJavaClassWizardPageEx;
-public class NewPortletClassWizardPage extends NewWebClassWizardPage {
+public class NewPortletClassWizardPage extends NewJavaClassWizardPageEx {
+ protected AnnotationsStandaloneGroup annotationsGroup;
+
+ protected Button existingClassButton;
+ protected Label existingClassLabel;
+ protected Text existingClassText;
+ protected Button existingButton;
+
public NewPortletClassWizardPage(IDataModel model, String pageName, String pageDesc, String pageTitle, String moduleType) {
super(model, pageName, pageDesc, pageTitle, moduleType);
}
@Override
+ protected Composite createTopLevelComposite(Composite parent) {
+ Composite composite = super.createTopLevelComposite(parent);
+
+ //projectNameLabel.setText(WEBUIMessages.WEB_PROJECT_LBL);
+
+ addSeperator(composite, 3);
+ createUseExistingGroup(composite);
+ //createAnnotationsGroup(composite);
+ model.setProperty(USE_ANNOTATIONS, false);
+
+ Dialog.applyDialogFont(composite);
+
+ return composite;
+ }
+
+ @Override
protected boolean isProjectValid(IProject project) {
- boolean result = super.isProjectValid(project);
- if (result == false) {
- return result;
- }
+ boolean result;
try {
- result = FacetedProjectFramework.hasProjectFacet(project, IPortletConstants.PORTLET_FACET_ID);
+ result = project.isAccessible() &&
+ project.hasNature(JavaCore.NATURE_ID);
} catch (CoreException ce) {
result = false;
}
return result;
+
}
- @Override
+
protected String getUseExistingCheckboxText() {
return "Use an existing Portlet class";
}
- @Override
+
protected String getUseExistingProperty() {
return USE_EXISTING_CLASS;
}
@@ -83,7 +115,6 @@
return super.getExtendedSelectedProject(selection);
}
- @Override
protected void handleClassButtonSelected() {
getControl().setCursor(new Cursor(getShell().getDisplay(), SWT.CURSOR_WAIT));
IProject project = (IProject) model.getProperty(PROJECT);
@@ -109,4 +140,52 @@
getControl().setCursor(null);
}
+ private void createUseExistingGroup(Composite composite) {
+ existingButton = new Button(composite, SWT.CHECK);
+ existingButton.setText(getUseExistingCheckboxText());
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ data.horizontalSpan = 3;
+ existingButton.setLayoutData(data);
+ synchHelper.synchCheckbox(existingButton, getUseExistingProperty(), null);
+ existingButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleExistingButtonSelected();
+ }
+ });
+
+ existingClassLabel = new Label(composite, SWT.LEFT);
+ existingClassLabel.setText(CLASS_NAME_LABEL);
+ existingClassLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+ existingClassLabel.setEnabled(false);
+
+ existingClassText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
+ existingClassText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ existingClassText.setEnabled(false);
+ synchHelper.synchText(existingClassText, CLASS_NAME, null);
+
+ existingClassButton = new Button(composite, SWT.PUSH);
+ existingClassButton.setText(BROWSE_BUTTON_LABEL);
+ existingClassButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+ existingClassButton.setEnabled(false);
+ existingClassButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleClassButtonSelected();
+ }
+ });
+ }
+
+ private void handleExistingButtonSelected() {
+ boolean enable = existingButton.getSelection();
+ existingClassLabel.setEnabled(enable);
+ existingClassButton.setEnabled(enable);
+ packageText.setEnabled(!enable);
+ packageButton.setEnabled(!enable);
+ packageLabel.setEnabled(!enable);
+ classText.setEnabled(!enable);
+ classLabel.setEnabled(!enable);
+ superText.setEnabled(!enable);
+ superButton.setEnabled(!enable);
+ superLabel.setEnabled(!enable);
+ }
+
}
Modified: trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletWizard.java
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletWizard.java 2008-08-30 00:06:07 UTC (rev 9969)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletWizard.java 2008-08-31 23:57:33 UTC (rev 9970)
@@ -49,15 +49,16 @@
IPortletUIConstants.NEW_PORTLET_WIZARD_PAGE_TITLE, IModuleConstants.JST_WEB_MODULE);
//page1.setInfopopID(IWebUIContextIds.WEBEDITOR_SERVLET_PAGE_ADD_SERVLET_WIZARD_1);
addPage(page1);
- AddPortletWizardPage page2 = new AddPortletWizardPage(getDataModel(), PAGE_TWO);
- //page2.setInfopopID(IWebUIContextIds.WEBEDITOR_SERVLET_PAGE_ADD_SERVLET_WIZARD_2);
- addPage(page2);
- NewPortletClassOptionsWizardPage page3 = new NewPortletClassOptionsWizardPage(
+
+ NewPortletClassOptionsWizardPage page2 = new NewPortletClassOptionsWizardPage(
getDataModel(),
- PAGE_THREE,
+ PAGE_TWO,
"Specify modifiers, interfaces to implement and method stubs to generate.",
IPortletUIConstants.NEW_PORTLET_WIZARD_PAGE_TITLE);
//page3.setInfopopID(IWebUIContextIds.WEBEDITOR_SERVLET_PAGE_ADD_SERVLET_WIZARD_3);
+ addPage(page2);
+ AddPortletWizardPage page3 = new AddPortletWizardPage(getDataModel(), PAGE_THREE);
+ //page2.setInfopopID(IWebUIContextIds.WEBEDITOR_SERVLET_PAGE_ADD_SERVLET_WIZARD_2);
addPage(page3);
AddJBossPortletWizardPage page4 = new AddJBossPortletWizardPage(getDataModel(), PAGE_FOUR);
addPage(page4);
Added: trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/action/xpl/AddJavaEEArtifactOperationEx.java
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/action/xpl/AddJavaEEArtifactOperationEx.java (rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/action/xpl/AddJavaEEArtifactOperationEx.java 2008-08-31 23:57:33 UTC (rev 9970)
@@ -0,0 +1,119 @@
+package org.jboss.tools.portlet.ui.internal.wizard.action.xpl;
+
+import static org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties.CLASS_NAME;
+import static org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties.JAVA_PACKAGE;
+import static org.eclipse.wst.common.componentcore.internal.operation.IArtifactEditOperationDataModelProperties.PROJECT_NAME;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
+import org.eclipse.jst.j2ee.internal.common.operations.NewJavaEEArtifactClassOperation;
+import org.eclipse.jst.j2ee.model.IModelProvider;
+import org.eclipse.jst.j2ee.model.ModelProviderManager;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.jboss.tools.portlet.ui.PortletUIActivator;
+
+public abstract class AddJavaEEArtifactOperationEx extends AbstractDataModelOperation {
+
+ protected IModelProvider provider;
+
+ public AddJavaEEArtifactOperationEx(IDataModel dataModel) {
+ super(dataModel);
+ }
+
+ @Override
+ public IStatus execute(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
+ Runnable runnable = null;
+ provider = getModelProvider();
+ runnable = new Runnable(){
+ public void run() {
+ try {
+ doExecute(monitor, info);
+ } catch (ExecutionException e) {
+ PortletUIActivator.log(e);
+ }
+ }
+ };
+ if (provider != null) {
+ if (provider.validateEdit(null, null).isOK()) {
+
+ provider.modify(runnable, null);
+ }
+ } else {
+ runnable.run();
+ }
+ //return doExecute(monitor, info);
+ return Status.CANCEL_STATUS;
+ }
+
+ private IModelProvider getModelProvider() {
+ IModelProvider modelProvider = null;
+ try {
+ modelProvider = ModelProviderManager.getModelProvider(getTargetProject());
+ } catch (Throwable e) {
+ // ignore
+ }
+ return modelProvider;
+ }
+
+ public IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
+ throws ExecutionException {
+ // create the java class
+ createClass();
+ return OK_STATUS;
+ }
+
+ protected String createClass() {
+ // Create bean java class file using the NewBeanClassOperation.
+ NewJavaEEArtifactClassOperation op = getNewClassOperation();
+ try {
+ IStatus status = op.execute(new NullProgressMonitor(), null);
+ if (!status.isOK()) {
+ PortletUIActivator.getDefault().getLog().log(status);
+ }
+ } catch (Exception e) {
+ PortletUIActivator.log(e);
+ }
+ // Return the qualified class name of the newly created java class for
+ // the bean
+ return getQualifiedClassName();
+ }
+
+ protected abstract NewJavaEEArtifactClassOperation getNewClassOperation();
+
+ public IProject getTargetProject() {
+ String projectName = model.getStringProperty(PROJECT_NAME);
+ return ProjectUtilities.getProject(projectName);
+ }
+
+ /**
+ * This method will return the qualified java class name as specified by the
+ * class name and package name properties in the data model. This method
+ * should not return null.
+ *
+ * @see #CLASS_NAME
+ * @see #JAVA_PACKAGE
+ *
+ * @return String qualified java class name
+ */
+ public final String getQualifiedClassName() {
+ // Use the java package name and unqualified class name to create a
+ // qualified java class name
+ String packageName = model.getStringProperty(JAVA_PACKAGE);
+ String className = model.getStringProperty(CLASS_NAME);
+
+ // Ensure the class is not in the default package before adding package
+ // name to qualified name
+ if (packageName != null && packageName.trim().length() > 0)
+ return packageName + "." + className; //$NON-NLS-1$
+
+ return className;
+ }
+
+}
Added: trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/action/xpl/AddWebClassOperationEx.java
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/action/xpl/AddWebClassOperationEx.java (rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/action/xpl/AddWebClassOperationEx.java 2008-08-31 23:57:33 UTC (rev 9970)
@@ -0,0 +1,64 @@
+package org.jboss.tools.portlet.ui.internal.wizard.action.xpl;
+
+import static org.eclipse.jst.j2ee.application.internal.operations.IAnnotationsDataModel.USE_ANNOTATIONS;
+import static org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties.CLASS_NAME;
+import static org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.USE_EXISTING_CLASS;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jst.j2ee.internal.web.operations.AddFilterOperation;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+
+public abstract class AddWebClassOperationEx extends AddJavaEEArtifactOperationEx {
+
+ public AddWebClassOperationEx(IDataModel dataModel) {
+ super(dataModel);
+ }
+
+ /**
+ * Subclasses may extend this method to add their own actions during
+ * execution. The implementation of the execute method drives the running of
+ * the operation. This implementation will create the filter class, and
+ * then it will create the filter metadata for the web deployment descriptor.
+ * This method will accept null as a parameter.
+ *
+ * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor,
+ * org.eclipse.core.runtime.IAdaptable)
+ * @see AddFilterOperation#createFilterClass()
+ * @see AddFilterOperation#generateFilterMetaData(NewFilterClassDataModel,
+ * String)
+ *
+ * @param monitor
+ * IProgressMonitor
+ * @param info
+ * IAdaptable
+ * @throws CoreException
+ * @throws InterruptedException
+ * @throws InvocationTargetException
+ */
+ @Override
+ public IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
+ throws ExecutionException {
+
+ boolean useExisting = model.getBooleanProperty(USE_EXISTING_CLASS);
+ String qualifiedClassName = model.getStringProperty(CLASS_NAME);
+
+ // create the java class
+ if (!useExisting)
+ qualifiedClassName = createClass();
+
+ // If the filter is not annotated, generate the filter metadata for the DD
+ if (!model.getBooleanProperty(USE_ANNOTATIONS))
+ generateMetaData(model, qualifiedClassName);
+
+ return OK_STATUS;
+ }
+
+ protected abstract void generateMetaData(IDataModel aModel, String qualifiedClassName);
+
+}
Added: trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/xpl/NewJavaClassWizardPageEx.java
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/xpl/NewJavaClassWizardPageEx.java (rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/xpl/NewJavaClassWizardPageEx.java 2008-08-31 23:57:33 UTC (rev 9970)
@@ -0,0 +1,719 @@
+package org.jboss.tools.portlet.ui.internal.wizard.xpl;
+
+/*******************************************************************************
+ * Copyright (c) 2003, 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
+ * David Schneider, david.schneider(a)unisys.com - [142500] WTP properties pages fonts don't follow Eclipse preferences
+ *******************************************************************************/
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.search.IJavaSearchConstants;
+import org.eclipse.jdt.core.search.IJavaSearchScope;
+import org.eclipse.jdt.internal.ui.dialogs.FilteredTypesSelectionDialog;
+import org.eclipse.jdt.internal.ui.viewsupport.IViewPartInputProvider;
+import org.eclipse.jdt.ui.JavaElementLabelProvider;
+import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.DecoratingLabelProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties;
+import org.eclipse.jst.j2ee.internal.dialogs.TypeSearchEngine;
+import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages;
+import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.eclipse.ui.views.contentoutline.ContentOutline;
+import org.eclipse.wst.common.componentcore.internal.operation.IArtifactEditOperationDataModelProperties;
+import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage;
+import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin;
+import org.jboss.tools.portlet.ui.PortletUIActivator;
+
+/**
+ *
+ */
+public class NewJavaClassWizardPageEx extends DataModelWizardPage {
+
+ private Text folderText;
+ private Button folderButton;
+ protected Text packageText;
+ protected Button packageButton;
+ protected Label packageLabel;
+ protected Text classText;
+ protected Label classLabel;
+ protected Text superText;
+ protected Button superButton;
+ protected Label superLabel;
+ protected Label projectNameLabel;
+ private Combo projectNameCombo;
+ protected String projectType;
+ private String projectName;
+
+ /**
+ * @param model
+ * @param pageName
+ */
+ public NewJavaClassWizardPageEx(IDataModel model, String pageName, String pageDesc, String pageTitle,
+ String moduleType) {
+ super(model, pageName);
+ setDescription(pageDesc);
+ this.setTitle(pageTitle);
+ setPageComplete(false);
+ this.projectType = moduleType;
+ this.projectName = null;
+ }
+
+ /**
+ *
+ */
+ protected String[] getValidationPropertyNames() {
+ return new String[]{IArtifactEditOperationDataModelProperties.PROJECT_NAME,
+ IArtifactEditOperationDataModelProperties.COMPONENT_NAME,
+ INewJavaClassDataModelProperties.SOURCE_FOLDER,
+ INewJavaClassDataModelProperties.JAVA_PACKAGE,
+ INewJavaClassDataModelProperties.CLASS_NAME,
+ INewJavaClassDataModelProperties.SUPERCLASS};
+ }
+
+ /**
+ *
+ */
+ protected Composite createTopLevelComposite(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 3;
+ composite.setLayout(layout);
+ GridData data = new GridData();
+ data.verticalAlignment = GridData.FILL;
+ data.horizontalAlignment = GridData.FILL;
+ data.widthHint = 300;
+ composite.setLayoutData(data);
+
+ addProjectNameGroup(composite);
+ addFolderGroup(composite);
+ addSeperator(composite, 3);
+ addPackageGroup(composite);
+ addClassnameGroup(composite);
+ addSuperclassGroup(composite);
+
+ classText.setFocus();
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, getInfopopID());
+ Dialog.applyDialogFont(parent);
+ return composite;
+ }
+
+ /**
+ * Add project group
+ */
+ private void addProjectNameGroup(Composite parent) {
+ // set up project name label
+ projectNameLabel = new Label(parent, SWT.NONE);
+ projectNameLabel.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.MODULES_DEPENDENCY_PAGE_TABLE_PROJECT)); //$NON-NLS-1$
+ GridData data = new GridData();
+ projectNameLabel.setLayoutData(data);
+ // set up project name entry field
+ projectNameCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint = 300;
+ data.horizontalSpan = 1;
+ projectNameCombo.setLayoutData(data);
+ projectNameCombo.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ super.widgetSelected(e);
+ // update source folder
+ if (folderText != null) {
+ String sourceFolder = getDefaultJavaSourceFolder(ProjectUtilities.getProject(projectNameCombo.getText())).getFullPath().toOSString();
+ if (sourceFolder != null)
+ folderText.setText(sourceFolder);
+ }
+ }
+ });
+ synchHelper.synchCombo(projectNameCombo, IArtifactEditOperationDataModelProperties.PROJECT_NAME, null);
+ initializeProjectList();
+ new Label(parent, SWT.NONE);
+ }
+
+ /**
+ *
+ **/
+ private IFolder getDefaultJavaSourceFolder(IProject project) {
+
+ if (project == null)
+ return null;
+ IPackageFragmentRoot[] sources = J2EEProjectUtilities.getSourceContainers(project);
+ // Try and return the first source folder
+ if (sources.length > 0) {
+ try {
+ return (IFolder) sources[0].getCorrespondingResource();
+ } catch (Exception e) {
+ return null;
+ }
+ }
+ IJavaProject javaProject = JavaCore.create(project);
+ if (javaProject == null) {
+ return null;
+ }
+ try {
+ IClasspathEntry[] entries = javaProject.getResolvedClasspath(false);
+ for (int i = 0; i < entries.length; i++) {
+ IClasspathEntry entry = entries[i];
+ if (entry.getContentKind() == IPackageFragmentRoot.K_SOURCE) {
+ IPath path = entry.getPath();
+ IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
+ if (resource instanceof IFolder) {
+ return (IFolder) resource;
+ }
+ }
+ }
+ } catch (JavaModelException e) {
+ // ignore
+ }
+ return null;
+ }
+
+ /**
+ * This method is used by the project list initializer. The method checks
+ * if the specified project is valid to include it in the project list.
+ *
+ * <p>Subclasses of this wizard page should override this method to
+ * adjust filtering of the projects to their needs. </p>
+ *
+ * @param project reference to the project to be checked
+ *
+ * @return <code>true</code> if the project is valid to be included in
+ * the project list, <code>false</code> - otherwise.
+ */
+ protected boolean isProjectValid(IProject project) {
+ boolean result;
+ try {
+ result = project.isAccessible() &&
+ project.hasNature(IModuleConstants.MODULE_NATURE_ID) &&
+ J2EEProjectUtilities.getJ2EEProjectType(project).equals(projectType);
+ } catch (CoreException ce) {
+ result = false;
+ }
+ return result;
+ }
+
+ /**
+ *
+ */
+ private void initializeProjectList() {
+ IProject[] workspaceProjects = ProjectUtilities.getAllProjects();
+ List items = new ArrayList();
+ for (int i = 0; i < workspaceProjects.length; i++) {
+ IProject project = workspaceProjects[i];
+ if (isProjectValid(project))
+ items.add(project.getName());
+ }
+ if (items.isEmpty()) return;
+ String[] names = new String[items.size()];
+ for (int i = 0; i < items.size(); i++) {
+ names[i] = (String) items.get(i);
+ }
+ projectNameCombo.setItems(names);
+ IProject selectedProject = null;
+ try {
+ if (model !=null) {
+ String projectNameFromModel = model.getStringProperty(IArtifactEditOperationDataModelProperties.COMPONENT_NAME);
+ if (projectNameFromModel!=null && projectNameFromModel.length()>0)
+ selectedProject = ProjectUtilities.getProject(projectNameFromModel);
+ }
+ } catch (Exception e) {};
+ try {
+ if (selectedProject == null)
+ selectedProject = getSelectedProject();
+ if (selectedProject != null && selectedProject.isAccessible()
+ && selectedProject.hasNature(IModuleConstants.MODULE_NATURE_ID)) {
+ projectNameCombo.setText(selectedProject.getName());
+ model.setProperty(IArtifactEditOperationDataModelProperties.PROJECT_NAME, selectedProject.getName());
+ }
+ } catch (CoreException ce) {
+ // Ignore
+ }
+ if (projectName == null && names.length > 0)
+ projectName = names[0];
+
+ if ((projectNameCombo.getText() == null || projectNameCombo.getText().length() == 0) && projectName != null) {
+ projectNameCombo.setText(projectName);
+ model.setProperty(IArtifactEditOperationDataModelProperties.PROJECT_NAME, projectName);
+ }
+
+ }
+
+ /**
+ * Add folder group to composite
+ */
+ private void addFolderGroup(Composite composite) {
+ // folder
+ Label folderLabel = new Label(composite, SWT.LEFT);
+ folderLabel.setText(J2EEUIMessages.FOLDER_LABEL);
+ folderLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+
+ folderText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ folderText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ synchHelper.synchText(folderText, INewJavaClassDataModelProperties.SOURCE_FOLDER, null);
+
+ IPackageFragmentRoot root = getSelectedPackageFragmentRoot();
+ String projectName = model.getStringProperty(IArtifactEditOperationDataModelProperties.PROJECT_NAME);
+ if (projectName != null && projectName.length() > 0) {
+ IProject targetProject = ProjectUtilities.getProject(projectName);
+ if (root == null || !root.getJavaProject().getProject().equals(targetProject)) {
+ IFolder folder = getDefaultJavaSourceFolder(targetProject);
+ if (folder != null)
+ folderText.setText(folder.getFullPath().toOSString());
+ } else {
+ folderText.setText(root.getPath().toString());
+ }
+ }
+
+ folderButton = new Button(composite, SWT.PUSH);
+ folderButton.setText(J2EEUIMessages.BROWSE_BUTTON_LABEL);
+ folderButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+ folderButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ handleFolderButtonPressed();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // Do nothing
+ }
+ });
+ }
+
+ /**
+ * Add package group to composite
+ */
+ private void addPackageGroup(Composite composite) {
+ // package
+ packageLabel = new Label(composite, SWT.LEFT);
+ packageLabel.setText(J2EEUIMessages.JAVA_PACKAGE_LABEL);
+ packageLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+
+ packageText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ packageText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ synchHelper.synchText(packageText, INewJavaClassDataModelProperties.JAVA_PACKAGE, null);
+
+ IPackageFragment packageFragment = getSelectedPackageFragment();
+ String targetProject = model.getStringProperty(IArtifactEditOperationDataModelProperties.PROJECT_NAME);
+ if (packageFragment != null && packageFragment.exists() &&
+ packageFragment.getJavaProject().getElementName().equals(targetProject)) {
+ IPackageFragmentRoot root = getPackageFragmentRoot(packageFragment);
+ if (root != null)
+ folderText.setText(root.getPath().toString());
+ model.setProperty(INewJavaClassDataModelProperties.JAVA_PACKAGE, packageFragment.getElementName());
+ }
+
+ packageButton = new Button(composite, SWT.PUSH);
+ packageButton.setText(J2EEUIMessages.BROWSE_BUTTON_LABEL);
+ packageButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+ packageButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ handlePackageButtonPressed();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // Do nothing
+ }
+ });
+ }
+
+ protected IPackageFragmentRoot getPackageFragmentRoot(IPackageFragment packageFragment) {
+ if (packageFragment == null)
+ return null;
+ else if (packageFragment.getParent() instanceof IPackageFragment)
+ return getPackageFragmentRoot((IPackageFragment) packageFragment.getParent());
+ else if (packageFragment.getParent() instanceof IPackageFragmentRoot)
+ return (IPackageFragmentRoot) packageFragment.getParent();
+ else
+ return null;
+ }
+
+ /**
+ * Add classname group to composite
+ */
+ private void addClassnameGroup(Composite composite) {
+ // class name
+ classLabel = new Label(composite, SWT.LEFT);
+ classLabel.setText(J2EEUIMessages.CLASS_NAME_LABEL);
+ classLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+
+ classText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ classText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ synchHelper.synchText(classText, INewJavaClassDataModelProperties.CLASS_NAME, null);
+
+ new Label(composite, SWT.LEFT);
+ }
+
+ /**
+ * Add seperator to composite
+ */
+ protected void addSeperator(Composite composite, int horSpan) {
+ GridData data = new GridData();
+ data.verticalAlignment = GridData.FILL;
+ data.horizontalAlignment = GridData.FILL;
+ data.widthHint = 300;
+ // Separator label
+ Label seperator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
+ data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ data.horizontalSpan = horSpan;
+ seperator.setLayoutData(data);
+ }
+
+ /**
+ * Add superclass group to the composite
+ */
+ private void addSuperclassGroup(Composite composite) {
+ // superclass
+ superLabel = new Label(composite, SWT.LEFT);
+ superLabel.setText(J2EEUIMessages.SUPERCLASS_LABEL);
+ superLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+
+ superText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ superText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ synchHelper.synchText(superText, INewJavaClassDataModelProperties.SUPERCLASS, null);
+
+ superButton = new Button(composite, SWT.PUSH);
+ superButton.setText(J2EEUIMessages.BROWSE_BUTTON_LABEL);
+ superButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+ superButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ handleSuperButtonPressed();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // Do nothing
+ }
+ });
+ }
+
+ /**
+ * Browse for a new Destination Folder
+ */
+ protected void handleFolderButtonPressed() {
+ ISelectionStatusValidator validator = getContainerDialogSelectionValidator();
+ ViewerFilter filter = getContainerDialogViewerFilter();
+ ITreeContentProvider contentProvider = new WorkbenchContentProvider();
+ ILabelProvider labelProvider = new DecoratingLabelProvider(new WorkbenchLabelProvider(), PlatformUI.getWorkbench()
+ .getDecoratorManager().getLabelDecorator());
+ ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), labelProvider, contentProvider);
+ dialog.setValidator(validator);
+ dialog.setTitle(J2EEUIMessages.CONTAINER_SELECTION_DIALOG_TITLE);
+ dialog.setMessage(J2EEUIMessages.CONTAINER_SELECTION_DIALOG_DESC);
+ dialog.addFilter(filter);
+ String projectName = model.getStringProperty(IArtifactEditOperationDataModelProperties.PROJECT_NAME);
+ if (projectName==null || projectName.length()==0)
+ return;
+ IProject project = ProjectUtilities.getProject(projectName);
+ dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
+
+ if (project != null)
+ dialog.setInitialSelection(project);
+ if (dialog.open() == Window.OK) {
+ Object element = dialog.getFirstResult();
+ try {
+ if (element instanceof IContainer) {
+ IContainer container = (IContainer) element;
+ folderText.setText(container.getFullPath().toString());
+ // dealWithSelectedContainerResource(container);
+ }
+ } catch (Exception ex) {
+ // Do nothing
+ }
+
+ }
+ }
+
+ protected void handlePackageButtonPressed() {
+ IPackageFragmentRoot packRoot = (IPackageFragmentRoot) model.getProperty(INewJavaClassDataModelProperties.JAVA_PACKAGE_FRAGMENT_ROOT);
+ if (packRoot == null)
+ return;
+ IJavaElement[] packages = null;
+ try {
+ packages = packRoot.getChildren();
+ } catch (JavaModelException e) {
+ // Do nothing
+ }
+ if (packages == null)
+ packages = new IJavaElement[0];
+
+ ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), new JavaElementLabelProvider(
+ JavaElementLabelProvider.SHOW_DEFAULT));
+ dialog.setTitle(J2EEUIMessages.PACKAGE_SELECTION_DIALOG_TITLE);
+ dialog.setMessage(J2EEUIMessages.PACKAGE_SELECTION_DIALOG_DESC);
+ dialog.setEmptyListMessage(J2EEUIMessages.PACKAGE_SELECTION_DIALOG_MSG_NONE);
+ dialog.setElements(packages);
+ if (dialog.open() == Window.OK) {
+ IPackageFragment fragment = (IPackageFragment) dialog.getFirstResult();
+ if (fragment != null) {
+ packageText.setText(fragment.getElementName());
+ } else {
+ packageText.setText(J2EEUIMessages.EMPTY_STRING);
+ }
+ }
+ }
+
+ protected void handleSuperButtonPressed() {
+ getControl().setCursor(new Cursor(getShell().getDisplay(), SWT.CURSOR_WAIT));
+ IPackageFragmentRoot packRoot = (IPackageFragmentRoot) model.getProperty(INewJavaClassDataModelProperties.JAVA_PACKAGE_FRAGMENT_ROOT);
+ if (packRoot == null)
+ return;
+
+ // this eliminates the non-exported classpath entries
+ final IJavaSearchScope scope = TypeSearchEngine.createJavaSearchScopeForAProject(packRoot.getJavaProject(), true, true);
+
+ // This includes all entries on the classpath. This behavior is
+ // identical
+ // to the Super Class Browse Button on the Create new Java Class Wizard
+ // final IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new
+ // IJavaElement[] {root.getJavaProject()} );
+ FilteredTypesSelectionDialog dialog = new FilteredTypesSelectionDialog(getShell(),false, getWizard().getContainer(), scope, IJavaSearchConstants.CLASS);
+ dialog.setTitle(J2EEUIMessages.SUPERCLASS_SELECTION_DIALOG_TITLE);
+ dialog.setMessage(J2EEUIMessages.SUPERCLASS_SELECTION_DIALOG_DESC);
+
+ if (dialog.open() == Window.OK) {
+ IType type = (IType) dialog.getFirstResult();
+ String superclassFullPath = J2EEUIMessages.EMPTY_STRING;
+ if (type != null) {
+ superclassFullPath = type.getFullyQualifiedName();
+ }
+ superText.setText(superclassFullPath);
+ getControl().setCursor(null);
+ return;
+ }
+ getControl().setCursor(null);
+ }
+
+ /**
+ * Returns a new instance of the Selection validator for the Container
+ * Selection Dialog This method can be extended by subclasses, as it does
+ * some basic validation.
+ */
+ protected ISelectionStatusValidator getContainerDialogSelectionValidator() {
+ return new ISelectionStatusValidator() {
+ public IStatus validate(Object[] selection) {
+ if (selection != null && selection[0] != null && !(selection[0] instanceof IProject))
+ return WTPCommonPlugin.OK_STATUS;
+ return WTPCommonPlugin.createErrorStatus(J2EEUIMessages.CONTAINER_SELECTION_DIALOG_VALIDATOR_MESG);
+ }
+ };
+ }
+
+ /**
+ * Returns a new instance of the Selection Listner for the Container
+ * Selection Dialog
+ */
+ protected ViewerFilter getContainerDialogViewerFilter() {
+ return new ViewerFilter() {
+ public boolean select(Viewer viewer, Object parent, Object element) {
+ if (element instanceof IProject) {
+ IProject project = (IProject) element;
+ return project.getName().equals(model.getProperty(IArtifactEditOperationDataModelProperties.PROJECT_NAME));
+ } else if (element instanceof IFolder) {
+ IFolder folder = (IFolder) element;
+ // only show source folders
+ IProject project = ProjectUtilities.getProject(model.getStringProperty(IArtifactEditOperationDataModelProperties.PROJECT_NAME));
+ IPackageFragmentRoot[] sourceFolders = J2EEProjectUtilities.getSourceContainers(project);
+ for (int i = 0; i < sourceFolders.length; i++) {
+ if (sourceFolders[i].getResource()!= null && sourceFolders[i].getResource().equals(folder))
+ return true;
+ }
+ }
+ return false;
+ }
+ };
+ }
+
+
+
+ /**
+ * @return
+ */
+ private IProject getSelectedProject() {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window == null)
+ return null;
+ ISelection selection = window.getSelectionService().getSelection();
+ if (selection == null)
+ return null;
+ if (!(selection instanceof IStructuredSelection))
+ return null;
+ IStructuredSelection stucturedSelection = (IStructuredSelection) selection;
+ if (stucturedSelection.getFirstElement() instanceof EObject)
+ return ProjectUtilities.getProject(stucturedSelection.getFirstElement());
+ IJavaElement element = getInitialJavaElement(selection);
+ if (element != null && element.getJavaProject() != null)
+ return element.getJavaProject().getProject();
+ return getExtendedSelectedProject(stucturedSelection.getFirstElement());
+ }
+
+ protected IProject getExtendedSelectedProject(Object selection) {
+ return null;
+ }
+
+ /**
+ * @return
+ */
+ private IPackageFragment getSelectedPackageFragment() {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window == null)
+ return null;
+ ISelection selection = window.getSelectionService().getSelection();
+ if (selection == null)
+ return null;
+ IJavaElement element = getInitialJavaElement(selection);
+ if (element != null) {
+ if (element.getElementType() == IJavaElement.PACKAGE_FRAGMENT) {
+ return (IPackageFragment) element;
+ } else if (element.getElementType() == IJavaElement.COMPILATION_UNIT) {
+ IJavaElement parent = ((ICompilationUnit) element).getParent();
+ if (parent.getElementType() == IJavaElement.PACKAGE_FRAGMENT) {
+ return (IPackageFragment) parent;
+ }
+ } else if (element.getElementType() == IJavaElement.TYPE) {
+ return ((IType) element).getPackageFragment();
+ }
+ }
+ return null;
+ }
+
+ private IPackageFragmentRoot getSelectedPackageFragmentRoot() {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window == null)
+ return null;
+ ISelection selection = window.getSelectionService().getSelection();
+ if (selection == null)
+ return null;
+ // StructuredSelection stucturedSelection = (StructuredSelection)
+ // selection;
+ IJavaElement element = getInitialJavaElement(selection);
+ if (element != null) {
+ if (element.getElementType() == IJavaElement.PACKAGE_FRAGMENT_ROOT)
+ return (IPackageFragmentRoot) element;
+ }
+ return null;
+ }
+
+ /**
+ * Utility method to inspect a selection to find a Java element.
+ *
+ * @param selection
+ * the selection to be inspected
+ * @return a Java element to be used as the initial selection, or
+ * <code>null</code>, if no Java element exists in the given
+ * selection
+ */
+ protected IJavaElement getInitialJavaElement(ISelection selection) {
+ IJavaElement jelem = null;
+ if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
+ Object selectedElement = ((IStructuredSelection) selection).getFirstElement();
+ if (selectedElement instanceof IAdaptable) {
+ IAdaptable adaptable = (IAdaptable) selectedElement;
+
+ jelem = (IJavaElement) adaptable.getAdapter(IJavaElement.class);
+ if (jelem == null) {
+ IResource resource = (IResource) adaptable.getAdapter(IResource.class);
+ if (resource != null && resource.getType() != IResource.ROOT) {
+ while (jelem == null && resource.getType() != IResource.PROJECT) {
+ resource = resource.getParent();
+ jelem = (IJavaElement) resource.getAdapter(IJavaElement.class);
+ }
+ if (jelem == null) {
+ jelem = JavaCore.create(resource); // java project
+ }
+ }
+ }
+ }
+ }
+ if (jelem == null) {
+ IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window == null)
+ return null;
+ IWorkbenchPart part = window.getActivePage().getActivePart();
+ if (part instanceof ContentOutline) {
+ part = window.getActivePage().getActiveEditor();
+ }
+
+ if (part instanceof IViewPartInputProvider) {
+ Object elem = ((IViewPartInputProvider) part).getViewPartInput();
+ if (elem instanceof IJavaElement) {
+ jelem = (IJavaElement) elem;
+ }
+ }
+ }
+
+ if (jelem == null || jelem.getElementType() == IJavaElement.JAVA_MODEL) {
+ try {
+ IJavaProject[] projects = JavaCore.create(getWorkspaceRoot()).getJavaProjects();
+ if (projects.length == 1) {
+ jelem = projects[0];
+ }
+ } catch (JavaModelException e) {
+ PortletUIActivator.log(e);
+ }
+ }
+ return jelem;
+ }
+
+ protected IWorkspaceRoot getWorkspaceRoot() {
+ return ResourcesPlugin.getWorkspace().getRoot();
+ }
+
+ public void setProjectName(String projectName) {
+ this.projectName = projectName;
+ }
+
+}
16 years, 3 months
JBoss Tools SVN: r9969 - in trunk: common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util and 29 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-08-29 20:06:07 -0400 (Fri, 29 Aug 2008)
New Revision: 9969
Modified:
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbProposal.java
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldConvertor.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/templates/configuration/MetaConfigurationLoader.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/OpenWithExternalBrowserHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/OpenWithExternalHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/MetaLibLoader.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XMetaDataLoader.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/documentation/DocumentGenerator.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/JarAccess.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/icons/impl/XStudioIcons.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelObjectImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/DefaultSiftedTree.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/SwitchPreference.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/SharableLoaderImpl.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/OSHelper.java
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/contentassist/ContentAssistProcessorDefinition.java
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/ui/FreeCaretStyledText.java
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/xpl/ToggleOccurencesMarkUpAction.java
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/jst/jsp/text/xpl/DefaultStructuredTextOccurrenceStructureProvider.java
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/core/resources/MarkerClearer.java
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/impl/VTaskImpl.java
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/RuleSetResourceLoader.java
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VManagerModel.java
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VResultModel.java
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VResultTemplateModel.java
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRuleModel.java
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRuleSetModel.java
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRuleSetsLoader.java
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRulesTree.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/CommonPlugin.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/FileUtil.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLEntityResolverImpl.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.view/src/org/jboss/tools/hibernate/wizard/hibernateconnection/TestUrlClassLoader.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInsertTemplate.java
trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFPromptingProviderTestProject/WebContent/WEB-INF/faces-config-1.xml
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/ImageSelectionDialog.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamMessagesLoader.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/NodesManagingUtil.java
Log:
PMD violations fixed.
InputStreams close() added where it was possible.
Modified: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/CommonPlugin.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/CommonPlugin.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/CommonPlugin.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -70,13 +70,15 @@
if(eclipse!=null) {
Dictionary eclipseDic = eclipse.getHeaders();
eclipseVersion = (String)eclipseDic.get("Bundle-Version");
+ FileInputStream fis = null;
try {
String path = FileLocator.resolve(eclipse.getEntry("/")).getPath();
if(path!=null) {
File aboutMappings = new File(path, "about.mappings");
if(aboutMappings.exists()) {
Properties properties = new Properties();
- properties.load(new FileInputStream(aboutMappings));
+ fis = new FileInputStream(aboutMappings);
+ properties.load(fis);
String buildId = properties.getProperty("0");
if(buildId!=null && buildId.length()>0) {
eclipseBuildId = buildId;
@@ -85,6 +87,14 @@
}
} catch (IOException e) {
getPluginLog().logError("Error in getting environment info: " + e.getMessage());
+ } finally {
+ if(fis!=null) {
+ try {
+ fis.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
}
}
StringBuffer result = new StringBuffer(studioName).append(" ").append(studioVersion).
Modified: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/FileUtil.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/FileUtil.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/FileUtil.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -62,9 +62,10 @@
public static ReadBytes readBytes(File f) {
if(!f.isFile()) return null;
+ BufferedInputStream br = null;
try {
FileInputStream fr = new FileInputStream(f);
- BufferedInputStream br = new BufferedInputStream(fr);
+ br = new BufferedInputStream(fr);
int l = (int)f.length();
byte[] bs = new byte[l];
l = br.read(bs, 0, l);
@@ -73,6 +74,14 @@
return new ReadBytes(bs, l);
} catch (IOException e) {
return null;
+ } finally {
+ if(br!=null) {
+ try {
+ br.close();
+ } catch (IOException e) {
+ //ignore
+ }
+ }
}
}
@@ -98,9 +107,10 @@
public static boolean isTextFile(File f, int length) {
if(!f.isFile()) return false;
+ BufferedReader br = null;
try {
FileReader fr = new FileReader(f);
- BufferedReader br = new BufferedReader(fr);
+ br = new BufferedReader(fr);
int l = (int)f.length();
if(l > length) l = length;
char[] cs = new char[l];
@@ -110,6 +120,14 @@
return isText(new String(cs));
} catch (IOException e) {
return false;
+ } finally {
+ if(br!=null) {
+ try {
+ br.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
}
}
Modified: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLEntityResolverImpl.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLEntityResolverImpl.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLEntityResolverImpl.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -38,12 +38,13 @@
XMLInputSource result = null;
String systemId = null;
String publicId = null;
+ InputStream is = null;
try {
DtdResolver resolver = new DtdResolver();
systemId = rid.getBaseSystemId()==null?rid.getLiteralSystemId():rid.getExpandedSystemId();
publicId = rid.getPublicId();
- InputStream is = resolver.getInputStream(rid.getPublicId(), systemId);
+ is = resolver.getInputStream(rid.getPublicId(), systemId);
if(is!=null) {
result = new XMLInputSource(rid.getPublicId(), systemId, rid.getBaseSystemId(), is, null);
}
Modified: trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbProposal.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbProposal.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbProposal.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -163,10 +163,7 @@
* @return
*/
public boolean isCloseTag() {
- if((label!=null)&&(label.startsWith("/"))) {
- return true;
- }
- return false;
+ return label != null && label.startsWith("/");
}
/**
Modified: trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldConvertor.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldConvertor.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldConvertor.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -93,7 +93,18 @@
}
return null;
}
- Document doc = convertToSchema(is, attributes, tldResource.isJsfResource());
+ Document doc = null;
+ try {
+ doc = convertToSchema(is, attributes, tldResource.isJsfResource());
+ } finally {
+ if(is!=null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
String tldContent = tldResource.getTldContent();
if(doc!=null && tldContent!=null) {
Element tldContentElement = doc.createElement(SchemaNodeFactory.TLD_CONTENT_NODE);
@@ -108,11 +119,21 @@
* @see org.jboss.tools.common.kb.KbSchemaConvertor#convertToSchema(java.io.File)
*/
public Document convertToSchema(File tldFile) {
+ BufferedInputStream bis = null;
try {
- return convertToSchema(new BufferedInputStream(new FileInputStream(tldFile)), new Properties(), false);
+ bis = new BufferedInputStream(new FileInputStream(tldFile));
+ return convertToSchema(bis, new Properties(), false);
} catch (FileNotFoundException e) {
KbPlugin.getPluginLog().logError(e);
return null;
+ } finally {
+ if(bis!=null) {
+ try {
+ bis.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
}
}
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/OpenWithExternalBrowserHandler.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/OpenWithExternalBrowserHandler.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/OpenWithExternalBrowserHandler.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -16,40 +16,6 @@
public OpenWithExternalBrowserHandler() {}
- /*
- public boolean isEnabled(XModelObject object) {
- if(object == null || object.getFileType() != object.FILE) return false;
- String s = getEditorName(object);
- boolean b = (s != null);
- if(!b) s = "?";
- ((XActionImpl)action).setDisplayName(s);
- return b;
- }
-
- public void executeHandler(XModelObject object, Properties p) throws XModelException {
- if(!isEnabled(object)) return;
- String f = getFileName(object);
- String ext = OpenWithHelper.getExtension(f);
- XModelObject editor = OpenWithHelper.getEditorObject(object.getModel(), ext);
- if(editor == null) throw new RuntimeException("External editor for file extension '" + ext + "' is not set.");
- start(action.getDisplayName(), f, editor);
- }
-
- protected String getFileName(XModelObject object) {
- return OpenWithHelper.getFileName(object);
- }
- */
-
-// private String getEditorName(XModelObject object) {
-// XModelObject o = object.getModel().getByPath(OpenWithHelper.EDITORS);
-// String[] es = XModelObjectUtil.asStringArray(o.getAttributeValue("extensions"));
-// for (int i = 0; i < es.length; i++) {
-// if(!es[i].toLowerCase().startsWith("html:")) continue;
-// return es[i].substring("html:".length());
-// }
-// return null;
-// }
-
public static void start(String actionname, String url, XModelObject editor) throws XModelException {
if(OpenWithHelper.validatePath(actionname, editor)) new OWEProcess(editor, url).start();
}
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/OpenWithExternalHandler.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/OpenWithExternalHandler.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/action/impl/handlers/OpenWithExternalHandler.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -74,7 +74,7 @@
public static void start(String actionname, String filename, XModelObject editor) throws XModelException {
int i = filename.indexOf('#');
String fn = (i < 0) ? filename : filename.substring(0, i);
- if(!new File(fn).isFile()) throw new RuntimeException("Cannot find file " + fn + ".");
+ if(!new File(fn).isFile()) throw new IllegalArgumentException("Cannot find file " + fn + ".");
if(OpenWithHelper.validatePath(actionname, editor)) new OWEProcess(editor, filename).start();
}
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/MetaLibLoader.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/MetaLibLoader.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/MetaLibLoader.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -90,29 +90,40 @@
void load(String name, URL url) {
if(url == null) return;
// long t = System.currentTimeMillis();
- InputStream stream = null;
+ InputStream stream1 = null;
+ InputStream stream2 = null;
try {
- stream = url.openStream();
- stream = new BufferedInputStream(stream, 16384);
+ stream1 = url.openStream();
+ stream2 = new BufferedInputStream(stream1, 16384);
+
+
+ Element g = parse(stream2);
+ if(g == null) {
+ ModelPlugin.getPluginLog().logInfo("Corrupted meta resource " + name);
+ } else {
+ load0(g, name, url.toString());
+ }
+
} catch (IOException e) {
ModelPlugin.getPluginLog().logError("MetaLoader: Cannot read resource " + url.toString());
return;
+ } finally {
+ if(stream2!=null) {
+ try {
+ stream2.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
}
- Element g = parse(stream);
- //XMLUtil.getElement(stream);
- if(g == null) {
- ModelPlugin.getPluginLog().logInfo("Corrupted meta resource " + name);
- } else {
- load0(g, name, url.toString());
- }
-
// long dt = - t + (t = System.currentTimeMillis());
// System.out.println("Loaded " + url + " in " + dt + " ms");
if(validateMetaXML) {
+ InputStream stream3 = null;
try {
- stream = url.openStream();
- InputSource is = new InputSource(stream);
+ stream3 = url.openStream();
+ InputSource is = new InputSource(stream3);
String[] errors = XMLUtil.getXMLErrors(is, true);
if(errors != null && errors.length > 0) {
ModelPlugin.getPluginLog().logInfo("Errors in " + name);
@@ -122,6 +133,14 @@
}
} catch (IOException e) {
ModelPlugin.getPluginLog().logError(e);
+ }finally {
+ if(stream3!=null) {
+ try {
+ stream3.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
}
// dt = - t + (t = System.currentTimeMillis());
// System.out.println("Validated " + url + " in " + dt + " ms");
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XMetaDataLoader.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XMetaDataLoader.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/XMetaDataLoader.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.common.meta.impl;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.*;
import org.w3c.dom.*;
@@ -102,9 +103,9 @@
// meta data loading
- static Element loadDocument(String filename) {
+ static Element loadDocument(String filename) throws FileNotFoundException {
Element e = XMLUtil.getElement(filename);
- if(e == null) throw new RuntimeException("Can't load meta model from " + filename);
+ if(e == null) throw new FileNotFoundException("Can't load meta model from " + filename);
return e;
}
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/documentation/DocumentGenerator.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/documentation/DocumentGenerator.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/documentation/DocumentGenerator.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -273,8 +273,9 @@
protected void replace() {
StringBuffer sb = new StringBuffer();
+ BufferedReader br = null;
try {
- BufferedReader br = new BufferedReader(new FileReader(new File(filename)));
+ br = new BufferedReader(new FileReader(new File(filename)));
char[] b = new char[256];
int i = 0;
while((i = br.read(b, 0, 256)) > 0) {
@@ -282,7 +283,15 @@
}
} catch (IOException e) {
ModelPlugin.getPluginLog().logError(e);
- }
+ } finally {
+ try {
+ if(br!=null) {
+ br.close();
+ }
+ } catch (IOException e) {
+ // ignore
+ }
+ }
int i = 0;
while(i < sb.length()) {
if(sb.charAt(i) == '&') sb.replace(i + 1, i + 5, "");
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/JarAccess.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/JarAccess.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/JarAccess.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -190,9 +190,10 @@
return "";
}
int length = 0;
+ BufferedInputStream bs = null;
try {
InputStream is = jar.getInputStream(jar.getEntry(path));
- BufferedInputStream bs = new BufferedInputStream(is);
+ bs = new BufferedInputStream(is);
while ((length = bs.available()) > 0) {
if (length > size)
length = size;
@@ -207,6 +208,13 @@
return "";
} finally {
unlockJar();
+ if(bs!=null) {
+ try {
+ bs.close();
+ } catch (IOException e) {
+ //ignore
+ }
+ }
}
}
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/icons/impl/XStudioIcons.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/icons/impl/XStudioIcons.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/icons/impl/XStudioIcons.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -55,8 +55,9 @@
File f = new File(filename);
if(!f.isFile()) return new byte[0];
byte[] b = null;
+ FileInputStream fr = null;
try {
- FileInputStream fr = new FileInputStream(f);
+ fr = new FileInputStream(f);
int length = fr.available();
b = new byte[length];
int i = 0;
@@ -65,6 +66,14 @@
}
} catch (IOException e) {
b = new byte[0];
+ } finally {
+ if(fr != null) {
+ try {
+ fr.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
}
return b;
}
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelImpl.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelImpl.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelImpl.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -438,7 +438,7 @@
public void setExtraRoot(XModelObject r) {
String pathpart = r.getPathPart();
- if(!pathpart.startsWith("root:")) throw new RuntimeException("Not extra root: " + pathpart);
+ if(!pathpart.startsWith("root:")) throw new IllegalArgumentException("Not extra root: " + pathpart);
extraroots.put(pathpart, r);
}
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelObjectImpl.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelObjectImpl.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/XModelObjectImpl.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -10,19 +10,29 @@
******************************************************************************/
package org.jboss.tools.common.model.impl;
-import java.io.*;
-import java.util.*;
-import org.eclipse.core.resources.*;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IActionFilter;
import org.eclipse.ui.views.properties.IPropertySource;
-
-import org.jboss.tools.common.meta.*;
-import org.jboss.tools.common.model.*;
+import org.jboss.tools.common.meta.XAttribute;
+import org.jboss.tools.common.meta.XMapping;
+import org.jboss.tools.common.meta.XModelEntity;
+import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.XModelException;
+import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.adapter.IModelObjectAdapter;
import org.jboss.tools.common.model.adapter.ModelObjectAdapterExtensionPoint;
-import org.jboss.tools.common.model.icons.impl.*;
+import org.jboss.tools.common.model.icons.impl.XModelObjectIcon;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
public class XModelObjectImpl implements XModelObject, Serializable, Cloneable {
@@ -54,9 +64,9 @@
public void changeEntity(String name) {
if(entity.getName().equals(name)) return;
XModelEntity newEntity = entity.getMetaModel().getEntity(name);
- if(newEntity == null) throw new RuntimeException("Entity " + name + " does not exist.");
+ if(newEntity == null) throw new IllegalArgumentException("Entity " + name + " does not exist.");
if(entity.getImplementingClass() != newEntity.getImplementingClass()) {
- throw new RuntimeException("Cannot convert entity " + entity.getName() + " to " + name + " because they have different implementations.");
+ throw new IllegalArgumentException("Cannot convert entity " + entity.getName() + " to " + name + " because they have different implementations.");
}
Properties p = new Properties();
XAttribute[] as = entity.getAttributes();
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/DefaultSiftedTree.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/DefaultSiftedTree.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/impl/trees/DefaultSiftedTree.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -10,7 +10,10 @@
******************************************************************************/
package org.jboss.tools.common.model.impl.trees;
-import org.jboss.tools.common.model.*;
+import org.jboss.tools.common.MethodNotImplementedException;
+import org.jboss.tools.common.model.XFilteredTree;
+import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.XModelObject;
public abstract class DefaultSiftedTree implements XFilteredTree {
@@ -38,17 +41,17 @@
}
public boolean isSelectable(XModelObject object) {
- throw new RuntimeException("Not implemented");
+ throw new MethodNotImplementedException("Not implemented");
}
public String getValue(XModelObject object) {
- throw new RuntimeException("Not implemented");
+ throw new MethodNotImplementedException("Not implemented");
}
public void setConstraint(Object object) {}
public XModelObject find(String value) {
- throw new RuntimeException("Not implemented");
+ throw new MethodNotImplementedException("Not implemented");
}
public XModelObject getParent(XModelObject object) {
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/SwitchPreference.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/SwitchPreference.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/SwitchPreference.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -6,7 +6,11 @@
*/
package org.jboss.tools.common.model.options;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.List;
import org.jboss.tools.common.model.XModelException;
@@ -47,7 +51,7 @@
}
public void setValue(String value) throws XModelException {
- if(switchPreference==null) throw new NullPointerException("switchPreference cannot be null, call setSwitchPreferenceFirst.");
+ if(switchPreference==null) throw new IllegalStateException("switchPreference cannot be null, call setSwitchPreferenceFirst.");
Preference preference = (Preference)preferencesMap.get(switchPreference.getValue());
if(preference==null) throw new IllegalStateException("Preference in't added for switch value '" + switchPreference.getValue() + "'");
preference.setValue(value);
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/SharableLoaderImpl.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/SharableLoaderImpl.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/options/impl/SharableLoaderImpl.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -10,13 +10,19 @@
******************************************************************************/
package org.jboss.tools.common.model.options.impl;
-import java.util.*;
-import org.w3c.dom.*;
-import org.jboss.tools.common.meta.*;
+import java.util.Properties;
+
+import org.jboss.tools.common.meta.XAttribute;
+import org.jboss.tools.common.meta.XChild;
+import org.jboss.tools.common.meta.XModelEntity;
import org.jboss.tools.common.model.XModelConstants;
-import org.jboss.tools.common.model.options.*;
+import org.jboss.tools.common.model.options.SharableConstants;
+import org.jboss.tools.common.model.options.SharableElement;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
public class SharableLoaderImpl implements SharableConstants {
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/OSHelper.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/OSHelper.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/OSHelper.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -19,6 +19,7 @@
* @version 1.0
*/
+import java.io.IOException;
import java.util.*;
import org.jboss.tools.common.model.plugin.ModelPlugin;
@@ -88,6 +89,14 @@
}
} catch (java.io.IOException e) {
ModelPlugin.getPluginLog().logError(e);
+ } finally {
+ if(br!=null) {
+ try {
+ br.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
}
return envVars;
}
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/templates/configuration/MetaConfigurationLoader.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/templates/configuration/MetaConfigurationLoader.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/templates/configuration/MetaConfigurationLoader.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -166,13 +166,22 @@
if (path!=null) {
File propertiesFile = path.toFile();
if (propertiesFile.exists() && propertiesFile.canRead()) {
+ InputStream is = null;
try {
- InputStream is = new FileInputStream(propertiesFile);
+ is = new FileInputStream(propertiesFile);
properties = new PropertyResourceBundle(is);
} catch (FileNotFoundException e) {
ModelUIPlugin.getPluginLog().logError(e);
} catch (IOException e) {
ModelUIPlugin.getPluginLog().logError(e);
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
}
}
}
Modified: trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/contentassist/ContentAssistProcessorDefinition.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/contentassist/ContentAssistProcessorDefinition.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/contentassist/ContentAssistProcessorDefinition.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -112,7 +112,7 @@
try {
result[0] = element.createExecutableExtension(name);
}
- catch (Exception e) {
+ catch (CoreException e) {
handleCreateExecutableException(result, e);
}
}
Modified: trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/ui/FreeCaretStyledText.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/ui/FreeCaretStyledText.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/ui/FreeCaretStyledText.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -67,32 +67,23 @@
}
public void redrawRange(int start, int length, boolean clearBackground) {
- try {
+ //FIX for JBIDE-1479 added by Max Areshkau
+ if (start > getCharCount())
+ start = getCharCount();
+ if (start + length > getCharCount())
+ length = getCharCount() - start;
+
+ //FIX for JBIDE-2192
+ if (length > 0) {
super.redrawRange(start, length, clearBackground);
- } catch (Exception x) {
- // ignore
- //FIX for JBIDE-1479 added by Max Areshkau
- if (start > getCharCount())
- start = getCharCount();
- if (start + length > getCharCount())
- length = getCharCount() - start;
-
- //FIX for JBIDE-2192
- if (length > 0) {
- super.redrawRange(start, length, clearBackground);
- }
}
}
public int getLineAtOffset(int offset) {
- try {
- return super.getLineAtOffset(offset);
- } catch (Exception e) {
- if (offset > getCharCount())
- offset = getCharCount();
- if (offset < 0)
- offset = 0;
- return super.getLineAtOffset(offset);
- }
+ if (offset > getCharCount())
+ offset = getCharCount();
+ if (offset < 0)
+ offset = 0;
+ return super.getLineAtOffset(offset);
}
}
Modified: trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/xpl/ToggleOccurencesMarkUpAction.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/xpl/ToggleOccurencesMarkUpAction.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/xpl/ToggleOccurencesMarkUpAction.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -12,6 +12,7 @@
*******************************************************************************/
package org.jboss.tools.common.text.xml.xpl;
+import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ResourceBundle;
@@ -24,7 +25,6 @@
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.TextEditorAction;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
-
import org.jboss.tools.common.text.xml.IOccurrencePreferenceProvider;
import org.jboss.tools.common.text.xml.XmlEditorPlugin;
import org.jboss.tools.jst.jsp.preferences.xpl.Messages;
@@ -56,20 +56,16 @@
*/
public void setEditor(ITextEditor editor) {
super.setEditor(editor);
- try {
- fOccurrencePreferenceProvider = null;
- StructuredTextEditor sse = getStructuredTextEditor(getTextEditor());
- if (sse != null && sse instanceof IOccurrencePreferenceProvider) {
- fOccurrencePreferenceProvider = (IOccurrencePreferenceProvider)sse;
- if (fOccurrencePreferenceProvider != null) {
- fEditorId = fOccurrencePreferenceProvider.getOccurrencePreferenceProvider().getEditorId();
- fKey = PreferenceKeyGenerator.generateKey(
- OccurrencePreferenceConstants.EDITOR_MARK_OCCURRENCES,
- fEditorId);
- }
+ fOccurrencePreferenceProvider = null;
+ StructuredTextEditor sse = getStructuredTextEditor(getTextEditor());
+ if (sse != null && sse instanceof IOccurrencePreferenceProvider) {
+ fOccurrencePreferenceProvider = (IOccurrencePreferenceProvider)sse;
+ if (fOccurrencePreferenceProvider != null) {
+ fEditorId = fOccurrencePreferenceProvider.getOccurrencePreferenceProvider().getEditorId();
+ fKey = PreferenceKeyGenerator.generateKey(
+ OccurrencePreferenceConstants.EDITOR_MARK_OCCURRENCES,
+ fEditorId);
}
- } catch (Exception x) {
- XmlEditorPlugin.getPluginLog().logError(x);
}
update();
}
@@ -125,13 +121,9 @@
public void run() {
boolean markOccurences = false;
- try {
- // determine if action should be enabled or not
- markOccurences = fPreferenceStore.getBoolean(fKey);
- fPreferenceStore.setValue(fKey, !markOccurences);
- } catch (Exception x) {
- //ignore
- }
+ // determine if action should be enabled or not
+ markOccurences = fPreferenceStore.getBoolean(fKey);
+ fPreferenceStore.setValue(fKey, !markOccurences);
}
/**
@@ -140,19 +132,14 @@
*/
public void update() {
IPreferenceStore newStore = null;
-
- try {
- super.update();
- newStore = (fOccurrencePreferenceProvider == null ? null : fOccurrencePreferenceProvider.getOccurrencePreferenceProvider().getPreferenceStore());
- if (newStore != fPreferenceStore) {
- if (fPreferenceStore != null)
- fPreferenceStore.removePropertyChangeListener(this);
- fPreferenceStore = newStore;
- if (fPreferenceStore != null)
- fPreferenceStore.addPropertyChangeListener(this);
- }
- } catch (Exception x) {
- //ignore
+ super.update();
+ newStore = (fOccurrencePreferenceProvider == null ? null : fOccurrencePreferenceProvider.getOccurrencePreferenceProvider().getPreferenceStore());
+ if (newStore != fPreferenceStore) {
+ if (fPreferenceStore != null)
+ fPreferenceStore.removePropertyChangeListener(this);
+ fPreferenceStore = newStore;
+ if (fPreferenceStore != null)
+ fPreferenceStore.addPropertyChangeListener(this);
}
boolean markOccurences = false;
@@ -183,7 +170,7 @@
URL base = null;
try {
base = FileLocator.resolve(XmlEditorPlugin.getDefault().getBundle().getEntry("/"));
- } catch (Exception e) {
+ } catch (IOException e) {
XmlEditorPlugin.getPluginLog().logError(e);
return null;
}
Modified: trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/jst/jsp/text/xpl/DefaultStructuredTextOccurrenceStructureProvider.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/jst/jsp/text/xpl/DefaultStructuredTextOccurrenceStructureProvider.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/jst/jsp/text/xpl/DefaultStructuredTextOccurrenceStructureProvider.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -56,17 +56,17 @@
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMText;
-import org.w3c.dom.Document;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
import org.jboss.tools.common.text.xml.XmlEditorPlugin;
import org.jboss.tools.common.text.xml.ui.xpl.ISelectionListenerWithSM;
import org.jboss.tools.common.text.xml.ui.xpl.SelectionListenerWithSMManager;
import org.jboss.tools.common.text.xml.ui.xpl.UIMessages;
import org.jboss.tools.jst.jsp.preferences.xpl.PreferenceKeyGenerator;
import org.jboss.tools.jst.jsp.preferences.xpl.XMLOccurrencePreferenceConstants;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
/**
* @author Jeremy
@@ -353,7 +353,6 @@
* @see com.ibm.sse.editor.ui.text.IStructuredTextOccurenceStructureProvider#install(org.eclipse.ui.texteditor.ITextEditor, org.eclipse.jface.text.source.projection.ProjectionViewer)
*/
public void install(StructuredTextEditor editor, ProjectionViewer viewer) {
- // TODO Auto-generated method stub
this.fEditor = editor;
this.fViewer = viewer;
@@ -368,7 +367,6 @@
* @see com.ibm.sse.editor.ui.text.IStructuredTextOccurenceStructureProvider#uninstall()
*/
public void uninstall() {
- // TODO Auto-generated method stub
// cancel possible running computation
fMarkOccurrenceAnnotations= false;
uninstallOccurrencesFinder();
@@ -380,43 +378,37 @@
* @see com.ibm.sse.editor.ui.text.IStructuredTextOccurenceStructureProvider#initialize()
*/
public void initialize() {
- // Initialize preferences
- try {
- fPreferenceStore.addPropertyChangeListener(fPropertyChangeListener);
+ fPreferenceStore.addPropertyChangeListener(fPropertyChangeListener);
- fMarkOccurrenceAnnotations = fPreferenceStore.getBoolean(PreferenceKeyGenerator.generateKey(
- XMLOccurrencePreferenceConstants.EDITOR_MARK_OCCURRENCES,
- fEditorID));
+ fMarkOccurrenceAnnotations = fPreferenceStore.getBoolean(PreferenceKeyGenerator.generateKey(
+ XMLOccurrencePreferenceConstants.EDITOR_MARK_OCCURRENCES,
+ fEditorID));
- fMarkNodeOccurrences =
- fPreferenceStore.getBoolean(PreferenceKeyGenerator.generateKey(
- XMLOccurrencePreferenceConstants.EDITOR_MARK_NODE_OCCURRENCES,
- fEditorID));
+ fMarkNodeOccurrences =
+ fPreferenceStore.getBoolean(PreferenceKeyGenerator.generateKey(
+ XMLOccurrencePreferenceConstants.EDITOR_MARK_NODE_OCCURRENCES,
+ fEditorID));
-
- fMarkAttributeOccurrences =
- fPreferenceStore.getBoolean(PreferenceKeyGenerator.generateKey(
- XMLOccurrencePreferenceConstants.EDITOR_MARK_ATTRIBUTE_OCCURRENCES,
- fEditorID));
+
+ fMarkAttributeOccurrences =
+ fPreferenceStore.getBoolean(PreferenceKeyGenerator.generateKey(
+ XMLOccurrencePreferenceConstants.EDITOR_MARK_ATTRIBUTE_OCCURRENCES,
+ fEditorID));
- fMarkAttributeValueOccurrences =
- fPreferenceStore.getBoolean(PreferenceKeyGenerator.generateKey(
- XMLOccurrencePreferenceConstants.EDITOR_MARK_ATTRIBUTE_VALUE_OCCURRENCES,
- fEditorID));
+ fMarkAttributeValueOccurrences =
+ fPreferenceStore.getBoolean(PreferenceKeyGenerator.generateKey(
+ XMLOccurrencePreferenceConstants.EDITOR_MARK_ATTRIBUTE_VALUE_OCCURRENCES,
+ fEditorID));
- fMarkTextOccurrences =
- fPreferenceStore.getBoolean(PreferenceKeyGenerator.generateKey(
- XMLOccurrencePreferenceConstants.EDITOR_MARK_TEXT_OCCURRENCES,
- fEditorID));
+ fMarkTextOccurrences =
+ fPreferenceStore.getBoolean(PreferenceKeyGenerator.generateKey(
+ XMLOccurrencePreferenceConstants.EDITOR_MARK_TEXT_OCCURRENCES,
+ fEditorID));
- fStickyOccurrenceAnnotations =
- fPreferenceStore.getBoolean(PreferenceKeyGenerator.generateKey(
- XMLOccurrencePreferenceConstants.EDITOR_STICKY_OCCURRENCES,
- fEditorID));
-
- } catch (Exception x) {
- XmlEditorPlugin.getPluginLog().logError(x);
- }
+ fStickyOccurrenceAnnotations =
+ fPreferenceStore.getBoolean(PreferenceKeyGenerator.generateKey(
+ XMLOccurrencePreferenceConstants.EDITOR_STICKY_OCCURRENCES,
+ fEditorID));
}
ProjectionViewer getSourceViewer() {
@@ -512,18 +504,15 @@
Document dom = (model instanceof IDOMModel) ? ((IDOMModel) model).getDocument() : null;
List matches = findMatches(dom, model, selection);
-// System.out.println("Matches size = " + (matches == null || matches.size() == 0 ? 0 : matches.size()));
if (matches == null || matches.size() == 0) {
if (!fStickyOccurrenceAnnotations)
removeOccurrenceAnnotations();
return;
}
-// Position[] positions= new Position[matches.size()];
List positionsList = new ArrayList();
int i= 0;
for (Iterator each= matches.iterator(); each.hasNext();) {
-// ASTNode currentNode= (ASTNode)each.next();
Object current = each.next();
if (current instanceof IDOMElement) {
IDOMElement currentNode = (IDOMElement)current;
@@ -539,24 +528,17 @@
positionsList.add(new Position(start, end - start));
}
-// positions[i++]= new Position(currentNode.getStartOffset(), currentNode.getEndOffset() - currentNode.getStartOffset());
} else if (current instanceof ITextRegion) {
ITextRegion currentRegion = (ITextRegion)current;
positionsList.add(new Position(currentRegion.getStart(), currentRegion.getLength()));
-// positions[i++]= new Position(currentRegion.getStart(), currentRegion.getLength());
} else if (current instanceof Position) {
Position currentPosition = (Position)current;
positionsList.add(new Position(currentPosition.getOffset(), currentPosition.getLength()));
-// positions[i++]= new Position(currentPosition.getOffset(), currentPosition.getLength());
}
}
if (positionsList.size() == 0) return;
-// removeOccurrenceAnnotations();
fOccurrencesFinderJob= new OccurrencesFinderJob(document,
(Position[])positionsList.toArray(new Position[positionsList.size()]), selection);
- //fOccurrencesFinderJob.setPriority(Job.DECORATE);
- //fOccurrencesFinderJob.setSystem(true);
- //fOccurrencesFinderJob.schedule();
fOccurrencesFinderJob.run(new NullProgressMonitor());
}
@@ -584,7 +566,7 @@
IDOMText xmlText = (IDOMText)region;
return findTextMatches(dom, xmlText.getData().trim());
}
- } catch (Exception x) {
+ } catch (DOMException x) {
XmlEditorPlugin.getPluginLog().logError(x);
}
return new ArrayList();
@@ -596,12 +578,9 @@
if (fMarkNodeOccurrences) {
NodeList children = (NodeContainer)dom.getChildNodes();
for (int i = 0; children != null && i < children.getLength(); i++) {
- if(!(children.item(i) instanceof IDOMNode)) continue;
- try {
+ if(children.item(i) instanceof IDOMNode) {
IDOMNode xmlNode = (IDOMNode)children.item(i);
addTagOccurencies(matches, xmlNode, tagName);
- } catch (Exception x) {
- XmlEditorPlugin.getPluginLog().logError(x);
}
}
}
@@ -629,12 +608,9 @@
if (fMarkAttributeOccurrences) {
NodeList children = (NodeContainer)dom.getChildNodes();
for (int i = 0; children != null && i < children.getLength(); i++) {
- if(!(children.item(i) instanceof IDOMNode)) continue;
- try {
+ if(children.item(i) instanceof IDOMNode) {
IDOMNode xmlNode = (IDOMNode)children.item(i);
addTagAttrNameOccurencies(matches, xmlNode, attrName);
- } catch (Exception x) {
- XmlEditorPlugin.getPluginLog().logError(x);
}
}
}
@@ -666,12 +642,9 @@
if (fMarkAttributeValueOccurrences) {
NodeList children = (NodeContainer)dom.getChildNodes();
for (int i = 0; children != null && i < children.getLength(); i++) {
- if(!(children.item(i) instanceof IDOMNode)) continue;
- try {
+ if(children.item(i) instanceof IDOMNode) {
IDOMNode xmlNode = (IDOMNode)children.item(i);
addTagAttrValueOccurencies(matches, xmlNode, attrValue);
- } catch (Exception x) {
- XmlEditorPlugin.getPluginLog().logError(x);
}
}
}
@@ -704,12 +677,9 @@
if (fMarkTextOccurrences && !isEmptyString (data)) {
NodeList children = (NodeContainer)dom.getChildNodes();
for (int i = 0; children != null && i < children.getLength(); i++) {
- if(!(children.item(i) instanceof IDOMNode)) continue;
- try {
+ if (children.item(i) instanceof IDOMNode) {
IDOMNode xmlNode = (IDOMNode)children.item(i);
addTextOccurencies(matches, xmlNode, data);
- } catch (Exception x) {
- XmlEditorPlugin.getPluginLog().logError(x);
}
}
}
@@ -717,8 +687,7 @@
}
private boolean isEmptyString(String str) {
- if (str == null || str.trim().length() == 0) return true;
- return false;
+ return str == null || str.trim().length() == 0;
}
private void addTextOccurencies(List matches, IDOMNode xmlNode, String data) {
@@ -728,7 +697,6 @@
IDOMText xmlText = (IDOMText)xmlNode;
String xmlData = xmlText.getData();
if (xmlData != null && xmlData.indexOf(data) != -1) {
-// matches.add(xmlText);
matches.add(
new Position(
xmlText.getStartOffset() + xmlData.indexOf(data), data.length()));
@@ -742,17 +710,7 @@
}
private boolean getEventNewBooleanValue(PropertyChangeEvent event) {
- boolean newValue = false;
- if (event.getNewValue() instanceof Boolean)
- newValue = ((Boolean) event.getNewValue()).booleanValue();
- else if (event.getNewValue() instanceof String) {
- String s= (String) event.getNewValue();
- if (IPreferenceStore.TRUE.equals(s))
- newValue= true;
- else if (IPreferenceStore.FALSE.equals(s))
- newValue= false;
- }
- return newValue;
+ return Boolean.getBoolean(event.getNewValue().toString());
}
/*
@@ -760,32 +718,25 @@
*/
public void handlePreferenceStoreChanged(PropertyChangeEvent event) {
- try {
- ISourceViewer sourceViewer= getSourceViewer();
- if (sourceViewer == null)
- return;
-
+ ISourceViewer sourceViewer= getSourceViewer();
+ if (getSourceViewer() != null) {
String property= event.getProperty();
if (PreferenceKeyGenerator.generateKey(
XMLOccurrencePreferenceConstants.EDITOR_MARK_OCCURRENCES,
fEditorID).equals(property)) {
-// System.out.println("Preference changed: " + property);
boolean markOccurrences = getEventNewBooleanValue(event);
if (markOccurrences != fMarkOccurrenceAnnotations) {
fMarkOccurrenceAnnotations= markOccurrences;
-
- if (!fMarkOccurrenceAnnotations)
+
+ if (!fMarkOccurrenceAnnotations) {
uninstallOccurrencesFinder();
- else
+ } else {
installOccurrencesFinder();
+ }
}
-
- return;
- }
- if (PreferenceKeyGenerator.generateKey(
+ } else if (PreferenceKeyGenerator.generateKey(
XMLOccurrencePreferenceConstants.EDITOR_OCCURRENCE_PROVIDER,
fEditorID).equals(property)) {
-// System.out.println("Preference changed: " + property);
if (event.getNewValue() instanceof String) {
String occurrenceProvider= (String)event.getNewValue();
if (occurrenceProvider != fOccurrenceProvider) {
@@ -796,52 +747,27 @@
}
}
}
- return;
- }
- if (PreferenceKeyGenerator.generateKey(
+ } else if (PreferenceKeyGenerator.generateKey(
XMLOccurrencePreferenceConstants.EDITOR_MARK_NODE_OCCURRENCES,
fEditorID).equals(property)) {
-// System.out.println("Preference changed: " + property);
fMarkNodeOccurrences= getEventNewBooleanValue(event);
-
- return;
- }
- if (PreferenceKeyGenerator.generateKey(
+ } else if (PreferenceKeyGenerator.generateKey(
XMLOccurrencePreferenceConstants.EDITOR_MARK_ATTRIBUTE_OCCURRENCES,
fEditorID).equals(property)) {
-// System.out.println("Preference changed: " + property);
fMarkAttributeOccurrences= getEventNewBooleanValue(event);
-
- return;
- }
- if (PreferenceKeyGenerator.generateKey(
+ } else if (PreferenceKeyGenerator.generateKey(
XMLOccurrencePreferenceConstants.EDITOR_MARK_ATTRIBUTE_VALUE_OCCURRENCES,
fEditorID).equals(property)) {
-// System.out.println("Preference changed: " + property);
fMarkAttributeValueOccurrences= getEventNewBooleanValue(event);
-
- return;
- }
- if (PreferenceKeyGenerator.generateKey(
+ } else if (PreferenceKeyGenerator.generateKey(
XMLOccurrencePreferenceConstants.EDITOR_MARK_TEXT_OCCURRENCES,
fEditorID).equals(property)) {
-// System.out.println("Preference changed: " + property);
fMarkAttributeValueOccurrences= getEventNewBooleanValue(event);
-
- return;
- }
-
- if (PreferenceKeyGenerator.generateKey(
+ } else if (PreferenceKeyGenerator.generateKey(
XMLOccurrencePreferenceConstants.EDITOR_STICKY_OCCURRENCES,
fEditorID).equals(property)) {
-// System.out.println("Preference changed: " + property);
fStickyOccurrenceAnnotations= getEventNewBooleanValue(event);
-
- return;
}
-
- } catch (Exception x) {
- XmlEditorPlugin.getPluginLog().logError("", x);
}
}
Modified: trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/core/resources/MarkerClearer.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/core/resources/MarkerClearer.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/core/resources/MarkerClearer.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -36,12 +36,9 @@
IProject[] ps = ModelPlugin.getWorkspace().getRoot().getProjects();
for (int i = 0; i < ps.length; i++) {
IModelNature n = (IModelNature)EclipseResourceUtil.getModelNature(ps[i]);
- if(n == null) continue;
- try {
+ if (n != null) {
XModelObject o = FileSystemsHelper.getWebInf(n.getModel());
- clear(o);
- } catch (Exception e) {
- ModelPlugin.getPluginLog().logError(e);
+ clear(o);
}
}
}
Modified: trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/impl/VTaskImpl.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/impl/VTaskImpl.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/impl/VTaskImpl.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -117,9 +117,7 @@
VResult[] results = action.check(object);
notifyApplied(rule, object, results);
} catch (Exception e) {
- if(VerificationPlugin.isDebugEnabled()) {
VerificationPlugin.getPluginLog().logError("Exception in action "+action+" ignored: "+e, e);
- }
}
checked = true;
if (checkChildren) break;
@@ -152,9 +150,7 @@
}
private void logListener(VTaskListener listener, Throwable e) {
- if(VerificationPlugin.isDebugEnabled()) {
- VerificationPlugin.getPluginLog().logInfo("Exception in listener "+listener+" ignored: "+e, e);
- }
+ VerificationPlugin.getPluginLog().logInfo("Exception in listener "+listener+" ignored: "+e, e);
}
private void notifyApplied(VRule rule, VObject object, VResult[] results) {
Modified: trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/RuleSetResourceLoader.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/RuleSetResourceLoader.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/RuleSetResourceLoader.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -28,8 +28,7 @@
IConfigurationElement[] elements = es[i].getConfigurationElements();
for (int j = 0; j < elements.length; j++) {
String path = elements[j].getAttribute("path");
- if(path == null) continue;
- try {
+ if(path != null) {
URL url = bundle.getResource(path);
if(url != null) {
resources.add(url);
@@ -38,10 +37,6 @@
VerificationPlugin.getPluginLog().logInfo("Warning: meta resource " + path + " not found.");
}
}
- } catch (Exception e) {
- if(ModelPlugin.isDebugEnabled()) {
- VerificationPlugin.getPluginLog().logError("Warning: meta resource " + path + " not found.");
- }
}
}
}
Modified: trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VManagerModel.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VManagerModel.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VManagerModel.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -8,7 +8,11 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.util.*;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.ResourceBundle;
+
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.impl.RegularObjectImpl;
import org.jboss.tools.common.model.plugin.ModelPlugin;
Modified: trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VResultModel.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VResultModel.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VResultModel.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -6,8 +6,8 @@
package org.jboss.tools.common.verification.vrules.model;
-import org.jboss.tools.common.verification.vrules.*;
-import org.jboss.tools.common.model.impl.*;
+import org.jboss.tools.common.model.impl.XModelObjectImpl;
+import org.jboss.tools.common.verification.vrules.VResult;
/**
*
Modified: trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VResultTemplateModel.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VResultTemplateModel.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VResultTemplateModel.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -6,11 +6,14 @@
package org.jboss.tools.common.verification.vrules.model;
-import org.jboss.tools.common.verification.vrules.*;
-import org.jboss.tools.common.model.impl.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import org.jboss.tools.common.model.impl.RegularObjectImpl;
+import org.jboss.tools.common.verification.vrules.VMessageFormat;
+import org.jboss.tools.common.verification.vrules.VResultTemplate;
+import org.jboss.tools.common.verification.vrules.VRule;
+
/**
*
* @author valera
Modified: trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRuleModel.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRuleModel.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRuleModel.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -6,13 +6,26 @@
package org.jboss.tools.common.verification.vrules.model;
-import java.util.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.impl.RegularObjectImpl;
import org.jboss.tools.common.model.util.ModelFeatureFactory;
-import org.jboss.tools.common.verification.vrules.*;
+import org.jboss.tools.common.verification.vrules.VAction;
+import org.jboss.tools.common.verification.vrules.VEntity;
+import org.jboss.tools.common.verification.vrules.VModel;
+import org.jboss.tools.common.verification.vrules.VObject;
+import org.jboss.tools.common.verification.vrules.VResult;
+import org.jboss.tools.common.verification.vrules.VResultTemplate;
+import org.jboss.tools.common.verification.vrules.VRule;
+import org.jboss.tools.common.verification.vrules.VRuleSet;
import org.jboss.tools.common.verification.vrules.impl.VResultFactoryImpl;
import org.jboss.tools.common.verification.vrules.impl.VRuleImpl;
import org.jboss.tools.common.verification.vrules.layer.VModelFactory;
Modified: trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRuleSetModel.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRuleSetModel.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRuleSetModel.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -8,10 +8,14 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.util.*;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.ResourceBundle;
+
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.impl.RegularObjectImpl;
-import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.util.ModelFeatureFactory;
import org.jboss.tools.common.verification.vrules.VEntity;
import org.jboss.tools.common.verification.vrules.VModel;
@@ -102,7 +106,7 @@
}
bundles.put(baseName, NULL);
if(VerificationPlugin.isDebugEnabled()) {
- VerificationPlugin.getPluginLog().logInfo("Resource not found: " + baseName + " by org.jboss.tools.common.verification.vrules.model.VRuleSetModel:getBundle()", new Exception(baseName));
+ VerificationPlugin.getPluginLog().logInfo("Resource not found: " + baseName + " by org.jboss.tools.common.verification.vrules.model.VRuleSetModel:getBundle()");
}
return null;
}
Modified: trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRuleSetsLoader.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRuleSetsLoader.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRuleSetsLoader.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -5,18 +5,22 @@
package org.jboss.tools.common.verification.vrules.model;
-import org.jboss.tools.common.model.*;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.jboss.tools.common.model.XModelException;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.engines.impl.EnginesLoader;
import org.jboss.tools.common.model.options.PreferenceModelUtilities;
import org.jboss.tools.common.model.plugin.ModelPlugin;
-import org.jboss.tools.common.model.util.*;
-import org.jboss.tools.common.model.engines.impl.EnginesLoader;
+import org.jboss.tools.common.model.util.XMLUtil;
import org.jboss.tools.common.verification.vrules.plugin.VerificationPlugin;
-
-import java.io.*;
-import java.net.*;
-import java.util.*;
-
-import org.eclipse.core.runtime.FileLocator;
import org.w3c.dom.Element;
/**
Modified: trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRulesTree.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRulesTree.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRulesTree.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -6,8 +6,8 @@
package org.jboss.tools.common.verification.vrules.model;
-import org.jboss.tools.common.model.*;
-import org.jboss.tools.common.model.impl.trees.*;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.impl.trees.DefaultSiftedTree;
/**
*
@@ -29,7 +29,7 @@
VManagerModel man = (VManagerModel)prjs[0];
if (!man.developer && first) {
// bad luck :)
- throw new RuntimeException("Members only");
+ throw new IllegalStateException("Members only");
}
first = false;
return man;
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -245,7 +245,7 @@
if(!includeMappings) {
org.dom4j.Document doc;
XMLHelper xmlHelper = new XMLHelper();
- InputStream stream;
+ InputStream stream = null;
String resourceName = "<unknown>"; //$NON-NLS-1$
try {
if(configXMLFile!=null) {
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -703,16 +703,25 @@
public void load(){
Properties properties = new Properties();
+ FileInputStream fis = null;
try{
File file = new File(getStoreFilePath().toOSString());
if(file.exists()){
- FileInputStream fis = new FileInputStream(file);
+ fis = new FileInputStream(file);
properties.load(fis);
propertiesInit(properties, this);
loadSuccessfull = true;
}
}catch(IOException ex){
VisualEditorPlugin.getDefault().logError("Can't load layout of mapping.", ex); //$NON-NLS-1$
+ } finally {
+ if(fis!=null) {
+ try {
+ fis.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
}
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.view/src/org/jboss/tools/hibernate/wizard/hibernateconnection/TestUrlClassLoader.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.view/src/org/jboss/tools/hibernate/wizard/hibernateconnection/TestUrlClassLoader.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.view/src/org/jboss/tools/hibernate/wizard/hibernateconnection/TestUrlClassLoader.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -79,21 +79,31 @@
*
*/
public Class loadClassFromBinaryFile(String fileName) throws IOException {
- FileInputStream in = null;
- File f = new File(fileName);
- byte[] bytes;
- int fSize = 0;
- in = new FileInputStream(f);
- fSize = (int)f.length();
- bytes = new byte[fSize];
- int length = 0;
- while (length < fSize)
- {
- length += in.read(bytes,length,in.available());
- }
- Class clazz = defineClass(null,bytes,0,length,(CodeSource)null);
- in.close();
- return clazz;
+ FileInputStream in = null;
+ try {
+ File f = new File(fileName);
+ byte[] bytes;
+ int fSize = 0;
+ in = new FileInputStream(f);
+ fSize = (int)f.length();
+ bytes = new byte[fSize];
+ int length = 0;
+ while (length < fSize)
+ {
+ length += in.read(bytes,length,in.available());
+ }
+ Class clazz = defineClass(null,bytes,0,length,(CodeSource)null);
+ in.close();
+ return clazz;
+ } finally {
+ if(in!=null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
}
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInsertTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInsertTemplate.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInsertTemplate.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -25,6 +25,7 @@
import org.eclipse.core.resources.IFile;
import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil;
+import org.jboss.tools.jsf.vpe.richfaces.RichFacesTemplatesActivator;
import org.jboss.tools.vpe.editor.VpeSourceDomBuilder;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
@@ -106,7 +107,7 @@
div.appendChild(text);
return vpeCreationData;
}
-
+ BufferedReader br = null;
try {
IFile iFile = VpeCreatorUtil.getFile(srcValue, pageContext);
if (iFile==null || !iFile.isAccessible()) {
@@ -118,7 +119,7 @@
return vpeCreationData;
}
File file = new File(iFile.getLocation().toOSString());
- BufferedReader br = new BufferedReader(new InputStreamReader(
+ br = new BufferedReader(new InputStreamReader(
new FileInputStream(file)));
while ((buf = br.readLine()) != null)
finalStr += buf + "\n"; //$NON-NLS-1$
@@ -130,6 +131,14 @@
.createTextNode(RESOURCE_READING_ERROR_MESSAGE);
div.appendChild(text);
return vpeCreationData;
+ } finally {
+ try {
+ if(br!=null) {
+ br.close();
+ }
+ } catch (IOException e) {
+ RichFacesTemplatesActivator.getPluginLog().logError(e);
+ }
}
if ((highlightValue == null) || (!searchInSupportedTypes(highlightValue))){
Modified: trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFPromptingProviderTestProject/WebContent/WEB-INF/faces-config-1.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFPromptingProviderTestProject/WebContent/WEB-INF/faces-config-1.xml 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFPromptingProviderTestProject/WebContent/WEB-INF/faces-config-1.xml 2008-08-30 00:06:07 UTC (rev 9969)
@@ -1,5 +1,4 @@
<?xml version="1.0"?>
-<?xml version="1.0"?>
<faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/ImageSelectionDialog.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/ImageSelectionDialog.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/ImageSelectionDialog.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -11,6 +11,7 @@
package org.jboss.tools.jst.jsp.outline.cssdialog;
import java.io.FileInputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashSet;
@@ -599,7 +600,7 @@
.getDisplay(), SWT.CURSOR_WAIT);
Point previewPoint = new Point(0, 0);
Point labelPoint = canvas.getSize();
- InputStream stream;
+ InputStream stream=null;
try {
getShell().setCursor(waitCursor);
stream = new FileInputStream(file.getLocation()
@@ -653,10 +654,17 @@
image.dispose();
gc.dispose();
}
- } catch (Exception ev) {
+ } catch (IOException ev) {
} finally {
- getShell().setCursor(parentCursor);
+ getShell().setCursor(parentCursor);
+ if(stream != null) {
+ try {
+ stream.close();
+ } catch (IOException e1) {
+ // ignore
+ }
+ }
}
}
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamMessagesLoader.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamMessagesLoader.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamMessagesLoader.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -138,13 +138,21 @@
if(p == null) continue;
File f = p.toFile();
Properties properties = new Properties();
+ FileInputStream is = null;
try {
- FileInputStream is = new FileInputStream(f);
+ is = new FileInputStream(f);
properties.load(is);
- is.close();
} catch (IOException e) {
//ignore
//TODO keep error for validation
+ } finally {
+ if(is!=null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
}
Set<?> s = properties.keySet();
for (Object o : s) keys.add((String)o);
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -97,539 +97,551 @@
public class VpeVisualDomBuilder extends VpeDomBuilder {
- public static final String VPE_USER_TOGGLE_ID = "vpe-user-toggle-id"; //$NON-NLS-1$
- public static final String VPE_USER_TOGGLE_LOOKUP_PARENT = "vpe-user-toggle-lookup-parent"; //$NON-NLS-1$
+ public static final String VPE_USER_TOGGLE_ID = "vpe-user-toggle-id"; //$NON-NLS-1$
+ public static final String VPE_USER_TOGGLE_LOOKUP_PARENT = "vpe-user-toggle-lookup-parent"; //$NON-NLS-1$
- /** REGEX_EL */
- private static final Pattern REGEX_EL = Pattern.compile(
- "[\\$|\\#]\\{.*\\}", Pattern.MULTILINE + Pattern.DOTALL); //$NON-NLS-1$
-
- private static final String PSEUDO_ELEMENT = "br"; //$NON-NLS-1$
- private static final String PSEUDO_ELEMENT_ATTR = "vpe:pseudo-element"; //$NON-NLS-1$
- private static final String INIT_ELEMENT_ATTR = "vpe:init-element"; //$NON-NLS-1$
- private static final String MOZ_ANONCLASS_ATTR = "_MOZ_ANONCLASS"; //$NON-NLS-1$
- private static final String INCLUDE_ELEMENT_ATTR = "vpe:include-element"; //$NON-NLS-1$
- private static final int DRAG_AREA_WIDTH = 10;
- private static final int DRAG_AREA_HEIGHT = 10;
- private static final String ATTR_DRAG_AVAILABLE_CLASS = "__drag__available_style"; //$NON-NLS-1$
- private static String DOTTED_BORDER = "border: 1px dotted #FF6600; padding: 5px;"; //$NON-NLS-1$
+ /** REGEX_EL */
+ private static final Pattern REGEX_EL = Pattern.compile(
+ "[\\$|\\#]\\{.*\\}", Pattern.MULTILINE + Pattern.DOTALL); //$NON-NLS-1$
- private MozillaEditor visualEditor;
- private XulRunnerEditor xulRunnerEditor;
- private nsIDOMDocument visualDocument;
- // JBIDE-2170 Sergey Dzmitrovich
- // private nsIDOMElement visualContentArea;
- private VpePageContext pageContext;
- private VpeDnD dnd;
- // JBIDE-2170 Sergey Dzmitrovich
- // private nsIDOMNode headNode;
- private List includeStack;
- // TODO Max Areshkau JBIDE-1457
- // boolean rebuildFlag = false;
+ private static final String PSEUDO_ELEMENT = "br"; //$NON-NLS-1$
+ private static final String PSEUDO_ELEMENT_ATTR = "vpe:pseudo-element"; //$NON-NLS-1$
+ private static final String INIT_ELEMENT_ATTR = "vpe:init-element"; //$NON-NLS-1$
+ private static final String MOZ_ANONCLASS_ATTR = "_MOZ_ANONCLASS"; //$NON-NLS-1$
+ private static final String INCLUDE_ELEMENT_ATTR = "vpe:include-element"; //$NON-NLS-1$
+ private static final int DRAG_AREA_WIDTH = 10;
+ private static final int DRAG_AREA_HEIGHT = 10;
+ private static final String ATTR_DRAG_AVAILABLE_CLASS = "__drag__available_style"; //$NON-NLS-1$
+ private static String DOTTED_BORDER = "border: 1px dotted #FF6600; padding: 5px;"; //$NON-NLS-1$
- /** faceletFile */
- private boolean faceletFile = false;
+ private MozillaEditor visualEditor;
+ private XulRunnerEditor xulRunnerEditor;
+ private nsIDOMDocument visualDocument;
+ // JBIDE-2170 Sergey Dzmitrovich
+ // private nsIDOMElement visualContentArea;
+ private VpePageContext pageContext;
+ private VpeDnD dnd;
+ // JBIDE-2170 Sergey Dzmitrovich
+ // private nsIDOMNode headNode;
+ private List includeStack;
+ // TODO Max Areshkau JBIDE-1457
+ // boolean rebuildFlag = false;
- private static final String ATTR_VPE = "vpe"; //$NON-NLS-1$
- private static final String ATTR_VPE_INLINE_LINK_VALUE = "inlinelink"; //$NON-NLS-1$
+ /** faceletFile */
+ private boolean faceletFile = false;
- private static final String ATTR_REL_STYLESHEET_VALUE = "stylesheet"; //$NON-NLS-1$
+ private static final String ATTR_VPE = "vpe"; //$NON-NLS-1$
+ private static final String ATTR_VPE_INLINE_LINK_VALUE = "inlinelink"; //$NON-NLS-1$
- private static final String YES_STRING = "yes"; //$NON-NLS-1$
- private static final String ZERO_STRING = "0"; //$NON-NLS-1$
- private static final String EMPTY_STRING = ""; //$NON-NLS-1$
+ private static final String ATTR_REL_STYLESHEET_VALUE = "stylesheet"; //$NON-NLS-1$
- private static final String ATRIBUTE_BORDER = "border"; //$NON-NLS-1$
- private static final String ATRIBUTE_CELLSPACING = "cellspacing"; //$NON-NLS-1$
- private static final String ATRIBUTE_CELLPADDING = "cellpadding"; //$NON-NLS-1$
+ private static final String YES_STRING = "yes"; //$NON-NLS-1$
+ private static final String ZERO_STRING = "0"; //$NON-NLS-1$
+ private static final String EMPTY_STRING = ""; //$NON-NLS-1$
- private static final String DOTTED_BORDER_STYLE = "border : 1px dotted #808080"; //$NON-NLS-1$
- private static final String DOTTED_BORDER_STYLE_FOR_IMG = "1px dotted #808080"; //$NON-NLS-1$
- private static final String DOTTED_BORDER_STYLE_FOR_TD = "border-left : 1px dotted #808080; border-right : 1px dotted #808080; border-top : 1px dotted #808080; border-bottom : 0px; color:#0051DD; background-color:#ECF3FF; padding-left: 3px; padding-right: 3px; line-height : 10px; font-family : arial; font-size : 10px; text-align:top; margin : 1px; -moz-user-modify : read-only"; //$NON-NLS-1$
- private static final String DOTTED_BORDER_STYLE_FOR_SPAN = "border : 1px solid #0051DD; color:#0051DD; background-color:#ECF3FF; padding-left: 3px; padding-right: 3px; line-height : 10px; font-family : arial; font-size : 10px; text-align:top; margin : 1px; -moz-user-modify : read-only"; //$NON-NLS-1$
+ private static final String ATRIBUTE_BORDER = "border"; //$NON-NLS-1$
+ private static final String ATRIBUTE_CELLSPACING = "cellspacing"; //$NON-NLS-1$
+ private static final String ATRIBUTE_CELLPADDING = "cellpadding"; //$NON-NLS-1$
- static private HashSet<String> unborderedSourceNodes = new HashSet<String>();
- static {
- unborderedSourceNodes.add(HTML.TAG_HTML);
- unborderedSourceNodes.add(HTML.TAG_HEAD);
- unborderedSourceNodes.add(HTML.TAG_BODY);
- }
+ private static final String DOTTED_BORDER_STYLE = "border : 1px dotted #808080"; //$NON-NLS-1$
+ private static final String DOTTED_BORDER_STYLE_FOR_IMG = "1px dotted #808080"; //$NON-NLS-1$
+ private static final String DOTTED_BORDER_STYLE_FOR_TD = "border-left : 1px dotted #808080; border-right : 1px dotted #808080; border-top : 1px dotted #808080; border-bottom : 0px; color:#0051DD; background-color:#ECF3FF; padding-left: 3px; padding-right: 3px; line-height : 10px; font-family : arial; font-size : 10px; text-align:top; margin : 1px; -moz-user-modify : read-only"; //$NON-NLS-1$
+ private static final String DOTTED_BORDER_STYLE_FOR_SPAN = "border : 1px solid #0051DD; color:#0051DD; background-color:#ECF3FF; padding-left: 3px; padding-right: 3px; line-height : 10px; font-family : arial; font-size : 10px; text-align:top; margin : 1px; -moz-user-modify : read-only"; //$NON-NLS-1$
- static private HashSet<String> unborderedVisualNodes = new HashSet<String>();
- static {
- unborderedVisualNodes.add(HTML.TAG_TBODY);
- unborderedVisualNodes.add(HTML.TAG_THEAD);
- unborderedVisualNodes.add(HTML.TAG_TR);
- unborderedVisualNodes.add(HTML.TAG_TD);
- unborderedVisualNodes.add(HTML.TAG_COL);
- unborderedVisualNodes.add(HTML.TAG_COLS);
- unborderedVisualNodes.add(HTML.TAG_COLGROUP);
- unborderedVisualNodes.add(HTML.TAG_LI);
- unborderedVisualNodes.add(HTML.TAG_BR);
- }
- private VpeDnd dropper;
+ static private HashSet<String> unborderedSourceNodes = new HashSet<String>();
+ static {
+ unborderedSourceNodes.add(HTML.TAG_HTML);
+ unborderedSourceNodes.add(HTML.TAG_HEAD);
+ unborderedSourceNodes.add(HTML.TAG_BODY);
+ }
- private Map<IFile, Document> includeDocuments = new HashMap<IFile, Document>();
+ static private HashSet<String> unborderedVisualNodes = new HashSet<String>();
+ static {
+ unborderedVisualNodes.add(HTML.TAG_TBODY);
+ unborderedVisualNodes.add(HTML.TAG_THEAD);
+ unborderedVisualNodes.add(HTML.TAG_TR);
+ unborderedVisualNodes.add(HTML.TAG_TD);
+ unborderedVisualNodes.add(HTML.TAG_COL);
+ unborderedVisualNodes.add(HTML.TAG_COLS);
+ unborderedVisualNodes.add(HTML.TAG_COLGROUP);
+ unborderedVisualNodes.add(HTML.TAG_LI);
+ unborderedVisualNodes.add(HTML.TAG_BR);
+ }
+ private VpeDnd dropper;
+
+ private Map<IFile, Document> includeDocuments = new HashMap<IFile, Document>();
private boolean showInvisibleTags;
- public VpeVisualDomBuilder(VpeDomMapping domMapping,
- INodeAdapter sorceAdapter, VpeTemplateManager templateManager,
- MozillaEditor visualEditor, VpePageContext pageContext) {
-
- super(domMapping, sorceAdapter, templateManager);
- this.visualEditor = visualEditor;
- xulRunnerEditor = visualEditor.getXulRunnerEditor();
- this.visualDocument = visualEditor.getDomDocument();
-// this.visualContentArea = visualEditor.getContentArea();
- this.dnd = new VpeDnD();
- this.pageContext = pageContext;
-// this.headNode = visualEditor.getHeadNode();
- dropper = new VpeDnd();
- dropper.setDndData(false, true);
+ public VpeVisualDomBuilder(VpeDomMapping domMapping,
+ INodeAdapter sorceAdapter, VpeTemplateManager templateManager,
+ MozillaEditor visualEditor, VpePageContext pageContext) {
- if (isFacelet()) {
- faceletFile = true;
- } else {
- faceletFile = false;
- }
-
- this.showInvisibleTags = Constants.YES_STRING
+ super(domMapping, sorceAdapter, templateManager);
+ this.visualEditor = visualEditor;
+ xulRunnerEditor = visualEditor.getXulRunnerEditor();
+ this.visualDocument = visualEditor.getDomDocument();
+ // this.visualContentArea = visualEditor.getContentArea();
+ this.dnd = new VpeDnD();
+ this.pageContext = pageContext;
+ // this.headNode = visualEditor.getHeadNode();
+ dropper = new VpeDnd();
+ dropper.setDndData(false, true);
+
+ if (isFacelet()) {
+ faceletFile = true;
+ } else {
+ faceletFile = false;
+ }
+
+ this.showInvisibleTags = Constants.YES_STRING
.equals(VpePreference.SHOW_INVISIBLE_TAGS.getValue());
- }
+ }
- public void buildDom(Document sourceDocument) {
- VpeSourceDomBuilder sourceBuilder = pageContext.getSourceBuilder();
- IDocument document = sourceBuilder.getStructuredTextViewer()
- .getDocument();
- if (document == null)
- return;
- includeStack = new ArrayList();
- IEditorInput input = pageContext.getEditPart().getEditorInput();
- if (input instanceof IFileEditorInput) {
- IFile file = ((IFileEditorInput) input).getFile();
- if (file != null) {
- includeStack.add(new VpeIncludeInfo(null, file, pageContext
- .getSourceBuilder().getSourceDocument()));
- }
- }
-
- pageContext.refreshConnector();
- pageContext.installIncludeElements();
- if (isFacelet()) {
- Element root = FaceletUtil.getRootFaceletElement(sourceDocument);
- if (root != null) {
- addNode(root, null, getContentArea());
- }
- } else {
- addChildren(null, sourceDocument, getContentArea());
- }
- /*
- * Fixes http://jira.jboss.com/jira/browse/JBIDE-2126.
- * To provide appropriate context menu functionality
- * visual content area should be mapped in any case.
- */
- registerNodes(new VpeNodeMapping(sourceDocument, getContentArea()));
- }
+ public void buildDom(Document sourceDocument) {
+ VpeSourceDomBuilder sourceBuilder = pageContext.getSourceBuilder();
+ IDocument document = sourceBuilder.getStructuredTextViewer()
+ .getDocument();
+ if (document == null)
+ return;
+ includeStack = new ArrayList();
+ IEditorInput input = pageContext.getEditPart().getEditorInput();
+ if (input instanceof IFileEditorInput) {
+ IFile file = ((IFileEditorInput) input).getFile();
+ if (file != null) {
+ includeStack.add(new VpeIncludeInfo(null, file, pageContext
+ .getSourceBuilder().getSourceDocument()));
+ }
+ }
- public void rebuildDom(Document sourceDocument) {
- // clearIncludeDocuments();
- cleanHead();
- domMapping.clear(getContentArea());
- super.dispose();
+ pageContext.refreshConnector();
+ pageContext.installIncludeElements();
+ if (isFacelet()) {
+ Element root = FaceletUtil.getRootFaceletElement(sourceDocument);
+ if (root != null) {
+ addNode(root, null, getContentArea());
+ }
+ } else {
+ addChildren(null, sourceDocument, getContentArea());
+ }
+ /*
+ * Fixes http://jira.jboss.com/jira/browse/JBIDE-2126. To provide
+ * appropriate context menu functionality visual content area should be
+ * mapped in any case.
+ */
+ registerNodes(new VpeNodeMapping(sourceDocument, getContentArea()));
+ }
- pageContext.clearAll();
- refreshExternalLinks();
- pageContext.getBundle().refreshRegisteredBundles();
+ public void rebuildDom(Document sourceDocument) {
+ // clearIncludeDocuments();
+ cleanHead();
+ domMapping.clear(getContentArea());
+ super.dispose();
- nsIDOMNodeList children = getContentArea().getChildNodes();
- long len = children.getLength();
- for (long i = len - 1; i >= 0; i--) {
- getContentArea().removeChild(children.item(i));
- }
+ pageContext.clearAll();
+ refreshExternalLinks();
+ pageContext.getBundle().refreshRegisteredBundles();
- if (sourceDocument != null) {
- buildDom(sourceDocument);
- }
+ nsIDOMNodeList children = getContentArea().getChildNodes();
+ long len = children.getLength();
+ for (long i = len - 1; i >= 0; i--) {
+ getContentArea().removeChild(children.item(i));
+ }
- }
+ if (sourceDocument != null) {
+ buildDom(sourceDocument);
+ }
- // temporary, will be change to prefference's variable
- // private boolean borderVisible = true;
-
- private boolean addNode(Node sourceNode, nsIDOMNode visualNextNode,
- nsIDOMNode visualContainer) {
-
- nsIDOMNode visualNewNode = createNode(sourceNode, visualContainer);
-
- // Fix for JBIDE-1097
- try {
- if (visualNewNode != null) {
- nsIDOMHTMLInputElement iDOMInputElement = (nsIDOMHTMLInputElement) visualNewNode
- .queryInterface(nsIDOMHTMLInputElement.NS_IDOMHTMLINPUTELEMENT_IID);
- iDOMInputElement.setReadOnly(true);
- }
- } catch (XPCOMException ex) {
- // just ignore this exception
- }
- if (visualNewNode != null) {
- if (visualNextNode == null) {
- visualContainer.appendChild(visualNewNode);
- } else {
- visualContainer.insertBefore(visualNewNode, visualNextNode);
- }
- return true;
- }
+ }
- return false;
- }
+ // temporary, will be change to prefference's variable
+ // private boolean borderVisible = true;
- private nsIDOMElement createBorder(Node sourceNode,
- nsIDOMElement visualNode, boolean block) {
- nsIDOMElement border = null;
- if (visualNode == null)
- return null;
- if (unborderedSourceNodes.contains(sourceNode.getNodeName()
- .toLowerCase()))
- return null;
- if (unborderedVisualNodes.contains(visualNode.getNodeName()
- .toLowerCase()))
- return null;
- if (HTML.TAG_IMG.equalsIgnoreCase(visualNode.getNodeName())) {
- String width = visualNode.getAttribute(ATRIBUTE_BORDER);
- if (width == null || ZERO_STRING.equalsIgnoreCase(width)
- || EMPTY_STRING.equalsIgnoreCase(width)) {
- String style = visualNode
- .getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
- style = VpeStyleUtil.setParameterInStyle(style,
- ATRIBUTE_BORDER, DOTTED_BORDER_STYLE_FOR_IMG);
- visualNode.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
- }
- return null;
- }
- if (block) {
- if (YES_STRING.equals(VpePreference.USE_DETAIL_BORDER.getValue())) {
- border = visualDocument.createElement(HTML.TAG_TABLE);
- border.setAttribute(ATRIBUTE_CELLSPACING, ZERO_STRING);
- border.setAttribute(ATRIBUTE_CELLPADDING, ZERO_STRING);
+ private boolean addNode(Node sourceNode, nsIDOMNode visualNextNode,
+ nsIDOMNode visualContainer) {
- nsIDOMElement tr1 = visualDocument.createElement(HTML.TAG_TR);
- border.appendChild(tr1);
- nsIDOMElement td1 = visualDocument.createElement(HTML.TAG_TD);
- td1.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
- DOTTED_BORDER_STYLE_FOR_TD);
- nsIDOMText text = visualDocument.createTextNode(sourceNode
- .getNodeName());
- td1.appendChild(text);
- tr1.appendChild(td1);
- nsIDOMElement tr2 = visualDocument.createElement(HTML.TAG_TR);
- border.appendChild(tr2);
- nsIDOMElement td2 = visualDocument.createElement(HTML.TAG_TD);
- tr2.appendChild(td2);
- nsIDOMElement p = visualDocument.createElement(HTML.TAG_P);
- p.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
- DOTTED_BORDER_STYLE);
- td2.appendChild(p);
+ nsIDOMNode visualNewNode = createNode(sourceNode, visualContainer);
- p.appendChild(visualNode);
+ // Fix for JBIDE-1097
+ try {
+ if (visualNewNode != null) {
+ nsIDOMHTMLInputElement iDOMInputElement = (nsIDOMHTMLInputElement) visualNewNode
+ .queryInterface(nsIDOMHTMLInputElement.NS_IDOMHTMLINPUTELEMENT_IID);
+ iDOMInputElement.setReadOnly(true);
+ }
+ } catch (XPCOMException ex) {
+ // just ignore this exception
+ }
+ if (visualNewNode != null) {
+ if (visualNextNode == null) {
+ visualContainer.appendChild(visualNewNode);
+ } else {
+ visualContainer.insertBefore(visualNewNode, visualNextNode);
+ }
+ return true;
+ }
- } else {
- border = visualDocument.createElement(HTML.TAG_TABLE);
- border.setAttribute(ATRIBUTE_CELLSPACING, ZERO_STRING);
- border.setAttribute(ATRIBUTE_CELLPADDING, ZERO_STRING);
+ return false;
+ }
- nsIDOMElement tr2 = visualDocument.createElement(HTML.TAG_TR);
- border.appendChild(tr2);
- nsIDOMElement td2 = visualDocument.createElement(HTML.TAG_TD);
- tr2.appendChild(td2);
- nsIDOMElement p = visualDocument.createElement(HTML.TAG_P);
- p.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
- DOTTED_BORDER_STYLE);
- td2.appendChild(p);
+ private nsIDOMElement createBorder(Node sourceNode,
+ nsIDOMElement visualNode, boolean block) {
+ nsIDOMElement border = null;
+ if (visualNode == null)
+ return null;
+ if (unborderedSourceNodes.contains(sourceNode.getNodeName()
+ .toLowerCase()))
+ return null;
+ if (unborderedVisualNodes.contains(visualNode.getNodeName()
+ .toLowerCase()))
+ return null;
+ if (HTML.TAG_IMG.equalsIgnoreCase(visualNode.getNodeName())) {
+ String width = visualNode.getAttribute(ATRIBUTE_BORDER);
+ if (width == null || ZERO_STRING.equalsIgnoreCase(width)
+ || EMPTY_STRING.equalsIgnoreCase(width)) {
+ String style = visualNode
+ .getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
+ style = VpeStyleUtil.setParameterInStyle(style,
+ ATRIBUTE_BORDER, DOTTED_BORDER_STYLE_FOR_IMG);
+ visualNode.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
+ }
+ return null;
+ }
+ if (block) {
+ if (YES_STRING.equals(VpePreference.USE_DETAIL_BORDER.getValue())) {
+ border = visualDocument.createElement(HTML.TAG_TABLE);
+ border.setAttribute(ATRIBUTE_CELLSPACING, ZERO_STRING);
+ border.setAttribute(ATRIBUTE_CELLPADDING, ZERO_STRING);
- p.appendChild(visualNode);
- }
- } else {
- border = visualDocument.createElement(HTML.TAG_SPAN);
- border.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
- DOTTED_BORDER_STYLE);
- if (YES_STRING.equals(VpePreference.USE_DETAIL_BORDER.getValue())) {
- nsIDOMElement name = visualDocument
- .createElement(HTML.TAG_SPAN);
- name.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
- DOTTED_BORDER_STYLE_FOR_SPAN);
- nsIDOMText text = visualDocument.createTextNode(sourceNode
- .getNodeName());
- name.appendChild(text);
- border.appendChild(name);
- }
- border.appendChild(visualNode);
- }
- if (VpeStyleUtil.getAbsolute((Element) sourceNode) && border != null) {
- int top = VpeStyleUtil.getSizeFromStyle((Element) sourceNode,
- VpeStyleUtil.ATTRIBUTE_STYLE + VpeStyleUtil.DOT_STRING
- + VpeStyleUtil.PARAMETER_TOP);
- int left = VpeStyleUtil.getSizeFromStyle((Element) sourceNode,
- VpeStyleUtil.ATTRIBUTE_STYLE + VpeStyleUtil.DOT_STRING
- + VpeStyleUtil.PARAMETER_LEFT);
+ nsIDOMElement tr1 = visualDocument.createElement(HTML.TAG_TR);
+ border.appendChild(tr1);
+ nsIDOMElement td1 = visualDocument.createElement(HTML.TAG_TD);
+ td1.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
+ DOTTED_BORDER_STYLE_FOR_TD);
+ nsIDOMText text = visualDocument.createTextNode(sourceNode
+ .getNodeName());
+ td1.appendChild(text);
+ tr1.appendChild(td1);
+ nsIDOMElement tr2 = visualDocument.createElement(HTML.TAG_TR);
+ border.appendChild(tr2);
+ nsIDOMElement td2 = visualDocument.createElement(HTML.TAG_TD);
+ tr2.appendChild(td2);
+ nsIDOMElement p = visualDocument.createElement(HTML.TAG_P);
+ p.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
+ DOTTED_BORDER_STYLE);
+ td2.appendChild(p);
- String style = visualNode
- .getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
- style = VpeStyleUtil.deleteFromString(style,
- VpeStyleUtil.PARAMETER_POSITION,
- VpeStyleUtil.SEMICOLON_STRING);
- style = VpeStyleUtil.deleteFromString(style,
- VpeStyleUtil.PARAMETER_TOP, VpeStyleUtil.SEMICOLON_STRING);
- style = VpeStyleUtil.deleteFromString(style,
- VpeStyleUtil.PARAMETER_LEFT, VpeStyleUtil.SEMICOLON_STRING);
- visualNode.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
+ p.appendChild(visualNode);
- style = border.getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
- style = VpeStyleUtil.setAbsolute(style);
- if (top != -1)
- style = VpeStyleUtil.setSizeInStyle(style,
- VpeStyleUtil.PARAMETER_TOP, top);
- if (left != -1)
- style = VpeStyleUtil.setSizeInStyle(style,
- VpeStyleUtil.PARAMETER_LEFT, left);
- border.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
- }
- return border;
- }
-
- /**
- * Generates visual node
- * @param sourceNode
- * @param visualOldContainer
- * @return
- */
- protected nsIDOMNode createNode(Node sourceNode,
- nsIDOMNode visualOldContainer) {
-
- boolean registerFlag = isCurrentMainDocument();
-
- //reads and dispatch events
- //JBIDE-675, checks if editor was disposed or not
- if(getPageContext().getSourceBuilder()==null ||includeDocuments==null) {
-
- throw new VpeDisposeException();
- }
- getPageContext().processDisplayEvents();
-
- //check source node can be changed and link can be a null in this case
- //we shouldn't process this node
- if(sourceNode==null||(
- sourceNode.getNodeType()!=Node.TEXT_NODE
- &&sourceNode.getNodeType()!=Node.ELEMENT_NODE
- &&sourceNode.getNodeType()!=Node.COMMENT_NODE)) {
- return null;
- }
-
- Set<Node> ifDependencySet = new HashSet<Node>();
- pageContext.setCurrentVisualNode(visualOldContainer);
- VpeTemplate template = templateManager.getTemplate(pageContext,
- sourceNode, ifDependencySet);
+ } else {
+ border = visualDocument.createElement(HTML.TAG_TABLE);
+ border.setAttribute(ATRIBUTE_CELLSPACING, ZERO_STRING);
+ border.setAttribute(ATRIBUTE_CELLPADDING, ZERO_STRING);
- VpeCreationData creationData = null;
- Node sourceNodeClone = null;
- // FIX FOR JBIDE-1568, added by Max Areshkau
- try {
+ nsIDOMElement tr2 = visualDocument.createElement(HTML.TAG_TR);
+ border.appendChild(tr2);
+ nsIDOMElement td2 = visualDocument.createElement(HTML.TAG_TD);
+ tr2.appendChild(td2);
+ nsIDOMElement p = visualDocument.createElement(HTML.TAG_P);
+ p.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
+ DOTTED_BORDER_STYLE);
+ td2.appendChild(p);
- if (ElService.getInstance().isCloneableNode(getPageContext(), sourceNode)) {
- sourceNodeClone = (sourceNode).cloneNode(true);
+ p.appendChild(visualNode);
+ }
+ } else {
+ border = visualDocument.createElement(HTML.TAG_SPAN);
+ border.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
+ DOTTED_BORDER_STYLE);
+ if (YES_STRING.equals(VpePreference.USE_DETAIL_BORDER.getValue())) {
+ nsIDOMElement name = visualDocument
+ .createElement(HTML.TAG_SPAN);
+ name.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE,
+ DOTTED_BORDER_STYLE_FOR_SPAN);
+ nsIDOMText text = visualDocument.createTextNode(sourceNode
+ .getNodeName());
+ name.appendChild(text);
+ border.appendChild(name);
+ }
+ border.appendChild(visualNode);
+ }
+ if (VpeStyleUtil.getAbsolute((Element) sourceNode) && border != null) {
+ int top = VpeStyleUtil.getSizeFromStyle((Element) sourceNode,
+ VpeStyleUtil.ATTRIBUTE_STYLE + VpeStyleUtil.DOT_STRING
+ + VpeStyleUtil.PARAMETER_TOP);
+ int left = VpeStyleUtil.getSizeFromStyle((Element) sourceNode,
+ VpeStyleUtil.ATTRIBUTE_STYLE + VpeStyleUtil.DOT_STRING
+ + VpeStyleUtil.PARAMETER_LEFT);
- template.beforeTemplateCreated(getPageContext(), sourceNodeClone, getVisualDocument());
- creationData = template.create(getPageContext(), sourceNodeClone, getVisualDocument());
- } else {
- creationData = template.create(getPageContext(), sourceNode, getVisualDocument());
- }
+ String style = visualNode
+ .getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
+ style = VpeStyleUtil.deleteFromString(style,
+ VpeStyleUtil.PARAMETER_POSITION,
+ VpeStyleUtil.SEMICOLON_STRING);
+ style = VpeStyleUtil.deleteFromString(style,
+ VpeStyleUtil.PARAMETER_TOP, VpeStyleUtil.SEMICOLON_STRING);
+ style = VpeStyleUtil.deleteFromString(style,
+ VpeStyleUtil.PARAMETER_LEFT, VpeStyleUtil.SEMICOLON_STRING);
+ visualNode.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
- } catch (XPCOMException ex) {
- VpePlugin.getPluginLog().logError(ex);
- VpeTemplate defTemplate = templateManager.getDefTemplate();
- creationData = defTemplate.create(getPageContext(), sourceNode,
- getVisualDocument());
- }
-
- getPageContext().setCurrentVisualNode(null);
+ style = border.getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
+ style = VpeStyleUtil.setAbsolute(style);
+ if (top != -1)
+ style = VpeStyleUtil.setSizeInStyle(style,
+ VpeStyleUtil.PARAMETER_TOP, top);
+ if (left != -1)
+ style = VpeStyleUtil.setSizeInStyle(style,
+ VpeStyleUtil.PARAMETER_LEFT, left);
+ border.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
+ }
+ return border;
+ }
- nsIDOMNode visualNewNode =creationData.getNode();
+ /**
+ * Generates visual node
+ *
+ * @param sourceNode
+ * @param visualOldContainer
+ * @return
+ */
+ protected nsIDOMNode createNode(Node sourceNode,
+ nsIDOMNode visualOldContainer) {
- nsIDOMElement border = null;
+ boolean registerFlag = isCurrentMainDocument();
- if(visualNewNode!=null && visualNewNode.getNodeType()==nsIDOMNode.ELEMENT_NODE) {
-
- nsIDOMElement visualNewElement = (nsIDOMElement) creationData
- .getNode().queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
-
- if ((visualNewElement != null) && template.hasImaginaryBorder()) {
+ // reads and dispatch events
+ // JBIDE-675, checks if editor was disposed or not
+ if (getPageContext().getSourceBuilder() == null
+ || includeDocuments == null) {
- visualNewElement.setAttribute(HTML.ATTR_STYLE, visualNewElement
- .getAttribute(HTML.ATTR_STYLE)
- + VpeStyleUtil.SEMICOLON_STRING + DOTTED_BORDER);
+ throw new VpeDisposeException();
+ }
+ getPageContext().processDisplayEvents();
- }
- if (visualNewElement != null) {
- correctVisualAttribute(visualNewElement);
- }
- if (YES_STRING.equals(VpePreference.SHOW_BORDER_FOR_ALL_TAGS
- .getValue())
- && visualNewElement != null) {
- boolean block = true;
- if (template.getTagDescription(null, null, null,
- visualNewElement, null).getDisplayType() == VpeTagDescription.DISPLAY_TYPE_INLINE) {
- block = false;
- }
- border = createBorder(sourceNode, visualNewElement, block);
- }
- if (!isCurrentMainDocument() && visualNewElement != null) {
- setReadOnlyElement(visualNewElement);
- }
- }
+ // check source node can be changed and link can be a null in this case
+ // we shouldn't process this node
+ if (sourceNode == null
+ || (sourceNode.getNodeType() != Node.TEXT_NODE
+ && sourceNode.getNodeType() != Node.ELEMENT_NODE && sourceNode
+ .getNodeType() != Node.COMMENT_NODE)) {
+ return null;
+ }
- if(sourceNode instanceof Element && visualNewNode!= null &&visualNewNode.getNodeType()==nsIDOMNode.ELEMENT_NODE) {
-
- setTooltip((Element) sourceNode, (nsIDOMElement)visualNewNode.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID));
- }
- if (registerFlag) {
-
- final VpeElementData data = creationData.getElementData();
+ Set<Node> ifDependencySet = new HashSet<Node>();
+ pageContext.setCurrentVisualNode(visualOldContainer);
+ VpeTemplate template = templateManager.getTemplate(pageContext,
+ sourceNode, ifDependencySet);
- if ((sourceNodeClone != null) && (data != null) && (data.getNodesData() != null) && (data.getNodesData().size() > 0)) {
+ VpeCreationData creationData = null;
+ Node sourceNodeClone = null;
+ // FIX FOR JBIDE-1568, added by Max Areshkau
+ try {
- if (template instanceof IEditableTemplate) {
- final IEditableTemplate editableTemplate = (IEditableTemplate) template;
-
- for (org.jboss.tools.vpe.editor.mapping.NodeData nodeData : data.getNodesData()) {
- Attr attr = editableTemplate.getOutputAttributeNode((Element) sourceNode);
- if(attr!=null){
- nodeData.setSourceNode(attr);
- }
- }
- }
-
- }
- VpeElementMapping elementMapping = new VpeElementMapping(
- sourceNode, visualNewNode, border,
- template, ifDependencySet, creationData.getData(),
- data);
- registerNodes(elementMapping);
- }
- if (template.isChildren()) {
- List<?> childrenInfoList = creationData.getChildrenInfoList();
- if (childrenInfoList == null) {
- addChildren(template, sourceNode,
- visualNewNode != null ? visualNewNode
- : visualOldContainer);
- } else {
- addChildren(template, sourceNode, visualOldContainer,
- childrenInfoList);
- }
- }
- getPageContext().setCurrentVisualNode(visualOldContainer);
- template.validate(getPageContext(), sourceNode,
- visualDocument, creationData);
- getPageContext().setCurrentVisualNode(null);
-
- // if showInvisibleTags mode
- if (isShowInvisibleTags() && (visualNewNode != null)
+ if (ElService.getInstance().isCloneableNode(getPageContext(),
+ sourceNode)) {
+ sourceNodeClone = (sourceNode).cloneNode(true);
+
+ template.beforeTemplateCreated(getPageContext(),
+ sourceNodeClone, getVisualDocument());
+ creationData = template.create(getPageContext(),
+ sourceNodeClone, getVisualDocument());
+ } else {
+ creationData = template.create(getPageContext(), sourceNode,
+ getVisualDocument());
+ }
+
+ } catch (XPCOMException ex) {
+ VpePlugin.getPluginLog().logError(ex);
+ VpeTemplate defTemplate = templateManager.getDefTemplate();
+ creationData = defTemplate.create(getPageContext(), sourceNode,
+ getVisualDocument());
+ }
+
+ getPageContext().setCurrentVisualNode(null);
+
+ nsIDOMNode visualNewNode = creationData.getNode();
+
+ nsIDOMElement border = null;
+
+ if (visualNewNode != null
+ && visualNewNode.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
+
+ nsIDOMElement visualNewElement = (nsIDOMElement) creationData
+ .getNode().queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+
+ if ((visualNewElement != null) && template.hasImaginaryBorder()) {
+
+ visualNewElement.setAttribute(HTML.ATTR_STYLE, visualNewElement
+ .getAttribute(HTML.ATTR_STYLE)
+ + VpeStyleUtil.SEMICOLON_STRING + DOTTED_BORDER);
+
+ }
+ if (visualNewElement != null) {
+ correctVisualAttribute(visualNewElement);
+ }
+ if (YES_STRING.equals(VpePreference.SHOW_BORDER_FOR_ALL_TAGS
+ .getValue())
+ && visualNewElement != null) {
+ boolean block = true;
+ if (template.getTagDescription(null, null, null,
+ visualNewElement, null).getDisplayType() == VpeTagDescription.DISPLAY_TYPE_INLINE) {
+ block = false;
+ }
+ border = createBorder(sourceNode, visualNewElement, block);
+ }
+ if (!isCurrentMainDocument() && visualNewElement != null) {
+ setReadOnlyElement(visualNewElement);
+ }
+ }
+
+ if (sourceNode instanceof Element && visualNewNode != null
+ && visualNewNode.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
+
+ setTooltip((Element) sourceNode, (nsIDOMElement) visualNewNode
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID));
+ }
+ if (registerFlag) {
+
+ final VpeElementData data = creationData.getElementData();
+
+ if ((sourceNodeClone != null) && (data != null)
+ && (data.getNodesData() != null)
+ && (data.getNodesData().size() > 0)) {
+
+ if (template instanceof IEditableTemplate) {
+ final IEditableTemplate editableTemplate = (IEditableTemplate) template;
+
+ for (org.jboss.tools.vpe.editor.mapping.NodeData nodeData : data
+ .getNodesData()) {
+ Attr attr = editableTemplate
+ .getOutputAttributeNode((Element) sourceNode);
+ if (attr != null) {
+ nodeData.setSourceNode(attr);
+ }
+ }
+ }
+
+ }
+ VpeElementMapping elementMapping = new VpeElementMapping(
+ sourceNode, visualNewNode, border, template,
+ ifDependencySet, creationData.getData(), data);
+ registerNodes(elementMapping);
+ }
+ if (template.isChildren()) {
+ List<?> childrenInfoList = creationData.getChildrenInfoList();
+ if (childrenInfoList == null) {
+ addChildren(template, sourceNode,
+ visualNewNode != null ? visualNewNode
+ : visualOldContainer);
+ } else {
+ addChildren(template, sourceNode, visualOldContainer,
+ childrenInfoList);
+ }
+ }
+ getPageContext().setCurrentVisualNode(visualOldContainer);
+ template.validate(getPageContext(), sourceNode, visualDocument,
+ creationData);
+ getPageContext().setCurrentVisualNode(null);
+
+ // if showInvisibleTags mode
+ if (isShowInvisibleTags() && (visualNewNode != null)
&& (sourceNode.getNodeType() == Node.ELEMENT_NODE)) {
- // add invisible children to node
+ // add invisible children to node
visualNewNode = addInvisibleChildren(sourceNode, visualNewNode);
}
-
- if (border != null)
- return border;
- else
- return visualNewNode;
- }
- private void correctVisualAttribute(nsIDOMElement element) {
+ if (border != null)
+ return border;
+ else
+ return visualNewNode;
+ }
- String styleValue = element.getAttribute(HTML.TAG_STYLE);
- String backgroundValue = element
- .getAttribute(VpeStyleUtil.PARAMETR_BACKGROND);
+ private void correctVisualAttribute(nsIDOMElement element) {
- if (styleValue != null) {
- styleValue = VpeStyleUtil.addFullPathIntoURLValue(styleValue,
- pageContext.getEditPart().getEditorInput());
- element.setAttribute(HTML.TAG_STYLE, styleValue);
- }
- if (backgroundValue != null) {
- backgroundValue = VpeStyleUtil
- .addFullPathIntoBackgroundValue(backgroundValue,
- pageContext.getEditPart().getEditorInput());
- element.setAttribute(VpeStyleUtil.PARAMETR_BACKGROND,
- backgroundValue);
- }
- }
+ String styleValue = element.getAttribute(HTML.TAG_STYLE);
+ String backgroundValue = element
+ .getAttribute(VpeStyleUtil.PARAMETR_BACKGROND);
- protected void addChildren(VpeTemplate containerTemplate,
- Node sourceContainer, nsIDOMNode visualContainer) {
-
- /*
- * Fixes http://jira.jboss.com/jira/browse/JBIDE-1944
- * author: Denis Maliarevich
- * This method is called when template has no childrenInfoList.
- * In this case h:dataTable and h:panelGrid should display pseudo text
- */
- if (containerTemplate instanceof VpeHtmlTemplate) {
- int type = ((VpeHtmlTemplate) containerTemplate).getType();
- if ((VpeHtmlTemplate.TYPE_DATATABLE == type)
- || (VpeHtmlTemplate.TYPE_PANELGRID == type)) {
- setPseudoContent(containerTemplate, sourceContainer,
- visualContainer);
- return;
- }
- }
-
- NodeList sourceNodes = sourceContainer.getChildNodes();
- int len = sourceNodes.getLength();
- int childrenCount = 0;
- for (int i = 0; i < len; i++) {
- Node sourceNode = sourceNodes.item(i);
- if ((!isInvisibleNode(sourceNode))
+ if (styleValue != null) {
+ styleValue = VpeStyleUtil.addFullPathIntoURLValue(styleValue,
+ pageContext.getEditPart().getEditorInput());
+ element.setAttribute(HTML.TAG_STYLE, styleValue);
+ }
+ if (backgroundValue != null) {
+ backgroundValue = VpeStyleUtil
+ .addFullPathIntoBackgroundValue(backgroundValue,
+ pageContext.getEditPart().getEditorInput());
+ element.setAttribute(VpeStyleUtil.PARAMETR_BACKGROND,
+ backgroundValue);
+ }
+ }
+
+ protected void addChildren(VpeTemplate containerTemplate,
+ Node sourceContainer, nsIDOMNode visualContainer) {
+
+ /*
+ * Fixes http://jira.jboss.com/jira/browse/JBIDE-1944 author: Denis
+ * Maliarevich This method is called when template has no
+ * childrenInfoList. In this case h:dataTable and h:panelGrid should
+ * display pseudo text
+ */
+ if (containerTemplate instanceof VpeHtmlTemplate) {
+ int type = ((VpeHtmlTemplate) containerTemplate).getType();
+ if ((VpeHtmlTemplate.TYPE_DATATABLE == type)
+ || (VpeHtmlTemplate.TYPE_PANELGRID == type)) {
+ setPseudoContent(containerTemplate, sourceContainer,
+ visualContainer);
+ return;
+ }
+ }
+
+ NodeList sourceNodes = sourceContainer.getChildNodes();
+ int len = sourceNodes.getLength();
+ int childrenCount = 0;
+ for (int i = 0; i < len; i++) {
+ Node sourceNode = sourceNodes.item(i);
+ if ((!isInvisibleNode(sourceNode))
&& (addNode(sourceNode, null, visualContainer))) {
- if (Node.ELEMENT_NODE == sourceNode.getNodeType()) {
- }
- childrenCount++;
- }
- }
+ if (Node.ELEMENT_NODE == sourceNode.getNodeType()) {
+ }
+ childrenCount++;
+ }
+ }
- if (childrenCount == 0) {
- setPseudoContent(containerTemplate, sourceContainer,
- visualContainer);
- }
- }
+ if (childrenCount == 0) {
+ setPseudoContent(containerTemplate, sourceContainer,
+ visualContainer);
+ }
+ }
- protected void addChildren(VpeTemplate containerTemplate,
- Node sourceContainer, nsIDOMNode visualOldContainer,
- List<?> childrenInfoList) {
- for (int i = 0; i < childrenInfoList.size(); i++) {
- VpeChildrenInfo info = (VpeChildrenInfo) childrenInfoList.get(i);
- nsIDOMNode visualParent = info.getVisualParent();
- if (visualParent == null)
- visualParent = visualOldContainer;
- List<?> sourceChildren = info.getSourceChildren();
- int childrenCount = 0;
- if (sourceChildren != null) {
- for (int j = 0; j < sourceChildren.size(); j++) {
- Node child = (Node) sourceChildren.get(j);
- if ((!isInvisibleNode(child))
+ protected void addChildren(VpeTemplate containerTemplate,
+ Node sourceContainer, nsIDOMNode visualOldContainer,
+ List<?> childrenInfoList) {
+ for (int i = 0; i < childrenInfoList.size(); i++) {
+ VpeChildrenInfo info = (VpeChildrenInfo) childrenInfoList.get(i);
+ nsIDOMNode visualParent = info.getVisualParent();
+ if (visualParent == null)
+ visualParent = visualOldContainer;
+ List<?> sourceChildren = info.getSourceChildren();
+ int childrenCount = 0;
+ if (sourceChildren != null) {
+ for (int j = 0; j < sourceChildren.size(); j++) {
+ Node child = (Node) sourceChildren.get(j);
+ if ((!isInvisibleNode(child))
&& addNode((Node) sourceChildren.get(j), null,
visualParent)) {
childrenCount++;
}
- }
- }
- if (childrenCount == 0 && childrenInfoList.size() == 0) {
- setPseudoContent(containerTemplate, sourceContainer,
- visualParent);
- }
- }
- }
-
- /**
+ }
+ }
+ if (childrenCount == 0 && childrenInfoList.size() == 0) {
+ setPseudoContent(containerTemplate, sourceContainer,
+ visualParent);
+ }
+ }
+ }
+
+ /**
*
* @param containerTemplate
* @param sourceContainer
@@ -648,15 +660,14 @@
// add all invisible tags to wrapper
NodeList sourceNodes = sourceContainer.getChildNodes();
-
for (int i = 0; i < sourceNodes.getLength(); i++) {
Node child = sourceNodes.item(i);
-
+
if (isInvisibleNode(child)) {
addNode(child, null, wrapper);
- count++ ;
+ count++;
}
}
}
@@ -664,7 +675,7 @@
return count > 0 ? wrapper : visualContainer;
}
-
+
/**
*
* @param node
@@ -683,1731 +694,1742 @@
}
- // /////////////////////////////////////////////////////////////////////////
- public nsIDOMNode addStyleNodeToHead(String styleText) {
- nsIDOMNode newStyle = visualDocument
- .createElement(VpeStyleUtil.ATTRIBUTE_STYLE);
+ // /////////////////////////////////////////////////////////////////////////
+ public nsIDOMNode addStyleNodeToHead(String styleText) {
+ nsIDOMNode newStyle = visualDocument
+ .createElement(VpeStyleUtil.ATTRIBUTE_STYLE);
- if (styleText != null) {
- nsIDOMText newText = visualDocument.createTextNode(styleText);
- newStyle.appendChild(newText);
- }
- getHeadNode().appendChild(newStyle);
- return newStyle;
- }
+ if (styleText != null) {
+ nsIDOMText newText = visualDocument.createTextNode(styleText);
+ newStyle.appendChild(newText);
+ }
+ getHeadNode().appendChild(newStyle);
+ return newStyle;
+ }
- public nsIDOMNode replaceStyleNodeToHead(nsIDOMNode oldStyleNode,
- String styleText) {
- nsIDOMElement newStyle = visualDocument
- .createElement(VpeStyleUtil.ATTRIBUTE_STYLE);
+ public nsIDOMNode replaceStyleNodeToHead(nsIDOMNode oldStyleNode,
+ String styleText) {
+ nsIDOMElement newStyle = visualDocument
+ .createElement(VpeStyleUtil.ATTRIBUTE_STYLE);
- if (styleText != null) {
- nsIDOMNode newText = visualDocument.createTextNode(styleText);
- newStyle.appendChild(newText);
- }
+ if (styleText != null) {
+ nsIDOMNode newText = visualDocument.createTextNode(styleText);
+ newStyle.appendChild(newText);
+ }
- getHeadNode().replaceChild(newStyle, oldStyleNode);
- return newStyle;
- }
+ getHeadNode().replaceChild(newStyle, oldStyleNode);
+ return newStyle;
+ }
- public void removeStyleNodeFromHead(nsIDOMNode oldStyleNode) {
- getHeadNode().removeChild(oldStyleNode);
- }
+ public void removeStyleNodeFromHead(nsIDOMNode oldStyleNode) {
+ getHeadNode().removeChild(oldStyleNode);
+ }
- void addExternalLinks() {
- IEditorInput input = pageContext.getEditPart().getEditorInput();
- IFile file = null;
- if (input instanceof IFileEditorInput) {
- file = ((IFileEditorInput) input).getFile();
- }
- ResourceReference[] l = null;
- if (file != null) {
- l = CSSReferenceList.getInstance().getAllResources(file);
- }
- if (l != null) {
- for (int i = 0; i < l.length; i++) {
- ResourceReference item = l[i];
- addLinkNodeToHead("file:///" + item.getLocation(), YES_STRING); //$NON-NLS-1$
- }
- }
- }
+ void addExternalLinks() {
+ IEditorInput input = pageContext.getEditPart().getEditorInput();
+ IFile file = null;
+ if (input instanceof IFileEditorInput) {
+ file = ((IFileEditorInput) input).getFile();
+ }
+ ResourceReference[] l = null;
+ if (file != null) {
+ l = CSSReferenceList.getInstance().getAllResources(file);
+ }
+ if (l != null) {
+ for (int i = 0; i < l.length; i++) {
+ ResourceReference item = l[i];
+ addLinkNodeToHead("file:///" + item.getLocation(), YES_STRING); //$NON-NLS-1$
+ }
+ }
+ }
- void removeExternalLinks() {
- nsIDOMNodeList childs = getHeadNode().getChildNodes();
- long length = childs.getLength();
- for (long i = length - 1; i >= 0; i--) {
- nsIDOMNode node = childs.item(i);
- if (node.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
- boolean isLink = false;
- boolean isStyle = false;
- if ((isLink = HTML.TAG_LINK
- .equalsIgnoreCase(node.getNodeName()))
- || (isStyle = HTML.TAG_STYLE.equalsIgnoreCase(node
- .getNodeName()))) {
- nsIDOMElement element = (nsIDOMElement) node
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- if ((isLink || (isStyle && ATTR_VPE_INLINE_LINK_VALUE
- .equalsIgnoreCase(element.getAttribute(ATTR_VPE))))
- && YES_STRING.equalsIgnoreCase(element
- .getAttribute(VpeTemplateManager.ATTR_LINK_EXT))) {
- getHeadNode().removeChild(node);
- }
- }
- }
- }
- }
+ void removeExternalLinks() {
+ nsIDOMNodeList childs = getHeadNode().getChildNodes();
+ long length = childs.getLength();
+ for (long i = length - 1; i >= 0; i--) {
+ nsIDOMNode node = childs.item(i);
+ if (node.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
+ boolean isLink = false;
+ boolean isStyle = false;
+ if ((isLink = HTML.TAG_LINK
+ .equalsIgnoreCase(node.getNodeName()))
+ || (isStyle = HTML.TAG_STYLE.equalsIgnoreCase(node
+ .getNodeName()))) {
+ nsIDOMElement element = (nsIDOMElement) node
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ if ((isLink || (isStyle && ATTR_VPE_INLINE_LINK_VALUE
+ .equalsIgnoreCase(element.getAttribute(ATTR_VPE))))
+ && YES_STRING
+ .equalsIgnoreCase(element
+ .getAttribute(VpeTemplateManager.ATTR_LINK_EXT))) {
+ getHeadNode().removeChild(node);
+ }
+ }
+ }
+ }
+ }
- void refreshExternalLinks() {
- removeExternalLinks();
- addExternalLinks();
- }
+ void refreshExternalLinks() {
+ removeExternalLinks();
+ addExternalLinks();
+ }
- // ==========================================================
- void resetPseudoElement(nsIDOMNode visualNode) {
- if (visualNode != null) {
- nsIDOMNode visualParent = visualNode.getParentNode();
- if (visualParent != null) {
- PseudoInfo info = getPseudoInfo(visualParent);
- if (info.pseudoNode == null && !info.isElements) {
- addPseudoElementImpl(visualParent);
- } else if (info.pseudoNode != null && info.isElements) {
- visualParent.removeChild(info.pseudoNode);
- }
- }
- }
- }
+ // ==========================================================
+ void resetPseudoElement(nsIDOMNode visualNode) {
+ if (visualNode != null) {
+ nsIDOMNode visualParent = visualNode.getParentNode();
+ if (visualParent != null) {
+ PseudoInfo info = getPseudoInfo(visualParent);
+ if (info.pseudoNode == null && !info.isElements) {
+ addPseudoElementImpl(visualParent);
+ } else if (info.pseudoNode != null && info.isElements) {
+ visualParent.removeChild(info.pseudoNode);
+ }
+ }
+ }
+ }
- private PseudoInfo getPseudoInfo(nsIDOMNode visualParent) {
- nsIDOMNode pseudoNode = null;
- boolean isElements = false;
+ private PseudoInfo getPseudoInfo(nsIDOMNode visualParent) {
+ nsIDOMNode pseudoNode = null;
+ boolean isElements = false;
- if (visualParent == null)
- return new PseudoInfo();
- nsIDOMNodeList visualNodes = visualParent.getChildNodes();
- if (visualNodes == null)
- return new PseudoInfo();
+ if (visualParent == null)
+ return new PseudoInfo();
+ nsIDOMNodeList visualNodes = visualParent.getChildNodes();
+ if (visualNodes == null)
+ return new PseudoInfo();
- long length = visualNodes.getLength();
- for (long i = 0; i < length; i++) {
- nsIDOMNode visualNode = visualNodes.item(i);
- if (pseudoNode == null && isPseudoElement(visualNode)) {
- pseudoNode = visualNode;
- } else if (!isEmptyText(visualNode)) {
- isElements = true;
- }
- if (pseudoNode != null && isElements) {
- break;
- }
- }
- return new PseudoInfo(pseudoNode, isElements);
- }
+ long length = visualNodes.getLength();
+ for (long i = 0; i < length; i++) {
+ nsIDOMNode visualNode = visualNodes.item(i);
+ if (pseudoNode == null && isPseudoElement(visualNode)) {
+ pseudoNode = visualNode;
+ } else if (!isEmptyText(visualNode)) {
+ isElements = true;
+ }
+ if (pseudoNode != null && isElements) {
+ break;
+ }
+ }
+ return new PseudoInfo(pseudoNode, isElements);
+ }
- static boolean isInitElement(nsIDOMNode visualNode) {
- if (visualNode == null) {
- return false;
- }
+ static boolean isInitElement(nsIDOMNode visualNode) {
+ if (visualNode == null) {
+ return false;
+ }
- if (visualNode.getNodeType() != Node.ELEMENT_NODE) {
- return false;
- }
+ if (visualNode.getNodeType() != Node.ELEMENT_NODE) {
+ return false;
+ }
- if (YES_STRING.equalsIgnoreCase(((nsIDOMElement) visualNode)
- .getAttribute(INIT_ELEMENT_ATTR))) {
- return true;
- }
+ if (YES_STRING.equalsIgnoreCase(((nsIDOMElement) visualNode)
+ .getAttribute(INIT_ELEMENT_ATTR))) {
+ return true;
+ }
- return false;
- }
+ return false;
+ }
- static boolean isPseudoElement(nsIDOMNode visualNode) {
- if (visualNode == null) {
- return false;
- }
+ static boolean isPseudoElement(nsIDOMNode visualNode) {
+ if (visualNode == null) {
+ return false;
+ }
- if (visualNode.getNodeType() != Node.ELEMENT_NODE) {
- return false;
- }
+ if (visualNode.getNodeType() != Node.ELEMENT_NODE) {
+ return false;
+ }
- if (YES_STRING.equalsIgnoreCase(((nsIDOMElement) visualNode
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
- .getAttribute(PSEUDO_ELEMENT_ATTR))) {
- return true;
- }
+ if (YES_STRING.equalsIgnoreCase(((nsIDOMElement) visualNode
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
+ .getAttribute(PSEUDO_ELEMENT_ATTR))) {
+ return true;
+ }
- return false;
- }
+ return false;
+ }
- private void setPseudoContent(VpeTemplate containerTemplate,
- Node sourceContainer, nsIDOMNode visualContainer) {
- if (containerTemplate != null) {
- containerTemplate.setPseudoContent(pageContext, sourceContainer,
- visualContainer, visualDocument);
- } else {
- try {
- VpeDefaultPseudoContentCreator.getInstance().setPseudoContent(
- pageContext, sourceContainer, visualContainer,
- visualDocument);
- } catch (VpeExpressionException ex) {
- VpeExpressionException exception = new VpeExpressionException("Error for source node"+sourceContainer.toString(),ex); //$NON-NLS-1$
- VpePlugin.reportProblem(exception);
+ private void setPseudoContent(VpeTemplate containerTemplate,
+ Node sourceContainer, nsIDOMNode visualContainer) {
+ if (containerTemplate != null) {
+ containerTemplate.setPseudoContent(pageContext, sourceContainer,
+ visualContainer, visualDocument);
+ } else {
+ try {
+ VpeDefaultPseudoContentCreator.getInstance().setPseudoContent(
+ pageContext, sourceContainer, visualContainer,
+ visualDocument);
+ } catch (VpeExpressionException ex) {
+ VpeExpressionException exception = new VpeExpressionException(
+ "Error for source node" + sourceContainer.toString(), ex); //$NON-NLS-1$
+ VpePlugin.reportProblem(exception);
+ }
}
- }
- // if (isEmptyElement(visualContainer)) {
- // addPseudoElementImpl(visualContainer);
- // }
- }
+ // if (isEmptyElement(visualContainer)) {
+ // addPseudoElementImpl(visualContainer);
+ // }
+ }
- private void addPseudoElementImpl(nsIDOMNode visualParent) {
- if (!templateManager.isWithoutPseudoElementContainer(visualParent
- .getNodeName())) {
- if (VpeDebug.VISUAL_ADD_PSEUDO_ELEMENT) {
- System.out.println("-------------------- addPseudoElement: " //$NON-NLS-1$
- + visualParent.getNodeName());
- }
- nsIDOMElement visualPseudoElement = visualDocument
- .createElement(PSEUDO_ELEMENT);
- visualPseudoElement.setAttribute(PSEUDO_ELEMENT_ATTR, YES_STRING);
- visualParent.appendChild(visualPseudoElement);
- }
- }
+ private void addPseudoElementImpl(nsIDOMNode visualParent) {
+ if (!templateManager.isWithoutPseudoElementContainer(visualParent
+ .getNodeName())) {
+ if (VpeDebug.VISUAL_ADD_PSEUDO_ELEMENT) {
+ System.out.println("-------------------- addPseudoElement: " //$NON-NLS-1$
+ + visualParent.getNodeName());
+ }
+ nsIDOMElement visualPseudoElement = visualDocument
+ .createElement(PSEUDO_ELEMENT);
+ visualPseudoElement.setAttribute(PSEUDO_ELEMENT_ATTR, YES_STRING);
+ visualParent.appendChild(visualPseudoElement);
+ }
+ }
- public boolean isEmptyElement(nsIDOMNode visualParent) {
- nsIDOMNodeList visualNodes = visualParent.getChildNodes();
- long len = visualNodes.getLength();
+ public boolean isEmptyElement(nsIDOMNode visualParent) {
+ nsIDOMNodeList visualNodes = visualParent.getChildNodes();
+ long len = visualNodes.getLength();
- if ((len == 0) || (len == 1 && isEmptyText(visualNodes.item(0)))) {
- return true;
- }
+ if ((len == 0) || (len == 1 && isEmptyText(visualNodes.item(0)))) {
+ return true;
+ }
- return false;
- }
+ return false;
+ }
- public boolean isEmptyDocument() {
- nsIDOMNodeList visualNodes = getContentArea().getChildNodes();
- long len = visualNodes.getLength();
- if ((len == 0)
- || (len == 1 && (isEmptyText(visualNodes.item(0)) || isPseudoElement(visualNodes
- .item(0))))) {
- return true;
- }
+ public boolean isEmptyDocument() {
+ nsIDOMNodeList visualNodes = getContentArea().getChildNodes();
+ long len = visualNodes.getLength();
+ if ((len == 0)
+ || (len == 1 && (isEmptyText(visualNodes.item(0)) || isPseudoElement(visualNodes
+ .item(0))))) {
+ return true;
+ }
- return false;
- }
+ return false;
+ }
- private boolean isEmptyText(nsIDOMNode visualNode) {
- if (visualNode == null
- || (visualNode.getNodeType() != nsIDOMNode.TEXT_NODE)) {
- return false;
- }
+ private boolean isEmptyText(nsIDOMNode visualNode) {
+ if (visualNode == null
+ || (visualNode.getNodeType() != nsIDOMNode.TEXT_NODE)) {
+ return false;
+ }
- if (visualNode.getNodeValue().trim().length() == 0) {
- return true;
- }
+ if (visualNode.getNodeValue().trim().length() == 0) {
+ return true;
+ }
- return false;
- }
+ return false;
+ }
- // ==========================================================
+ // ==========================================================
- public void updateNode(Node sourceNode) {
- if (sourceNode == null)
- return;
+ public void updateNode(Node sourceNode) {
+ if (sourceNode == null)
+ return;
- switch (sourceNode.getNodeType()) {
- case Node.DOCUMENT_NODE:
- rebuildDom((Document) sourceNode);
- break;
-// case Node.COMMENT_NODE:
-// updateComment(sourceNode);
-// break;
- default:
- updateElement(getNodeForUpdate(sourceNode));
- }
- }
+ switch (sourceNode.getNodeType()) {
+ case Node.DOCUMENT_NODE:
+ rebuildDom((Document) sourceNode);
+ break;
+ // case Node.COMMENT_NODE:
+ // updateComment(sourceNode);
+ // break;
+ default:
+ updateElement(getNodeForUpdate(sourceNode));
+ }
+ }
- // TODO Ssergey Vasilyev make a common code for figuring out
- // if it is need to update parent node or not
- private Node getNodeForUpdate(Node sourceNode) {
- /* Changing of <tr> or <td> tags can affect whole the table */
- Node sourceTable = getParentTable(sourceNode, 2);
- if (sourceTable != null) {
- return sourceTable;
- }
+ // TODO Ssergey Vasilyev make a common code for figuring out
+ // if it is need to update parent node or not
+ private Node getNodeForUpdate(Node sourceNode) {
+ /* Changing of <tr> or <td> tags can affect whole the table */
+ Node sourceTable = getParentTable(sourceNode, 2);
+ if (sourceTable != null) {
+ return sourceTable;
+ }
- /* Changing of an <option> tag can affect the parent select */
- Node sourceSelect = getParentSelect(sourceNode);
- if (sourceSelect != null) {
- return sourceSelect;
- }
+ /* Changing of an <option> tag can affect the parent select */
+ Node sourceSelect = getParentSelect(sourceNode);
+ if (sourceSelect != null) {
+ return sourceSelect;
+ }
- return sourceNode;
- }
+ return sourceNode;
+ }
-// private void updateComment(Node sourceNode) {
-// VpeNodeMapping mapping = domMapping.getNodeMapping(sourceNode);
-// if (mapping != null
-// && mapping.getType() == VpeNodeMapping.COMMENT_MAPPING) {
-// nsIDOMNodeList visualNodes = mapping.getVisualNode()
-// .getChildNodes();
-//
-// if (visualNodes.getLength() > 0) {
-// visualNodes.item(0).setNodeValue(sourceNode.getNodeValue());
-// }
-// }
-// }
+ // private void updateComment(Node sourceNode) {
+ // VpeNodeMapping mapping = domMapping.getNodeMapping(sourceNode);
+ // if (mapping != null
+ // && mapping.getType() == VpeNodeMapping.COMMENT_MAPPING) {
+ // nsIDOMNodeList visualNodes = mapping.getVisualNode()
+ // .getChildNodes();
+ //
+ // if (visualNodes.getLength() > 0) {
+ // visualNodes.item(0).setNodeValue(sourceNode.getNodeValue());
+ // }
+ // }
+ // }
- private void updateElement(Node sourceNode) {
- VpeElementMapping elementMapping = null;
- VpeNodeMapping nodeMapping = domMapping.getNodeMapping(sourceNode);
- if (nodeMapping instanceof VpeElementMapping) {
-
- elementMapping = (VpeElementMapping) nodeMapping;
- if (elementMapping != null && elementMapping.getTemplate() != null) {
- Node updateNode = elementMapping.getTemplate()
- .getNodeForUptate(pageContext,
- elementMapping.getSourceNode(),
- elementMapping.getVisualNode(),
- elementMapping.getData());
+ private void updateElement(Node sourceNode) {
+ VpeElementMapping elementMapping = null;
+ VpeNodeMapping nodeMapping = domMapping.getNodeMapping(sourceNode);
+ if (nodeMapping instanceof VpeElementMapping) {
- /*
- * special processing of "style" element
- *
- * for unification of updating nodes - or redevelop updating
- * mechanism (for example : transfer this function to template )
- * or redevelop template of "style" element
- */
- if (HTML.TAG_STYLE.equalsIgnoreCase(sourceNode.getNodeName())) {
- // refresh style node
- VpeStyleUtil.refreshStyleElement(this, elementMapping);
- return;
- }
- if (updateNode != null && updateNode != sourceNode) {
- updateNode(updateNode);
- return;
- }
- }
- }
-
-
- nsIDOMNode visualOldNode = domMapping.remove(sourceNode);
- getSourceNodes().remove(sourceNode);
-
- if (sourceNode instanceof INodeNotifier) {
- ((INodeNotifier) sourceNode).removeAdapter(getSorceAdapter());
- }
- if (visualOldNode != null) {
- if (elementMapping != null) {
- nsIDOMElement border = elementMapping.getBorder();
- if (border != null) {
- visualOldNode = border;
- }
- }
- nsIDOMNode visualContainer = visualOldNode.getParentNode();
- nsIDOMNode visualNextNode = visualOldNode.getNextSibling();
- if (visualContainer != null) {
- visualContainer.removeChild(visualOldNode);
- addNode(sourceNode, visualNextNode, visualContainer);
- }
- } else {
- // Max Areshkau Why we need update parent node when we update text
- // node?
- // lookd like we haven't need do it.
- if (sourceNode.getNodeType() == Node.TEXT_NODE) {
- updateNode(sourceNode.getParentNode());
- }
- }
- }
+ elementMapping = (VpeElementMapping) nodeMapping;
+ if (elementMapping != null && elementMapping.getTemplate() != null) {
+ Node updateNode = elementMapping.getTemplate()
+ .getNodeForUptate(pageContext,
+ elementMapping.getSourceNode(),
+ elementMapping.getVisualNode(),
+ elementMapping.getData());
- public void removeNode(Node sourceNode) {
- //remove from cash should be called first
- domMapping.remove(sourceNode);
- getSourceNodes().remove(sourceNode);
- if (sourceNode instanceof INodeNotifier) {
- ((INodeNotifier) sourceNode).removeAdapter(getSorceAdapter());
- }
- }
+ /*
+ * special processing of "style" element
+ *
+ * for unification of updating nodes - or redevelop updating
+ * mechanism (for example : transfer this function to template )
+ * or redevelop template of "style" element
+ */
+ if (HTML.TAG_STYLE.equalsIgnoreCase(sourceNode.getNodeName())) {
+ // refresh style node
+ VpeStyleUtil.refreshStyleElement(this, elementMapping);
+ return;
+ }
+ if (updateNode != null && updateNode != sourceNode) {
+ updateNode(updateNode);
+ return;
+ }
+ }
+ }
- private Node getParentTable(Node sourceNode, int depth) {
- Node parentNode = sourceNode.getParentNode();
- for (int i = 0; parentNode != null && i < depth; parentNode = parentNode
- .getParentNode(), i++) {
- if (HTML.TAG_TABLE.equalsIgnoreCase(parentNode.getNodeName())) {
- return parentNode;
- }
- }
- return null;
- }
+ nsIDOMNode visualOldNode = domMapping.remove(sourceNode);
+ getSourceNodes().remove(sourceNode);
- private Node getParentSelect(Node sourceNode) {
- if (HTML.TAG_OPTION.equalsIgnoreCase(sourceNode.getNodeName())) {
- Node parentNode = sourceNode.getParentNode();
- if (HTML.TAG_SELECT.equalsIgnoreCase(parentNode.getNodeName())) {
- return parentNode;
- }
- }
- return null;
- }
+ if (sourceNode instanceof INodeNotifier) {
+ ((INodeNotifier) sourceNode).removeAdapter(getSorceAdapter());
+ }
+ if (visualOldNode != null) {
+ if (elementMapping != null) {
+ nsIDOMElement border = elementMapping.getBorder();
+ if (border != null) {
+ visualOldNode = border;
+ }
+ }
+ nsIDOMNode visualContainer = visualOldNode.getParentNode();
+ nsIDOMNode visualNextNode = visualOldNode.getNextSibling();
+ if (visualContainer != null) {
+ visualContainer.removeChild(visualOldNode);
+ addNode(sourceNode, visualNextNode, visualContainer);
+ }
+ } else {
+ // Max Areshkau Why we need update parent node when we update text
+ // node?
+ // lookd like we haven't need do it.
+ if (sourceNode.getNodeType() == Node.TEXT_NODE) {
+ updateNode(sourceNode.getParentNode());
+ }
+ }
+ }
- // public void setText(Node sourceText) {
- // Node sourceParent = sourceText.getParentNode();
- // if (sourceParent != null && sourceParent.getLocalName() != null) {
- // String sourceParentName = sourceParent.getLocalName();
- // if (HTML.TAG_TEXTAREA.equalsIgnoreCase(sourceParentName)
- // || HTML.TAG_OPTION.equalsIgnoreCase(sourceParentName)) {
- // updateNode(sourceText.getParentNode());
- // return;
- // }
- // }
- // nsIDOMNode visualText = domMapping.getVisualNode(sourceText);
- // if (visualText != null) {
- // String visualValue = TextUtil.visualText(sourceText.getNodeValue());
- // visualText.setNodeValue(visualValue);
- // }else {
- // VpeNodeMapping nodeMapping = domMapping
- // .getNodeMapping(sourceParent);
- // if (nodeMapping != null
- // && nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
- // VpeTemplate template = ((VpeElementMapping) nodeMapping)
- // .getTemplate();
- // if (template != null) {
- // if (!template.containsText()) {
- // return;
- // }
- public boolean setText(Node sourceText) {
- Node sourceParent = sourceText.getParentNode();
- if (sourceParent != null && sourceParent.getLocalName() != null) {
- String sourceParentName = sourceParent.getLocalName();
- if (HTML.TAG_TEXTAREA.equalsIgnoreCase(sourceParentName)
- || HTML.TAG_OPTION.equalsIgnoreCase(sourceParentName) || HTML.TAG_STYLE.equalsIgnoreCase(sourceParentName)) {
- updateNode(sourceText.getParentNode());
- return true;
- }
- }
- nsIDOMNode visualText = domMapping.getVisualNode(sourceText);
- if (visualText != null) {
- String visualValue = TextUtil.visualText(sourceText.getNodeValue());
- visualText.setNodeValue(visualValue);
- } else {
- VpeNodeMapping nodeMapping = domMapping
- .getNodeMapping(sourceParent);
- if (nodeMapping != null
- && nodeMapping instanceof VpeElementMapping) {
- VpeTemplate template = ((VpeElementMapping) nodeMapping)
- .getTemplate();
- if (template != null) {
- if (!template.containsText()) {
- return false;
- }
- }
- }
- updateNode(sourceText);
- return true;
- }
+ public void removeNode(Node sourceNode) {
+ // remove from cash should be called first
+ domMapping.remove(sourceNode);
+ getSourceNodes().remove(sourceNode);
+ if (sourceNode instanceof INodeNotifier) {
+ ((INodeNotifier) sourceNode).removeAdapter(getSorceAdapter());
+ }
+ }
- // }
- // updateNode(sourceText);
- return false;
- }
+ private Node getParentTable(Node sourceNode, int depth) {
+ Node parentNode = sourceNode.getParentNode();
+ for (int i = 0; parentNode != null && i < depth; parentNode = parentNode
+ .getParentNode(), i++) {
+ if (HTML.TAG_TABLE.equalsIgnoreCase(parentNode.getNodeName())) {
+ return parentNode;
+ }
+ }
+ return null;
+ }
- // }
+ private Node getParentSelect(Node sourceNode) {
+ if (HTML.TAG_OPTION.equalsIgnoreCase(sourceNode.getNodeName())) {
+ Node parentNode = sourceNode.getParentNode();
+ if (HTML.TAG_SELECT.equalsIgnoreCase(parentNode.getNodeName())) {
+ return parentNode;
+ }
+ }
+ return null;
+ }
- public void setAttribute(Element sourceElement, String name, String value) {
- VpeElementMapping elementMapping = (VpeElementMapping) domMapping
- .getNodeMapping(sourceElement);
- if (elementMapping != null) {
- if (elementMapping.isIfDependencyFromAttribute(name)) {
- updateElement(sourceElement);
- } else {
- VpeTemplate template = elementMapping.getTemplate();
- if (elementMapping.getBorder() != null) {
- updateElement(sourceElement);
- } else if (template.isRecreateAtAttrChange(pageContext,
- sourceElement, visualDocument,
- (nsIDOMElement) elementMapping.getVisualNode(),
- elementMapping.getData(), name, value)) {
- updateElement(sourceElement);
- } else {
- nsIDOMElement visualElement = (nsIDOMElement) elementMapping
- .getVisualNode();
- if (visualElement != null) {
- String visualElementName = visualElement.getNodeName();
- if (HTML.TAG_SELECT.equalsIgnoreCase(visualElementName)) {
- updateElement(sourceElement);
- return;
- } else if (HTML.TAG_OPTION
- .equalsIgnoreCase(visualElementName)) {
- updateElement(sourceElement.getParentNode());
- return;
- } else if (HTML.TAG_INPUT
- .equalsIgnoreCase(visualElementName)) {
- updateElement(sourceElement);
- // Fixes JBIDE-1744 author dmaliarevich
- // unified h:dataTable border lookup
- // after attribute change and
- // after visual editor refresh
- } else if (HTML.TAG_TABLE
- .equalsIgnoreCase(visualElementName)) {
- updateElement(sourceElement);
- }
- // End of fix
- }
- // setXmlnsAttribute(elementMapping, name, value);
- template.setAttribute(pageContext, sourceElement,
- visualDocument, visualElement, elementMapping
- .getData(), name, value);
- resetTooltip(sourceElement, visualElement);
- }
- }
- }
- }
+ // public void setText(Node sourceText) {
+ // Node sourceParent = sourceText.getParentNode();
+ // if (sourceParent != null && sourceParent.getLocalName() != null) {
+ // String sourceParentName = sourceParent.getLocalName();
+ // if (HTML.TAG_TEXTAREA.equalsIgnoreCase(sourceParentName)
+ // || HTML.TAG_OPTION.equalsIgnoreCase(sourceParentName)) {
+ // updateNode(sourceText.getParentNode());
+ // return;
+ // }
+ // }
+ // nsIDOMNode visualText = domMapping.getVisualNode(sourceText);
+ // if (visualText != null) {
+ // String visualValue = TextUtil.visualText(sourceText.getNodeValue());
+ // visualText.setNodeValue(visualValue);
+ // }else {
+ // VpeNodeMapping nodeMapping = domMapping
+ // .getNodeMapping(sourceParent);
+ // if (nodeMapping != null
+ // && nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
+ // VpeTemplate template = ((VpeElementMapping) nodeMapping)
+ // .getTemplate();
+ // if (template != null) {
+ // if (!template.containsText()) {
+ // return;
+ // }
+ public boolean setText(Node sourceText) {
+ Node sourceParent = sourceText.getParentNode();
+ if (sourceParent != null && sourceParent.getLocalName() != null) {
+ String sourceParentName = sourceParent.getLocalName();
+ if (HTML.TAG_TEXTAREA.equalsIgnoreCase(sourceParentName)
+ || HTML.TAG_OPTION.equalsIgnoreCase(sourceParentName)
+ || HTML.TAG_STYLE.equalsIgnoreCase(sourceParentName)) {
+ updateNode(sourceText.getParentNode());
+ return true;
+ }
+ }
+ nsIDOMNode visualText = domMapping.getVisualNode(sourceText);
+ if (visualText != null) {
+ String visualValue = TextUtil.visualText(sourceText.getNodeValue());
+ visualText.setNodeValue(visualValue);
+ } else {
+ VpeNodeMapping nodeMapping = domMapping
+ .getNodeMapping(sourceParent);
+ if (nodeMapping != null && nodeMapping instanceof VpeElementMapping) {
+ VpeTemplate template = ((VpeElementMapping) nodeMapping)
+ .getTemplate();
+ if (template != null) {
+ if (!template.containsText()) {
+ return false;
+ }
+ }
+ }
+ updateNode(sourceText);
+ return true;
+ }
- public void stopToggle(Node sourceNode) {
- if (!(sourceNode instanceof Element))
- return;
+ // }
+ // updateNode(sourceText);
+ return false;
+ }
- Element sourceElement = (Element) sourceNode;
- VpeElementMapping elementMapping = (VpeElementMapping) domMapping
- .getNodeMapping(sourceElement);
- if (elementMapping != null) {
- VpeTemplate template = elementMapping.getTemplate();
+ // }
- if (template instanceof VpeToggableTemplate) {
- ((VpeToggableTemplate) template).stopToggling(sourceElement);
- }
- }
- }
+ public void setAttribute(Element sourceElement, String name, String value) {
+ VpeElementMapping elementMapping = (VpeElementMapping) domMapping
+ .getNodeMapping(sourceElement);
+ if (elementMapping != null) {
+ if (elementMapping.isIfDependencyFromAttribute(name)) {
+ updateElement(sourceElement);
+ } else {
+ VpeTemplate template = elementMapping.getTemplate();
+ if (elementMapping.getBorder() != null) {
+ updateElement(sourceElement);
+ } else if (template.isRecreateAtAttrChange(pageContext,
+ sourceElement, visualDocument,
+ (nsIDOMElement) elementMapping.getVisualNode(),
+ elementMapping.getData(), name, value)) {
+ updateElement(sourceElement);
+ } else {
+ nsIDOMElement visualElement = (nsIDOMElement) elementMapping
+ .getVisualNode();
+ if (visualElement != null) {
+ String visualElementName = visualElement.getNodeName();
+ if (HTML.TAG_SELECT.equalsIgnoreCase(visualElementName)) {
+ updateElement(sourceElement);
+ return;
+ } else if (HTML.TAG_OPTION
+ .equalsIgnoreCase(visualElementName)) {
+ updateElement(sourceElement.getParentNode());
+ return;
+ } else if (HTML.TAG_INPUT
+ .equalsIgnoreCase(visualElementName)) {
+ updateElement(sourceElement);
+ // Fixes JBIDE-1744 author dmaliarevich
+ // unified h:dataTable border lookup
+ // after attribute change and
+ // after visual editor refresh
+ } else if (HTML.TAG_TABLE
+ .equalsIgnoreCase(visualElementName)) {
+ updateElement(sourceElement);
+ }
+ // End of fix
+ }
+ // setXmlnsAttribute(elementMapping, name, value);
+ template.setAttribute(pageContext, sourceElement,
+ visualDocument, visualElement, elementMapping
+ .getData(), name, value);
+ resetTooltip(sourceElement, visualElement);
+ }
+ }
+ }
+ }
- public boolean doToggle(nsIDOMNode visualNode) {
- if (visualNode == null) {
- return false;
- }
- nsIDOMElement visualElement = null;
- try {
- visualElement = (nsIDOMElement) visualNode
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- } catch (XPCOMException exception) {
- visualElement = (nsIDOMElement) visualNode.getParentNode()
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- }
- if (visualElement == null) {
- return false;
- }
+ public void stopToggle(Node sourceNode) {
+ if (!(sourceNode instanceof Element))
+ return;
- nsIDOMAttr toggleIdAttr = visualElement
- .getAttributeNode(VPE_USER_TOGGLE_ID);
- if (toggleIdAttr == null) {
- return false;
- }
- String toggleId = toggleIdAttr.getNodeValue();
+ Element sourceElement = (Element) sourceNode;
+ VpeElementMapping elementMapping = (VpeElementMapping) domMapping
+ .getNodeMapping(sourceElement);
+ if (elementMapping != null) {
+ VpeTemplate template = elementMapping.getTemplate();
- if (toggleId == null) {
- return false;
- }
+ if (template instanceof VpeToggableTemplate) {
+ ((VpeToggableTemplate) template).stopToggling(sourceElement);
+ }
+ }
+ }
- boolean toggleLookup = false;
- nsIDOMAttr toggleLookupAttr = visualElement
- .getAttributeNode(VPE_USER_TOGGLE_LOOKUP_PARENT);
- if (toggleLookupAttr != null) {
- toggleLookup = "true".equals(toggleLookupAttr.getNodeValue());
- }
+ public boolean doToggle(nsIDOMNode visualNode) {
+ if (visualNode == null) {
+ return false;
+ }
+ nsIDOMElement visualElement = null;
+ try {
+ visualElement = (nsIDOMElement) visualNode
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ } catch (XPCOMException exception) {
+ visualElement = (nsIDOMElement) visualNode.getParentNode()
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ }
+ if (visualElement == null) {
+ return false;
+ }
- nsIDOMElement selectedElem = getLastSelectedElement();
- // Fixes JBIDE-1823 author dmaliarevich
- if (null == selectedElem) {
- return false;
- }
- VpeElementMapping elementMapping = null;
- VpeNodeMapping nodeMapping = domMapping.getNodeMapping(selectedElem);
- if (nodeMapping instanceof VpeElementMapping) {
- elementMapping = (VpeElementMapping) nodeMapping;
- }
- // end of fix
- if (elementMapping == null) {
- // may be toggle with facet
- while (!selectedElem.getNodeName().equals(HTML.TAG_TABLE)) {
- selectedElem = (nsIDOMElement) selectedElem.getParentNode()
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- }
- // Fixes JBIDE-1823 author dmaliarevich
- nodeMapping = domMapping.getNodeMapping(selectedElem);
- if (nodeMapping instanceof VpeElementMapping) {
- elementMapping = (VpeElementMapping) nodeMapping;
- }
- // end of fix
- }
- Node sourceNode = (Node) domMapping.getSourceNode(selectedElem);
- if (sourceNode == null) {
- return false;
- }
+ nsIDOMAttr toggleIdAttr = visualElement
+ .getAttributeNode(VPE_USER_TOGGLE_ID);
+ if (toggleIdAttr == null) {
+ return false;
+ }
+ String toggleId = toggleIdAttr.getNodeValue();
- Element sourceElement = (Element) (sourceNode instanceof Element ? sourceNode
- : sourceNode.getParentNode());
+ if (toggleId == null) {
+ return false;
+ }
- // Fixes JBIDE-1823 author dmaliarevich
- // Template is looked according to <code>selectedElem</code>
- // so <code>toggleLookupAttr</code> should be retrieved
- // from this element
- toggleLookupAttr = selectedElem
- .getAttributeNode(VPE_USER_TOGGLE_LOOKUP_PARENT);
- if (toggleLookupAttr != null) {
- toggleLookup = "true".equals(toggleLookupAttr.getNodeValue());
- }
- // end of fix
-
- if (elementMapping != null) {
- VpeTemplate template = elementMapping.getTemplate();
+ boolean toggleLookup = false;
+ nsIDOMAttr toggleLookupAttr = visualElement
+ .getAttributeNode(VPE_USER_TOGGLE_LOOKUP_PARENT);
+ if (toggleLookupAttr != null) {
+ toggleLookup = "true".equals(toggleLookupAttr.getNodeValue());
+ }
- while (toggleLookup && sourceElement != null
- && !(template instanceof VpeToggableTemplate)) {
- sourceElement = (Element) sourceElement.getParentNode();
- if (sourceElement == null) {
- break;
- }
- // Fixes JBIDE-1823 author dmaliarevich
- nodeMapping = domMapping.getNodeMapping(sourceElement);
- if (nodeMapping instanceof VpeElementMapping) {
- elementMapping = (VpeElementMapping) nodeMapping;
- }
- // end of fix
- if (elementMapping == null) {
- continue;
- }
- template = elementMapping.getTemplate();
- }
+ nsIDOMElement selectedElem = getLastSelectedElement();
+ // Fixes JBIDE-1823 author dmaliarevich
+ if (null == selectedElem) {
+ return false;
+ }
+ VpeElementMapping elementMapping = null;
+ VpeNodeMapping nodeMapping = domMapping.getNodeMapping(selectedElem);
+ if (nodeMapping instanceof VpeElementMapping) {
+ elementMapping = (VpeElementMapping) nodeMapping;
+ }
+ // end of fix
+ if (elementMapping == null) {
+ // may be toggle with facet
+ while (!selectedElem.getNodeName().equals(HTML.TAG_TABLE)) {
+ selectedElem = (nsIDOMElement) selectedElem.getParentNode()
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ }
+ // Fixes JBIDE-1823 author dmaliarevich
+ nodeMapping = domMapping.getNodeMapping(selectedElem);
+ if (nodeMapping instanceof VpeElementMapping) {
+ elementMapping = (VpeElementMapping) nodeMapping;
+ }
+ // end of fix
+ }
+ Node sourceNode = (Node) domMapping.getSourceNode(selectedElem);
+ if (sourceNode == null) {
+ return false;
+ }
- if (template instanceof VpeToggableTemplate) {
- ((VpeToggableTemplate) template).toggle(this, sourceElement,
- toggleId);
- updateElement(sourceElement);
- return true;
- }
- }
- return false;
- }
+ Element sourceElement = (Element) (sourceNode instanceof Element ? sourceNode
+ : sourceNode.getParentNode());
- public void removeAttribute(Element sourceElement, String name) {
- VpeElementMapping elementMapping = (VpeElementMapping) domMapping
- .getNodeMapping(sourceElement);
- if (elementMapping != null) {
- if (elementMapping.isIfDependencyFromAttribute(name)) {
- updateElement(sourceElement);
- } else {
- VpeTemplate template = elementMapping.getTemplate();
- if (template.isRecreateAtAttrChange(pageContext, sourceElement,
- visualDocument, (nsIDOMElement) elementMapping
- .getVisualNode(), elementMapping.getData(),
- name, null)) {
- updateElement(sourceElement);
- }
- // else {
- // removeXmlnsAttribute(elementMapping, name);
- // template.removeAttribute(pageContext, sourceElement,
- // visualDocument, (nsIDOMElement) elementMapping
- // .getVisualNode(), elementMapping.getData(),
- // name);
- // resetTooltip(sourceElement, (nsIDOMElement) elementMapping
- // .getVisualNode());
- // }
- }
- }
- }
+ // Fixes JBIDE-1823 author dmaliarevich
+ // Template is looked according to <code>selectedElem</code>
+ // so <code>toggleLookupAttr</code> should be retrieved
+ // from this element
+ toggleLookupAttr = selectedElem
+ .getAttributeNode(VPE_USER_TOGGLE_LOOKUP_PARENT);
+ if (toggleLookupAttr != null) {
+ toggleLookup = "true".equals(toggleLookupAttr.getNodeValue());
+ }
+ // end of fix
- public void refreshBundleValues(Element sourceElement) {
- VpeElementMapping elementMapping = (VpeElementMapping) domMapping
- .getNodeMapping(sourceElement);
- if (elementMapping != null) {
- VpeTemplate template = elementMapping.getTemplate();
- template.refreshBundleValues(pageContext, sourceElement,
- elementMapping.getData());
- }
- }
+ if (elementMapping != null) {
+ VpeTemplate template = elementMapping.getTemplate();
- boolean isContentArea(nsIDOMNode visualNode) {
- return getContentArea().equals(visualNode);
- }
+ while (toggleLookup && sourceElement != null
+ && !(template instanceof VpeToggableTemplate)) {
+ sourceElement = (Element) sourceElement.getParentNode();
+ if (sourceElement == null) {
+ break;
+ }
+ // Fixes JBIDE-1823 author dmaliarevich
+ nodeMapping = domMapping.getNodeMapping(sourceElement);
+ if (nodeMapping instanceof VpeElementMapping) {
+ elementMapping = (VpeElementMapping) nodeMapping;
+ }
+ // end of fix
+ if (elementMapping == null) {
+ continue;
+ }
+ template = elementMapping.getTemplate();
+ }
- nsIDOMElement getContentArea() {
- return visualEditor.getContentArea();
- }
+ if (template instanceof VpeToggableTemplate) {
+ ((VpeToggableTemplate) template).toggle(this, sourceElement,
+ toggleId);
+ updateElement(sourceElement);
+ return true;
+ }
+ }
+ return false;
+ }
- public void setSelectionRectangle(/*nsIDOMElement*/ nsIDOMNode visualElement) {
- setSelectionRectangle(visualElement, true);
- }
+ public void removeAttribute(Element sourceElement, String name) {
+ VpeElementMapping elementMapping = (VpeElementMapping) domMapping
+ .getNodeMapping(sourceElement);
+ if (elementMapping != null) {
+ if (elementMapping.isIfDependencyFromAttribute(name)) {
+ updateElement(sourceElement);
+ } else {
+ VpeTemplate template = elementMapping.getTemplate();
+ if (template.isRecreateAtAttrChange(pageContext, sourceElement,
+ visualDocument, (nsIDOMElement) elementMapping
+ .getVisualNode(), elementMapping.getData(),
+ name, null)) {
+ updateElement(sourceElement);
+ }
+ // else {
+ // removeXmlnsAttribute(elementMapping, name);
+ // template.removeAttribute(pageContext, sourceElement,
+ // visualDocument, (nsIDOMElement) elementMapping
+ // .getVisualNode(), elementMapping.getData(),
+ // name);
+ // resetTooltip(sourceElement, (nsIDOMElement) elementMapping
+ // .getVisualNode());
+ // }
+ }
+ }
+ }
- void setSelectionRectangle(/*nsIDOMElement*/ nsIDOMNode visualElement, boolean scroll) {
- int resizerConstrains = getResizerConstrains(visualElement);
- visualEditor.setSelectionRectangle(visualElement, resizerConstrains,
- scroll);
- }
+ public void refreshBundleValues(Element sourceElement) {
+ VpeElementMapping elementMapping = (VpeElementMapping) domMapping
+ .getNodeMapping(sourceElement);
+ if (elementMapping != null) {
+ VpeTemplate template = elementMapping.getTemplate();
+ template.refreshBundleValues(pageContext, sourceElement,
+ elementMapping.getData());
+ }
+ }
- public nsIDOMNode addLinkNodeToHead(String href_val, String ext_val) {
- nsIDOMElement newNode = createLinkNode(href_val,
- ATTR_REL_STYLESHEET_VALUE, ext_val);
+ boolean isContentArea(nsIDOMNode visualNode) {
+ return getContentArea().equals(visualNode);
+ }
- //TODO Dzmitry Sakovich
- // Fix priority CSS classes JBIDE-1713
- nsIDOMNode firstNode = getHeadNode().getFirstChild();
- getHeadNode().insertBefore(newNode, firstNode);
- return newNode;
- }
+ nsIDOMElement getContentArea() {
+ return visualEditor.getContentArea();
+ }
- public nsIDOMNode replaceLinkNodeToHead(nsIDOMNode oldNode,
- String href_val, String ext_val) {
- nsIDOMNode newNode = createLinkNode(href_val,
- ATTR_REL_STYLESHEET_VALUE, ext_val);
- getHeadNode().replaceChild(newNode, oldNode);
- return newNode;
- }
+ public void setSelectionRectangle(/* nsIDOMElement */nsIDOMNode visualElement) {
+ setSelectionRectangle(visualElement, true);
+ }
- public nsIDOMNode replaceLinkNodeToHead(String href_val, String ext_val) {
- nsIDOMNode newNode = null;
- nsIDOMNode oldNode = getLinkNode(href_val, ext_val);
- if (oldNode == null) {
- newNode = addLinkNodeToHead(href_val, ext_val);
- }
- return newNode;
- }
+ void setSelectionRectangle(/* nsIDOMElement */nsIDOMNode visualElement,
+ boolean scroll) {
+ int resizerConstrains = getResizerConstrains(visualElement);
+ visualEditor.setSelectionRectangle(visualElement, resizerConstrains,
+ scroll);
+ }
- public void removeLinkNodeFromHead(nsIDOMNode node) {
- getHeadNode().removeChild(node);
- }
+ public nsIDOMNode addLinkNodeToHead(String href_val, String ext_val) {
+ nsIDOMElement newNode = createLinkNode(href_val,
+ ATTR_REL_STYLESHEET_VALUE, ext_val);
- private nsIDOMElement createLinkNode(String href_val, String rel_val,
- String ext_val) {
- nsIDOMElement linkNode = null;
- if ((ATTR_REL_STYLESHEET_VALUE.equalsIgnoreCase(rel_val))
- && href_val.startsWith("file:")) {
- /*
- * Because of the Mozilla caches the linked css files we replace tag
- * <link rel="styleseet" href="file://..."> with tag <style
- * vpe="ATTR_VPE_INLINE_LINK_VALUE">file content</style> It is
- * LinkReplacer
- */
- linkNode = visualDocument.createElement(HTML.TAG_STYLE);
- linkNode.setAttribute(ATTR_VPE, ATTR_VPE_INLINE_LINK_VALUE);
+ // TODO Dzmitry Sakovich
+ // Fix priority CSS classes JBIDE-1713
+ nsIDOMNode firstNode = getHeadNode().getFirstChild();
+ getHeadNode().insertBefore(newNode, firstNode);
+ return newNode;
+ }
- /* Copy links attributes into our <style> */
- linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_HREF, href_val);
- linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_EXT, ext_val);
- try {
- StringBuffer styleText = new StringBuffer(EMPTY_STRING);
- URL url = new URL((new Path(href_val)).toOSString());
- String fileName = url.getFile();
- BufferedReader in = new BufferedReader(new FileReader(
- (fileName)));
- String str = EMPTY_STRING;
- while ((str = in.readLine()) != null) {
- styleText.append(str);
- }
+ public nsIDOMNode replaceLinkNodeToHead(nsIDOMNode oldNode,
+ String href_val, String ext_val) {
+ nsIDOMNode newNode = createLinkNode(href_val,
+ ATTR_REL_STYLESHEET_VALUE, ext_val);
+ getHeadNode().replaceChild(newNode, oldNode);
+ return newNode;
+ }
- String styleForParse = styleText.toString();
- styleForParse = VpeStyleUtil.addFullPathIntoURLValue(
- styleForParse, href_val);
+ public nsIDOMNode replaceLinkNodeToHead(String href_val, String ext_val) {
+ nsIDOMNode newNode = null;
+ nsIDOMNode oldNode = getLinkNode(href_val, ext_val);
+ if (oldNode == null) {
+ newNode = addLinkNodeToHead(href_val, ext_val);
+ }
+ return newNode;
+ }
- in.close();
- nsIDOMText textNode = visualDocument
- .createTextNode(styleForParse);
- linkNode.appendChild(textNode);
- return linkNode;
- } catch (FileNotFoundException fnfe) {
- /* File which was pointed by user is not exists. Do nothing. */
- } catch (IOException ioe) {
- VpePlugin.getPluginLog().logError(ioe.getMessage(), ioe);
- }
- }
+ public void removeLinkNodeFromHead(nsIDOMNode node) {
+ getHeadNode().removeChild(node);
+ }
- linkNode = visualDocument.createElement(HTML.TAG_LINK);
- linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_REL, rel_val);
- linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_HREF, href_val);
- linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_EXT, ext_val);
+ private nsIDOMElement createLinkNode(String href_val, String rel_val,
+ String ext_val) {
+ nsIDOMElement linkNode = null;
+ if ((ATTR_REL_STYLESHEET_VALUE.equalsIgnoreCase(rel_val))
+ && href_val.startsWith("file:")) {
+ /*
+ * Because of the Mozilla caches the linked css files we replace tag
+ * <link rel="styleseet" href="file://..."> with tag <style
+ * vpe="ATTR_VPE_INLINE_LINK_VALUE">file content</style> It is
+ * LinkReplacer
+ */
+ linkNode = visualDocument.createElement(HTML.TAG_STYLE);
+ linkNode.setAttribute(ATTR_VPE, ATTR_VPE_INLINE_LINK_VALUE);
- return linkNode;
- }
+ /* Copy links attributes into our <style> */
+ linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_HREF, href_val);
+ linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_EXT, ext_val);
+ BufferedReader in = null;
+ try {
+ StringBuffer styleText = new StringBuffer(EMPTY_STRING);
+ URL url = new URL((new Path(href_val)).toOSString());
+ String fileName = url.getFile();
+ in = new BufferedReader(new FileReader(
+ (fileName)));
+ String str = EMPTY_STRING;
+ while ((str = in.readLine()) != null) {
+ styleText.append(str);
+ }
- private boolean isLinkReplacer(nsIDOMNode node) {
- return HTML.TAG_STYLE.equalsIgnoreCase(node.getNodeName())
- && ATTR_VPE_INLINE_LINK_VALUE
- .equalsIgnoreCase(((nsIDOMElement) node
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
- .getAttribute(ATTR_VPE));
- }
+ String styleForParse = styleText.toString();
+ styleForParse = VpeStyleUtil.addFullPathIntoURLValue(
+ styleForParse, href_val);
- private nsIDOMNode getLinkNode(String href_val, String ext_val) {
- nsIDOMNodeList children = getHeadNode().getChildNodes();
- long len = children.getLength();
- for (long i = len - 1; i >= 0; i--) {
- nsIDOMNode node = children.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- if (HTML.TAG_LINK.equalsIgnoreCase(node.getNodeName())
- || isLinkReplacer(node)) {
- nsIDOMElement element = (nsIDOMElement) node
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- if (ext_val.equalsIgnoreCase(element
- .getAttribute(VpeTemplateManager.ATTR_LINK_EXT))
- && href_val
- .equalsIgnoreCase(element
- .getAttribute(VpeTemplateManager.ATTR_LINK_HREF))) {
- return node;
- }
- }
- }
- }
- return null;
- }
+ in.close();
+ nsIDOMText textNode = visualDocument
+ .createTextNode(styleForParse);
+ linkNode.appendChild(textNode);
+ return linkNode;
+ } catch (FileNotFoundException fnfe) {
+ /* File which was pointed by user is not exists. Do nothing. */
+ } catch (IOException ioe) {
+ VpePlugin.getPluginLog().logError(ioe.getMessage(), ioe);
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ VpePlugin.getPluginLog().logError(e);
+ }
+ }
+ }
+ }
- private void cleanHead() {
- nsIDOMNodeList children = getHeadNode().getChildNodes();
- long len = children.getLength();
- for (long i = len - 1; i >= 0; i--) {
- nsIDOMNode node = children.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- if (isLinkReplacer(node)) {
- /*Added by Max Areshkau(Fix for JBIDE-1941)
- * Ext. attribute used for adding external styles
- * to editor. If was added external attribute, this
- * property is true.
- */
- if (!YES_STRING.equalsIgnoreCase(((nsIDOMElement) node
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
- .getAttribute(VpeTemplateManager.ATTR_LINK_EXT))) {
- // int linkAddress =
- // MozillaSupports.queryInterface(node,
- // nsIStyleSheetLinkingElement.NS_ISTYLESHEETLINKINGELEMENT_IID);
- // nsIStyleSheetLinkingElement linkingElement = new
- // nsIStyleSheetLinkingElement(linkAddress);
- // linkingElement.removeStyleSheet();
- node = getHeadNode().removeChild(node);
- }
- } else if (HTML.TAG_STYLE.equalsIgnoreCase(node.getNodeName())
- && (!YES_STRING
- .equalsIgnoreCase(((nsIDOMElement) node
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
- .getAttribute(ATTR_VPE)))) {
- node = getHeadNode().removeChild(node);
- }
- }
- }
- }
+ linkNode = visualDocument.createElement(HTML.TAG_LINK);
+ linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_REL, rel_val);
+ linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_HREF, href_val);
+ linkNode.setAttribute(VpeTemplateManager.ATTR_LINK_EXT, ext_val);
- private class PseudoInfo {
- private nsIDOMNode pseudoNode;
- private boolean isElements;
+ return linkNode;
+ }
- private PseudoInfo() {
- this(null, false);
- }
+ private boolean isLinkReplacer(nsIDOMNode node) {
+ return HTML.TAG_STYLE.equalsIgnoreCase(node.getNodeName())
+ && ATTR_VPE_INLINE_LINK_VALUE
+ .equalsIgnoreCase(((nsIDOMElement) node
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
+ .getAttribute(ATTR_VPE));
+ }
- private PseudoInfo(nsIDOMNode pseudoNode, boolean isElements) {
- this.pseudoNode = pseudoNode;
- this.isElements = isElements;
- }
- }
+ private nsIDOMNode getLinkNode(String href_val, String ext_val) {
+ nsIDOMNodeList children = getHeadNode().getChildNodes();
+ long len = children.getLength();
+ for (long i = len - 1; i >= 0; i--) {
+ nsIDOMNode node = children.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ if (HTML.TAG_LINK.equalsIgnoreCase(node.getNodeName())
+ || isLinkReplacer(node)) {
+ nsIDOMElement element = (nsIDOMElement) node
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ if (ext_val.equalsIgnoreCase(element
+ .getAttribute(VpeTemplateManager.ATTR_LINK_EXT))
+ && href_val
+ .equalsIgnoreCase(element
+ .getAttribute(VpeTemplateManager.ATTR_LINK_HREF))) {
+ return node;
+ }
+ }
+ }
+ }
+ return null;
+ }
- void showDragCaret(nsIDOMNode node, int offset) {
- xulRunnerEditor.showDragCaret(node, offset);
- }
+ private void cleanHead() {
+ nsIDOMNodeList children = getHeadNode().getChildNodes();
+ long len = children.getLength();
+ for (long i = len - 1; i >= 0; i--) {
+ nsIDOMNode node = children.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ if (isLinkReplacer(node)) {
+ /*
+ * Added by Max Areshkau(Fix for JBIDE-1941) Ext. attribute
+ * used for adding external styles to editor. If was added
+ * external attribute, this property is true.
+ */
+ if (!YES_STRING.equalsIgnoreCase(((nsIDOMElement) node
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
+ .getAttribute(VpeTemplateManager.ATTR_LINK_EXT))) {
+ // int linkAddress =
+ // MozillaSupports.queryInterface(node,
+ // nsIStyleSheetLinkingElement.
+ // NS_ISTYLESHEETLINKINGELEMENT_IID);
+ // nsIStyleSheetLinkingElement linkingElement = new
+ // nsIStyleSheetLinkingElement(linkAddress);
+ // linkingElement.removeStyleSheet();
+ node = getHeadNode().removeChild(node);
+ }
+ } else if (HTML.TAG_STYLE.equalsIgnoreCase(node.getNodeName())
+ && (!YES_STRING
+ .equalsIgnoreCase(((nsIDOMElement) node
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
+ .getAttribute(ATTR_VPE)))) {
+ node = getHeadNode().removeChild(node);
+ }
+ }
+ }
+ }
- void hideDragCaret() {
+ private class PseudoInfo {
+ private nsIDOMNode pseudoNode;
+ private boolean isElements;
- xulRunnerEditor.hideDragCaret();
- }
+ private PseudoInfo() {
+ this(null, false);
+ }
- private int getResizerConstrains(nsIDOMNode visualNode) {
- VpeNodeMapping nodeMapping = domMapping.getNodeMapping(visualNode);
- if (nodeMapping != null
- &&( nodeMapping instanceof VpeElementMapping)
- &&( nodeMapping.getSourceNode() instanceof Element)
- &&(nodeMapping.getVisualNode().getNodeType()==nsIDOMNode.ELEMENT_NODE)) {
- return ((VpeElementMapping) nodeMapping).getTemplate()
- .getTagDescription(pageContext,
- (Element) nodeMapping.getSourceNode(),
- visualDocument,
- (nsIDOMElement) nodeMapping.getVisualNode().queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID),
- ((VpeElementMapping) nodeMapping).getData())
- .getResizeConstrains();
- }
- return VpeTagDescription.RESIZE_CONSTRAINS_NONE;
- }
+ private PseudoInfo(nsIDOMNode pseudoNode, boolean isElements) {
+ this.pseudoNode = pseudoNode;
+ this.isElements = isElements;
+ }
+ }
- public void resize(nsIDOMElement element, int resizerConstrains, int top,
- int left, int width, int height) {
- VpeElementMapping elementMapping = (VpeElementMapping) domMapping
- .getNodeMapping(element);
- if (elementMapping != null) {
- elementMapping.getTemplate().resize(pageContext,
- (Element) elementMapping.getSourceNode(), visualDocument,
- element, elementMapping.getData(), resizerConstrains, top,
- left, width, height);
- }
- }
+ void showDragCaret(nsIDOMNode node, int offset) {
+ xulRunnerEditor.showDragCaret(node, offset);
+ }
- static boolean isAnonElement(nsIDOMNode visualNode) {
- if (visualNode != null
- && visualNode.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
- String attrValue = ((nsIDOMElement) visualNode
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
- .getAttribute(MOZ_ANONCLASS_ATTR);
+ void hideDragCaret() {
- return attrValue != null && attrValue.length() > 0;
- }
+ xulRunnerEditor.hideDragCaret();
+ }
- return false;
- }
+ private int getResizerConstrains(nsIDOMNode visualNode) {
+ VpeNodeMapping nodeMapping = domMapping.getNodeMapping(visualNode);
+ if (nodeMapping != null
+ && (nodeMapping instanceof VpeElementMapping)
+ && (nodeMapping.getSourceNode() instanceof Element)
+ && (nodeMapping.getVisualNode().getNodeType() == nsIDOMNode.ELEMENT_NODE)) {
+ return ((VpeElementMapping) nodeMapping).getTemplate()
+ .getTagDescription(
+ pageContext,
+ (Element) nodeMapping.getSourceNode(),
+ visualDocument,
+ (nsIDOMElement) nodeMapping.getVisualNode()
+ .queryInterface(
+ nsIDOMElement.NS_IDOMELEMENT_IID),
+ ((VpeElementMapping) nodeMapping).getData())
+ .getResizeConstrains();
+ }
+ return VpeTagDescription.RESIZE_CONSTRAINS_NONE;
+ }
- boolean canInnerDrag(nsIDOMElement visualDragElement) {
- VpeNodeMapping node = domMapping.getNodeMapping(visualDragElement);
- if (node instanceof VpeElementMapping) {
- VpeElementMapping elementMapping = (VpeElementMapping) node;
- if (elementMapping != null && elementMapping.getSourceNode() instanceof Element) {
- return elementMapping.getTemplate().canInnerDrag(pageContext,
- (Element)elementMapping.getSourceNode(),
- visualDocument, visualDragElement,
- elementMapping.getData());
- }
- }
- return false;
- }
+ public void resize(nsIDOMElement element, int resizerConstrains, int top,
+ int left, int width, int height) {
+ VpeElementMapping elementMapping = (VpeElementMapping) domMapping
+ .getNodeMapping(element);
+ if (elementMapping != null) {
+ elementMapping.getTemplate().resize(pageContext,
+ (Element) elementMapping.getSourceNode(), visualDocument,
+ element, elementMapping.getData(), resizerConstrains, top,
+ left, width, height);
+ }
+ }
- VpeSourceInnerDropInfo getSourceInnerDropInfo(Node sourceDragNode,
- VpeVisualInnerDropInfo visualDropInfo, boolean checkParentTemplates) {
- nsIDOMNode visualDropContainer = visualDropInfo.getDropContainer();
- long visualDropOffset = visualDropInfo.getDropOffset();
- Node sourceDropContainer = null;
- int sourceDropOffset = 0;
+ static boolean isAnonElement(nsIDOMNode visualNode) {
+ if (visualNode != null
+ && visualNode.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
+ String attrValue = ((nsIDOMElement) visualNode
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
+ .getAttribute(MOZ_ANONCLASS_ATTR);
- switch (visualDropContainer.getNodeType()) {
- case nsIDOMNode.ELEMENT_NODE:
- nsIDOMNode visualOffsetNode = null;
- boolean afterFlag = false;
- long visualChildCount = VisualDomUtil
- .getChildCount(visualDropContainer);
- if (visualDropOffset < visualChildCount) {
- visualOffsetNode = VisualDomUtil.getChildNode(
- visualDropContainer, visualDropOffset);
- if (isPseudoElement(visualOffsetNode)
- || isAnonElement(visualOffsetNode)) {
- visualOffsetNode = getLastAppreciableVisualChild(visualDropContainer);
- afterFlag = true;
- }
- } else {
- visualOffsetNode = getLastAppreciableVisualChild(visualDropContainer);
- afterFlag = visualChildCount != 0;
- }
- if (visualOffsetNode != null) {
- Node sourceOffsetNode = domMapping
- .getSourceNode(visualOffsetNode);
- if (sourceOffsetNode != null) {
- sourceDropContainer = sourceOffsetNode.getParentNode();
- sourceDropOffset = ((NodeImpl) sourceOffsetNode).getIndex();
- if (afterFlag) {
- sourceDropOffset++;
- }
- }
- }
- if (sourceDropContainer == null) {
- sourceDropContainer = domMapping
- .getNearSourceNode(visualDropContainer);
- if (sourceDropContainer != null) {
- sourceDropOffset = sourceDropContainer.getChildNodes()
- .getLength();
- }
- }
- if (sourceDropContainer == null) {
- sourceDropContainer = domMapping
- .getNearSourceNode(getContentArea());
- sourceDropOffset = sourceDropContainer.getChildNodes()
- .getLength();
- }
- break;
- case nsIDOMNode.TEXT_NODE:
- VpeNodeMapping nodeMapping = domMapping
- .getNearNodeMapping(visualDropContainer);
-// switch (nodeMapping.getType()) {
-// case VpeNodeMapping.TEXT_MAPPING:
- sourceDropContainer = nodeMapping.getSourceNode();
- sourceDropOffset = TextUtil.sourceInnerPosition(
- sourceDropContainer.getNodeValue(), visualDropOffset);
-// break;
-// case VpeNodeMapping.ELEMENT_MAPPING:
- // it's attribute
- if (isTextEditable(visualDropContainer)) {
- String[] atributeNames = ((VpeElementMapping) nodeMapping)
- .getTemplate().getOutputAtributeNames();
- if (atributeNames != null && atributeNames.length > 0) {
- Element sourceElement = (Element) nodeMapping
- .getSourceNode();
- sourceDropContainer = sourceElement
- .getAttributeNode(atributeNames[0]);
- sourceDropOffset = TextUtil.sourceInnerPosition(
- sourceDropContainer.getNodeValue(),
- visualDropOffset);
- }
- }
- nodeMapping.getVisualNode();
-// }
-// break;
- }
- if (sourceDropContainer != null) {
- return getSourceInnerDropInfo(sourceDragNode, sourceDropContainer,
- sourceDropOffset, checkParentTemplates);
- } else {
- return new VpeSourceInnerDropInfo(null, 0, false);
- }
- }
+ return attrValue != null && attrValue.length() > 0;
+ }
- VpeSourceInnerDropInfo getSourceInnerDropInfo(Node dragNode,
- Node container, int offset, boolean checkParentsTemplates) {
- // Thread.dumpStack();
- boolean canDrop = false;
- switch (container.getNodeType()) {
- case Node.ELEMENT_NODE:
- VpeNodeMapping nodeMapping = domMapping.getNodeMapping(container);
- if (nodeMapping != null
- && nodeMapping instanceof VpeElementMapping) {
- canDrop = ((VpeElementMapping) nodeMapping).getTemplate()
- .canInnerDrop(pageContext, container, dragNode);
- }
- if (!canDrop) {
- if (!checkParentsTemplates)
- return new VpeSourceInnerDropInfo(container, offset,
- canDrop);
- // offset = ((NodeImpl)container).getIndex();
- // container = container.getParentNode();
- // TODO Max Areshkau unclear logic , if we can drop on element
- // why we trying to drop
- // this on parent
- // return getSourceInnerDropInfo(dragNode, container, offset,
- // false);
- return new VpeSourceInnerDropInfo(container, offset, canDrop);
- }
- break;
- case Node.TEXT_NODE:
- case Node.DOCUMENT_NODE:
- canDrop = true;
- break;
- case Node.ATTRIBUTE_NODE:
- canDrop = true;
- break;
- }
- if (canDrop) {
- return new VpeSourceInnerDropInfo(container, offset, canDrop);
- } else {
- return new VpeSourceInnerDropInfo(null, 0, canDrop);
- }
- }
+ return false;
+ }
- public void innerDrop(Node dragNode, Node container, int offset) {
- VpeNodeMapping mapping = domMapping.getNearNodeMapping(container);
- if (mapping != null) {
- nsIDOMNode visualDropContainer = mapping.getVisualNode();
-// switch (mapping.getType()) {
-// case VpeNodeMapping.TEXT_MAPPING:
-// break;
-// case VpeNodeMapping.ELEMENT_MAPPING:
- nsIDOMNode visualParent = visualDropContainer.getParentNode();
- VpeNodeMapping oldMapping = mapping;
- mapping = domMapping.getNearNodeMapping(visualParent);
- if (mapping != null
- && mapping instanceof VpeElementMapping) {
- ((VpeElementMapping) mapping).getTemplate()
- .innerDrop(
- pageContext,
- new VpeSourceInnerDragInfo(dragNode, 0, 0),
- new VpeSourceInnerDropInfo(container,
- offset, true));
- } else {
- ((VpeElementMapping) oldMapping).getTemplate()
- .innerDrop(
- pageContext,
- new VpeSourceInnerDragInfo(dragNode, 0, 0),
- new VpeSourceInnerDropInfo(container,
- offset, true));
- }
-// }
+ boolean canInnerDrag(nsIDOMElement visualDragElement) {
+ VpeNodeMapping node = domMapping.getNodeMapping(visualDragElement);
+ if (node instanceof VpeElementMapping) {
+ VpeElementMapping elementMapping = (VpeElementMapping) node;
+ if (elementMapping != null
+ && elementMapping.getSourceNode() instanceof Element) {
+ return elementMapping.getTemplate().canInnerDrag(pageContext,
+ (Element) elementMapping.getSourceNode(),
+ visualDocument, visualDragElement,
+ elementMapping.getData());
+ }
+ }
+ return false;
+ }
- }
- }
+ VpeSourceInnerDropInfo getSourceInnerDropInfo(Node sourceDragNode,
+ VpeVisualInnerDropInfo visualDropInfo, boolean checkParentTemplates) {
+ nsIDOMNode visualDropContainer = visualDropInfo.getDropContainer();
+ long visualDropOffset = visualDropInfo.getDropOffset();
+ Node sourceDropContainer = null;
+ int sourceDropOffset = 0;
- void innerDrop(VpeSourceInnerDragInfo dragInfo,
- VpeSourceInnerDropInfo dropInfo) {
- dropper.drop(pageContext, dragInfo, dropInfo);
- }
+ switch (visualDropContainer.getNodeType()) {
+ case nsIDOMNode.ELEMENT_NODE:
+ nsIDOMNode visualOffsetNode = null;
+ boolean afterFlag = false;
+ long visualChildCount = VisualDomUtil
+ .getChildCount(visualDropContainer);
+ if (visualDropOffset < visualChildCount) {
+ visualOffsetNode = VisualDomUtil.getChildNode(
+ visualDropContainer, visualDropOffset);
+ if (isPseudoElement(visualOffsetNode)
+ || isAnonElement(visualOffsetNode)) {
+ visualOffsetNode = getLastAppreciableVisualChild(visualDropContainer);
+ afterFlag = true;
+ }
+ } else {
+ visualOffsetNode = getLastAppreciableVisualChild(visualDropContainer);
+ afterFlag = visualChildCount != 0;
+ }
+ if (visualOffsetNode != null) {
+ Node sourceOffsetNode = domMapping
+ .getSourceNode(visualOffsetNode);
+ if (sourceOffsetNode != null) {
+ sourceDropContainer = sourceOffsetNode.getParentNode();
+ sourceDropOffset = ((NodeImpl) sourceOffsetNode).getIndex();
+ if (afterFlag) {
+ sourceDropOffset++;
+ }
+ }
+ }
+ if (sourceDropContainer == null) {
+ sourceDropContainer = domMapping
+ .getNearSourceNode(visualDropContainer);
+ if (sourceDropContainer != null) {
+ sourceDropOffset = sourceDropContainer.getChildNodes()
+ .getLength();
+ }
+ }
+ if (sourceDropContainer == null) {
+ sourceDropContainer = domMapping
+ .getNearSourceNode(getContentArea());
+ sourceDropOffset = sourceDropContainer.getChildNodes()
+ .getLength();
+ }
+ break;
+ case nsIDOMNode.TEXT_NODE:
+ VpeNodeMapping nodeMapping = domMapping
+ .getNearNodeMapping(visualDropContainer);
+ // switch (nodeMapping.getType()) {
+ // case VpeNodeMapping.TEXT_MAPPING:
+ sourceDropContainer = nodeMapping.getSourceNode();
+ sourceDropOffset = TextUtil.sourceInnerPosition(sourceDropContainer
+ .getNodeValue(), visualDropOffset);
+ // break;
+ // case VpeNodeMapping.ELEMENT_MAPPING:
+ // it's attribute
+ if (isTextEditable(visualDropContainer)) {
+ String[] atributeNames = ((VpeElementMapping) nodeMapping)
+ .getTemplate().getOutputAtributeNames();
+ if (atributeNames != null && atributeNames.length > 0) {
+ Element sourceElement = (Element) nodeMapping
+ .getSourceNode();
+ sourceDropContainer = sourceElement
+ .getAttributeNode(atributeNames[0]);
+ sourceDropOffset = TextUtil.sourceInnerPosition(
+ sourceDropContainer.getNodeValue(),
+ visualDropOffset);
+ }
+ }
+ nodeMapping.getVisualNode();
+ // }
+ // break;
+ }
+ if (sourceDropContainer != null) {
+ return getSourceInnerDropInfo(sourceDragNode, sourceDropContainer,
+ sourceDropOffset, checkParentTemplates);
+ } else {
+ return new VpeSourceInnerDropInfo(null, 0, false);
+ }
+ }
- nsIDOMElement getNearDragElement(Element visualElement) {
- VpeElementMapping elementMapping = domMapping
- .getNearElementMapping(visualElement);
- while (elementMapping != null) {
- if (canInnerDrag(elementMapping.getVisualElement())) {
- return elementMapping.getVisualElement();
- }
- elementMapping = domMapping.getNearElementMapping(elementMapping
- .getVisualNode().getParentNode());
- }
- return null;
- }
+ VpeSourceInnerDropInfo getSourceInnerDropInfo(Node dragNode,
+ Node container, int offset, boolean checkParentsTemplates) {
+ // Thread.dumpStack();
+ boolean canDrop = false;
+ switch (container.getNodeType()) {
+ case Node.ELEMENT_NODE:
+ VpeNodeMapping nodeMapping = domMapping.getNodeMapping(container);
+ if (nodeMapping != null && nodeMapping instanceof VpeElementMapping) {
+ canDrop = ((VpeElementMapping) nodeMapping).getTemplate()
+ .canInnerDrop(pageContext, container, dragNode);
+ }
+ if (!canDrop) {
+ if (!checkParentsTemplates)
+ return new VpeSourceInnerDropInfo(container, offset,
+ canDrop);
+ // offset = ((NodeImpl)container).getIndex();
+ // container = container.getParentNode();
+ // TODO Max Areshkau unclear logic , if we can drop on element
+ // why we trying to drop
+ // this on parent
+ // return getSourceInnerDropInfo(dragNode, container, offset,
+ // false);
+ return new VpeSourceInnerDropInfo(container, offset, canDrop);
+ }
+ break;
+ case Node.TEXT_NODE:
+ case Node.DOCUMENT_NODE:
+ canDrop = true;
+ break;
+ case Node.ATTRIBUTE_NODE:
+ canDrop = true;
+ break;
+ }
+ if (canDrop) {
+ return new VpeSourceInnerDropInfo(container, offset, canDrop);
+ } else {
+ return new VpeSourceInnerDropInfo(null, 0, canDrop);
+ }
+ }
- nsIDOMElement getDragElement(nsIDOMElement visualElement) {
- VpeElementMapping elementMapping = domMapping
- .getNearElementMapping(visualElement);
- if (elementMapping != null
- && canInnerDrag(elementMapping.getVisualElement())) {
- return elementMapping.getVisualElement();
- }
- return null;
- }
+ public void innerDrop(Node dragNode, Node container, int offset) {
+ VpeNodeMapping mapping = domMapping.getNearNodeMapping(container);
+ if (mapping != null) {
+ nsIDOMNode visualDropContainer = mapping.getVisualNode();
+ // switch (mapping.getType()) {
+ // case VpeNodeMapping.TEXT_MAPPING:
+ // break;
+ // case VpeNodeMapping.ELEMENT_MAPPING:
+ nsIDOMNode visualParent = visualDropContainer.getParentNode();
+ VpeNodeMapping oldMapping = mapping;
+ mapping = domMapping.getNearNodeMapping(visualParent);
+ if (mapping != null && mapping instanceof VpeElementMapping) {
+ ((VpeElementMapping) mapping).getTemplate().innerDrop(
+ pageContext,
+ new VpeSourceInnerDragInfo(dragNode, 0, 0),
+ new VpeSourceInnerDropInfo(container, offset, true));
+ } else {
+ ((VpeElementMapping) oldMapping).getTemplate().innerDrop(
+ pageContext,
+ new VpeSourceInnerDragInfo(dragNode, 0, 0),
+ new VpeSourceInnerDropInfo(container, offset, true));
+ }
+ // }
- public boolean isTextEditable(nsIDOMNode visualNode) {
+ }
+ }
- if (visualNode != null) {
- nsIDOMNode parent = visualNode.getParentNode();
- if (parent != null
- && parent.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
- nsIDOMElement element = (nsIDOMElement) parent
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- nsIDOMAttr style = element.getAttributeNode("style");
- if (style != null) {
- String styleValue = style.getNodeValue();
- String[] items = styleValue.split(";");
- for (int i = 0; i < items.length; i++) {
- String[] item = items[i].split(":");
- if ("-moz-user-modify".equals(item[0].trim())
- && "read-only".equals(item[1].trim())) {
- return false;
- }
- }
- }
- nsIDOMAttr classAttr = element.getAttributeNode("class");
- if (classAttr != null) {
- String classValue = classAttr.getNodeValue().trim();
- if ("__any__tag__caption".equals(classValue)) {
- return false;
- }
- }
- }
- }
- return true;
- }
+ void innerDrop(VpeSourceInnerDragInfo dragInfo,
+ VpeSourceInnerDropInfo dropInfo) {
+ dropper.drop(pageContext, dragInfo, dropInfo);
+ }
- VpeVisualInnerDropInfo getInnerDropInfo(Node sourceDropContainer,
- int sourceDropOffset) {
- nsIDOMNode visualDropContainer = null;
- long visualDropOffset = 0;
+ nsIDOMElement getNearDragElement(Element visualElement) {
+ VpeElementMapping elementMapping = domMapping
+ .getNearElementMapping(visualElement);
+ while (elementMapping != null) {
+ if (canInnerDrag(elementMapping.getVisualElement())) {
+ return elementMapping.getVisualElement();
+ }
+ elementMapping = domMapping.getNearElementMapping(elementMapping
+ .getVisualNode().getParentNode());
+ }
+ return null;
+ }
- switch (sourceDropContainer.getNodeType()) {
- case Node.TEXT_NODE:
- visualDropContainer = domMapping.getVisualNode(sourceDropContainer);
- visualDropOffset = TextUtil.visualInnerPosition(sourceDropContainer
- .getNodeValue(), sourceDropOffset);
- break;
- case Node.ELEMENT_NODE:
- case Node.DOCUMENT_NODE:
- NodeList sourceChildren = sourceDropContainer.getChildNodes();
- if (sourceDropOffset < sourceChildren.getLength()) {
- Node sourceChild = sourceChildren.item(sourceDropOffset);
- nsIDOMNode visualChild = domMapping.getVisualNode(sourceChild);
- if (visualChild != null) {
- visualDropContainer = visualChild.getParentNode();
+ nsIDOMElement getDragElement(nsIDOMElement visualElement) {
+ VpeElementMapping elementMapping = domMapping
+ .getNearElementMapping(visualElement);
+ if (elementMapping != null
+ && canInnerDrag(elementMapping.getVisualElement())) {
+ return elementMapping.getVisualElement();
+ }
+ return null;
+ }
- visualDropOffset = VisualDomUtil.getOffset(visualChild);
- }
- }
- if (visualDropContainer == null) {
- visualDropContainer = domMapping
- .getNearVisualNode(sourceDropContainer);
- nsIDOMNode visualChild = getLastAppreciableVisualChild(visualDropContainer);
- if (visualChild != null) {
- visualDropOffset = VisualDomUtil.getOffset(visualChild) + 1;
- } else {
- visualDropOffset = 0;
- }
- }
- break;
- case Node.ATTRIBUTE_NODE:
- Element sourceElement = ((Attr) sourceDropContainer)
- .getOwnerElement();
- VpeElementMapping elementMapping = domMapping
- .getNearElementMapping(sourceElement);
- nsIDOMNode textNode = elementMapping.getTemplate()
- .getOutputTextNode(pageContext, sourceElement,
- elementMapping.getData());
- if (textNode != null) {
- visualDropContainer = textNode;
- visualDropOffset = TextUtil.visualInnerPosition(
- sourceDropContainer.getNodeValue(), sourceDropOffset);
- }
- break;
- }
- if (visualDropContainer == null) {
- return null;
- }
- return new VpeVisualInnerDropInfo(visualDropContainer,
- visualDropOffset, 0, 0);
- }
+ public boolean isTextEditable(nsIDOMNode visualNode) {
- protected void setTooltip(Element sourceElement, nsIDOMElement visualElement) {
- if (visualElement != null && sourceElement != null
- && !((IDOMElement) sourceElement).isJSPTag()) {
- if (HTML.TAG_HTML.equalsIgnoreCase(sourceElement.getNodeName()))
- return;
- String titleValue = getTooltip(sourceElement);
+ if (visualNode != null) {
+ nsIDOMNode parent = visualNode.getParentNode();
+ if (parent != null
+ && parent.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
+ nsIDOMElement element = (nsIDOMElement) parent
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ nsIDOMAttr style = element.getAttributeNode("style");
+ if (style != null) {
+ String styleValue = style.getNodeValue();
+ String[] items = styleValue.split(";");
+ for (int i = 0; i < items.length; i++) {
+ String[] item = items[i].split(":");
+ if ("-moz-user-modify".equals(item[0].trim())
+ && "read-only".equals(item[1].trim())) {
+ return false;
+ }
+ }
+ }
+ nsIDOMAttr classAttr = element.getAttributeNode("class");
+ if (classAttr != null) {
+ String classValue = classAttr.getNodeValue().trim();
+ if ("__any__tag__caption".equals(classValue)) {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ }
- if (titleValue != null) {
- titleValue = titleValue.replaceAll("&", "&");
- titleValue = titleValue.replaceAll("<", "<");
- titleValue = titleValue.replaceAll(">", ">");
- }
+ VpeVisualInnerDropInfo getInnerDropInfo(Node sourceDropContainer,
+ int sourceDropOffset) {
+ nsIDOMNode visualDropContainer = null;
+ long visualDropOffset = 0;
- if (titleValue != null) {
- // visualElement.setAttribute("title", titleValue);
- setTooltip(visualElement, titleValue);
- }
- }
- }
+ switch (sourceDropContainer.getNodeType()) {
+ case Node.TEXT_NODE:
+ visualDropContainer = domMapping.getVisualNode(sourceDropContainer);
+ visualDropOffset = TextUtil.visualInnerPosition(sourceDropContainer
+ .getNodeValue(), sourceDropOffset);
+ break;
+ case Node.ELEMENT_NODE:
+ case Node.DOCUMENT_NODE:
+ NodeList sourceChildren = sourceDropContainer.getChildNodes();
+ if (sourceDropOffset < sourceChildren.getLength()) {
+ Node sourceChild = sourceChildren.item(sourceDropOffset);
+ nsIDOMNode visualChild = domMapping.getVisualNode(sourceChild);
+ if (visualChild != null) {
+ visualDropContainer = visualChild.getParentNode();
- protected void setTooltip(nsIDOMElement visualElement, String titleValue) {
- visualElement.setAttribute(HTML.ATTR_TITLE, titleValue);
- nsIDOMNodeList children = visualElement.getChildNodes();
- long len = children.getLength();
- for (long i = 0; i < len; i++) {
- nsIDOMNode child = children.item(i);
- if (child.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
- setTooltip(((nsIDOMElement) child
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID)),
- titleValue);
- }
- }
- }
+ visualDropOffset = VisualDomUtil.getOffset(visualChild);
+ }
+ }
+ if (visualDropContainer == null) {
+ visualDropContainer = domMapping
+ .getNearVisualNode(sourceDropContainer);
+ nsIDOMNode visualChild = getLastAppreciableVisualChild(visualDropContainer);
+ if (visualChild != null) {
+ visualDropOffset = VisualDomUtil.getOffset(visualChild) + 1;
+ } else {
+ visualDropOffset = 0;
+ }
+ }
+ break;
+ case Node.ATTRIBUTE_NODE:
+ Element sourceElement = ((Attr) sourceDropContainer)
+ .getOwnerElement();
+ VpeElementMapping elementMapping = domMapping
+ .getNearElementMapping(sourceElement);
+ nsIDOMNode textNode = elementMapping.getTemplate()
+ .getOutputTextNode(pageContext, sourceElement,
+ elementMapping.getData());
+ if (textNode != null) {
+ visualDropContainer = textNode;
+ visualDropOffset = TextUtil.visualInnerPosition(
+ sourceDropContainer.getNodeValue(), sourceDropOffset);
+ }
+ break;
+ }
+ if (visualDropContainer == null) {
+ return null;
+ }
+ return new VpeVisualInnerDropInfo(visualDropContainer,
+ visualDropOffset, 0, 0);
+ }
- private void resetTooltip(Element sourceElement, nsIDOMElement visualElement) {
- if (visualElement != null && sourceElement != null
- && !((ElementImpl) sourceElement).isJSPTag()) {
- if (HTML.TAG_HTML.equalsIgnoreCase(sourceElement.getNodeName()))
- return;
- String titleValue = getTooltip(sourceElement);
+ protected void setTooltip(Element sourceElement, nsIDOMElement visualElement) {
+ if (visualElement != null && sourceElement != null
+ && !((IDOMElement) sourceElement).isJSPTag()) {
+ if (HTML.TAG_HTML.equalsIgnoreCase(sourceElement.getNodeName()))
+ return;
+ String titleValue = getTooltip(sourceElement);
- if (titleValue != null) {
- titleValue = titleValue.replaceAll("&", "&"); //$NON-NLS-1$//$NON-NLS-2$
- titleValue = titleValue.replaceAll("<", "<"); //$NON-NLS-1$//$NON-NLS-2$
- titleValue = titleValue.replaceAll(">", ">"); //$NON-NLS-1$//$NON-NLS-2$
- }
+ if (titleValue != null) {
+ titleValue = titleValue.replaceAll("&", "&");
+ titleValue = titleValue.replaceAll("<", "<");
+ titleValue = titleValue.replaceAll(">", ">");
+ }
- if (titleValue != null) {
- resetTooltip(visualElement, titleValue);
- }
- }
- }
+ if (titleValue != null) {
+ // visualElement.setAttribute("title", titleValue);
+ setTooltip(visualElement, titleValue);
+ }
+ }
+ }
- private void resetTooltip(nsIDOMElement visualElement, String titleValue) {
- visualElement.setAttribute(HTML.ATTR_TITLE, titleValue);
- nsIDOMNodeList children = visualElement.getChildNodes();
- long len = children.getLength();
- for (long i = 0; i < len; i++) {
- nsIDOMNode child = children.item(i);
- if (child.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
- if (domMapping.getNodeMapping(child) == null) {
- resetTooltip((nsIDOMElement) child
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID),
- titleValue);
- }
- }
- }
- }
+ protected void setTooltip(nsIDOMElement visualElement, String titleValue) {
+ visualElement.setAttribute(HTML.ATTR_TITLE, titleValue);
+ nsIDOMNodeList children = visualElement.getChildNodes();
+ long len = children.getLength();
+ for (long i = 0; i < len; i++) {
+ nsIDOMNode child = children.item(i);
+ if (child.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
+ setTooltip(((nsIDOMElement) child
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID)),
+ titleValue);
+ }
+ }
+ }
- private String getTooltip(Element sourceElement) {
- StringBuffer buffer = new StringBuffer();
- buffer.append(sourceElement.getNodeName());
- NamedNodeMap attrs = sourceElement.getAttributes();
- int len = attrs.getLength();
- for (int i = 0; i < len; i++) {
- if (i == 7) {
- return buffer.append("\n\t... ").toString(); //$NON-NLS-1$
- }
- int valueLength = attrs.item(i).getNodeValue().length();
- if (valueLength > 30) {
- StringBuffer temp = new StringBuffer();
- temp.append(attrs.item(i).getNodeValue().substring(0, 15)
- + " ... " //$NON-NLS-1$
- + attrs.item(i).getNodeValue().substring(
- valueLength - 15, valueLength));
- buffer.append("\n" + attrs.item(i).getNodeName() + ": " + temp); //$NON-NLS-1$ //$NON-NLS-2$
- } else
- buffer.append("\n" + attrs.item(i).getNodeName() + ": " //$NON-NLS-1$ //$NON-NLS-2$
- + attrs.item(i).getNodeValue());
+ private void resetTooltip(Element sourceElement, nsIDOMElement visualElement) {
+ if (visualElement != null && sourceElement != null
+ && !((ElementImpl) sourceElement).isJSPTag()) {
+ if (HTML.TAG_HTML.equalsIgnoreCase(sourceElement.getNodeName()))
+ return;
+ String titleValue = getTooltip(sourceElement);
- }
+ if (titleValue != null) {
+ titleValue = titleValue.replaceAll("&", "&"); //$NON-NLS-1$//$NON-NLS-2$
+ titleValue = titleValue.replaceAll("<", "<"); //$NON-NLS-1$//$NON-NLS-2$
+ titleValue = titleValue.replaceAll(">", ">"); //$NON-NLS-1$//$NON-NLS-2$
+ }
- return buffer.toString();
- }
+ if (titleValue != null) {
+ resetTooltip(visualElement, titleValue);
+ }
+ }
+ }
- Rectangle getNodeBounds(nsIDOMNode visualNode) {
+ private void resetTooltip(nsIDOMElement visualElement, String titleValue) {
+ visualElement.setAttribute(HTML.ATTR_TITLE, titleValue);
+ nsIDOMNodeList children = visualElement.getChildNodes();
+ long len = children.getLength();
+ for (long i = 0; i < len; i++) {
+ nsIDOMNode child = children.item(i);
+ if (child.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
+ if (domMapping.getNodeMapping(child) == null) {
+ resetTooltip((nsIDOMElement) child
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID),
+ titleValue);
+ }
+ }
+ }
+ }
- return XulRunnerVpeUtils.getElementBounds(visualNode);
- }
+ private String getTooltip(Element sourceElement) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(sourceElement.getNodeName());
+ NamedNodeMap attrs = sourceElement.getAttributes();
+ int len = attrs.getLength();
+ for (int i = 0; i < len; i++) {
+ if (i == 7) {
+ return buffer.append("\n\t... ").toString(); //$NON-NLS-1$
+ }
+ int valueLength = attrs.item(i).getNodeValue().length();
+ if (valueLength > 30) {
+ StringBuffer temp = new StringBuffer();
+ temp.append(attrs.item(i).getNodeValue().substring(0, 15)
+ + " ... " //$NON-NLS-1$
+ + attrs.item(i).getNodeValue().substring(
+ valueLength - 15, valueLength));
+ buffer.append("\n" + attrs.item(i).getNodeName() + ": " + temp); //$NON-NLS-1$ //$NON-NLS-2$
+ } else
+ buffer.append("\n" + attrs.item(i).getNodeName() + ": " //$NON-NLS-1$ //$NON-NLS-2$
+ + attrs.item(i).getNodeValue());
- static boolean canInsertAfter(int x, int y, Rectangle rect) {
- if (y > (rect.y + rect.height) || x > (rect.x + rect.width)) {
- return true;
- }
- return y >= rect.x && x > (rect.x + rect.width / 2);
- }
+ }
- static nsIDOMNode getLastAppreciableVisualChild(nsIDOMNode visualParent) {
- nsIDOMNode visualLastChild = null;
- nsIDOMNodeList visualChildren = visualParent.getChildNodes();
- long len = visualChildren.getLength();
- for (long i = len - 1; i >= 0; i--) {
- nsIDOMNode visualChild = visualChildren.item(i);
- if (!isPseudoElement(visualChild) && !isAnonElement(visualChild)) {
- visualLastChild = visualChild;
- break;
- }
- }
- return visualLastChild;
- }
+ return buffer.toString();
+ }
- void correctVisualDropPosition(VpeVisualInnerDropInfo newVisualDropInfo,
- VpeVisualInnerDropInfo oldVisualDropInfo) {
- nsIDOMNode newVisualDropContainer = newVisualDropInfo
- .getDropContainer();
- nsIDOMNode oldVisualDropContainer = oldVisualDropInfo
- .getDropContainer();
+ Rectangle getNodeBounds(nsIDOMNode visualNode) {
- if (newVisualDropContainer.equals(oldVisualDropContainer)) {
- newVisualDropInfo.setDropOffset(oldVisualDropInfo.getDropOffset());
- return;
- }
+ return XulRunnerVpeUtils.getElementBounds(visualNode);
+ }
- nsIDOMNode child = oldVisualDropContainer;
- while (child != null && child.getNodeType() != Node.DOCUMENT_NODE) {
- nsIDOMNode parent = child.getParentNode();
- if (newVisualDropContainer.equals(parent)) {
- long offset = VisualDomUtil.getOffset(child);
- Rectangle rect = getNodeBounds(child);
- if (canInsertAfter(oldVisualDropInfo.getMouseX(),
- oldVisualDropInfo.getMouseY(), rect)) {
- offset++;
- }
- newVisualDropInfo.setDropOffset(offset);
- }
- child = parent;
- }
- }
+ static boolean canInsertAfter(int x, int y, Rectangle rect) {
+ if (y > (rect.y + rect.height) || x > (rect.x + rect.width)) {
+ return true;
+ }
+ return y >= rect.x && x > (rect.x + rect.width / 2);
+ }
- public nsIDOMRange createDOMRange() {
- return xulRunnerEditor.createDOMRange();
- }
+ static nsIDOMNode getLastAppreciableVisualChild(nsIDOMNode visualParent) {
+ nsIDOMNode visualLastChild = null;
+ nsIDOMNodeList visualChildren = visualParent.getChildNodes();
+ long len = visualChildren.getLength();
+ for (long i = len - 1; i >= 0; i--) {
+ nsIDOMNode visualChild = visualChildren.item(i);
+ if (!isPseudoElement(visualChild) && !isAnonElement(visualChild)) {
+ visualLastChild = visualChild;
+ break;
+ }
+ }
+ return visualLastChild;
+ }
- public nsIDOMRange createDOMRange(nsIDOMNode selectedNode) {
- nsIDOMRange range = createDOMRange();
- range.selectNode(selectedNode);
- return range;
- }
+ void correctVisualDropPosition(VpeVisualInnerDropInfo newVisualDropInfo,
+ VpeVisualInnerDropInfo oldVisualDropInfo) {
+ nsIDOMNode newVisualDropContainer = newVisualDropInfo
+ .getDropContainer();
+ nsIDOMNode oldVisualDropContainer = oldVisualDropInfo
+ .getDropContainer();
- public static boolean isIncludeElement(nsIDOMElement visualElement) {
- return YES_STRING.equalsIgnoreCase(visualElement
- .getAttribute(INCLUDE_ELEMENT_ATTR));
- }
+ if (newVisualDropContainer.equals(oldVisualDropContainer)) {
+ newVisualDropInfo.setDropOffset(oldVisualDropInfo.getDropOffset());
+ return;
+ }
- public static void markIncludeElement(nsIDOMElement visualElement) {
- visualElement.setAttribute(INCLUDE_ELEMENT_ATTR, YES_STRING);
- }
+ nsIDOMNode child = oldVisualDropContainer;
+ while (child != null && child.getNodeType() != Node.DOCUMENT_NODE) {
+ nsIDOMNode parent = child.getParentNode();
+ if (newVisualDropContainer.equals(parent)) {
+ long offset = VisualDomUtil.getOffset(child);
+ Rectangle rect = getNodeBounds(child);
+ if (canInsertAfter(oldVisualDropInfo.getMouseX(),
+ oldVisualDropInfo.getMouseY(), rect)) {
+ offset++;
+ }
+ newVisualDropInfo.setDropOffset(offset);
+ }
+ child = parent;
+ }
+ }
- protected void setReadOnlyElement(nsIDOMElement node) {
- String style = node.getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
- style = VpeStyleUtil.setParameterInStyle(style, "-moz-user-modify", //$NON-NLS-1$
- "read-only"); //$NON-NLS-1$
- node.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
- }
+ public nsIDOMRange createDOMRange() {
+ return xulRunnerEditor.createDOMRange();
+ }
- void setMoveCursor(nsIDOMMouseEvent mouseEvent) {
+ public nsIDOMRange createDOMRange(nsIDOMNode selectedNode) {
+ nsIDOMRange range = createDOMRange();
+ range.selectNode(selectedNode);
+ return range;
+ }
- nsIDOMElement selectedElement = xulRunnerEditor
- .getLastSelectedElement();
- if (selectedElement != null && canInnerDrag(selectedElement)) {
- String styleClasses = selectedElement.getAttribute(HTML.ATTR_CLASS);
- if (inDragArea(getNodeBounds(selectedElement), VisualDomUtil
- .getMousePoint(mouseEvent))) {
- // change cursor
- if (styleClasses == null
- || !(styleClasses.contains(ATTR_DRAG_AVAILABLE_CLASS))) {
- // change cursor style to move
- styleClasses = ATTR_DRAG_AVAILABLE_CLASS + " " //$NON-NLS-1$
- + styleClasses;
- }
- } else {
- // change cursor style to normal
- if (styleClasses != null) {
+ public static boolean isIncludeElement(nsIDOMElement visualElement) {
+ return YES_STRING.equalsIgnoreCase(visualElement
+ .getAttribute(INCLUDE_ELEMENT_ATTR));
+ }
- styleClasses = styleClasses.replaceAll(
- ATTR_DRAG_AVAILABLE_CLASS, ""); //$NON-NLS-1$
- }
- }
- selectedElement.setAttribute(HTML.ATTR_CLASS, styleClasses);
- }
- }
+ public static void markIncludeElement(nsIDOMElement visualElement) {
+ visualElement.setAttribute(INCLUDE_ELEMENT_ATTR, YES_STRING);
+ }
- private boolean inDragArea(Rectangle dragArea, Point mousePoint) {
- // TODO add drag and drop support
- return dragArea.contains(mousePoint)
- && mousePoint.x < (dragArea.x + DRAG_AREA_WIDTH)
- && mousePoint.y < (dragArea.y + DRAG_AREA_HEIGHT);
- }
+ protected void setReadOnlyElement(nsIDOMElement node) {
+ String style = node.getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
+ style = VpeStyleUtil.setParameterInStyle(style, "-moz-user-modify", //$NON-NLS-1$
+ "read-only"); //$NON-NLS-1$
+ node.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
+ }
- nsIDOMElement getDragElement(nsIDOMMouseEvent mouseEvent) {
+ void setMoveCursor(nsIDOMMouseEvent mouseEvent) {
- nsIDOMElement selectedElement = xulRunnerEditor
- .getLastSelectedElement();
- if (selectedElement != null && canInnerDrag(selectedElement)) {
- if (inDragArea(getNodeBounds(selectedElement), VisualDomUtil
- .getMousePoint(mouseEvent))) {
- return selectedElement;
- }
- }
- return null;
- }
+ nsIDOMElement selectedElement = xulRunnerEditor
+ .getLastSelectedElement();
+ if (selectedElement != null && canInnerDrag(selectedElement)) {
+ String styleClasses = selectedElement.getAttribute(HTML.ATTR_CLASS);
+ if (inDragArea(getNodeBounds(selectedElement), VisualDomUtil
+ .getMousePoint(mouseEvent))) {
+ // change cursor
+ if (styleClasses == null
+ || !(styleClasses.contains(ATTR_DRAG_AVAILABLE_CLASS))) {
+ // change cursor style to move
+ styleClasses = ATTR_DRAG_AVAILABLE_CLASS + " " //$NON-NLS-1$
+ + styleClasses;
+ }
+ } else {
+ // change cursor style to normal
+ if (styleClasses != null) {
- VpeSourceInnerDragInfo getSourceInnerDragInfo(
- VpeVisualInnerDragInfo visualDragInfo) {
- nsIDOMNode visualNode = visualDragInfo.getNode();
- int offset = visualDragInfo.getOffset();
- int length = visualDragInfo.getLength();
+ styleClasses = styleClasses.replaceAll(
+ ATTR_DRAG_AVAILABLE_CLASS, ""); //$NON-NLS-1$
+ }
+ }
+ selectedElement.setAttribute(HTML.ATTR_CLASS, styleClasses);
+ }
+ }
- VpeNodeMapping nodeMapping = domMapping.getNearNodeMapping(visualNode);
- Node sourceNode = nodeMapping.getSourceNode();
+ private boolean inDragArea(Rectangle dragArea, Point mousePoint) {
+ // TODO add drag and drop support
+ return dragArea.contains(mousePoint)
+ && mousePoint.x < (dragArea.x + DRAG_AREA_WIDTH)
+ && mousePoint.y < (dragArea.y + DRAG_AREA_HEIGHT);
+ }
- if (sourceNode != null) {
- switch (sourceNode.getNodeType()) {
- case Node.TEXT_NODE:
- int end = TextUtil.sourceInnerPosition(visualNode
- .getNodeValue(), offset + length);
- offset = TextUtil.sourceInnerPosition(
- visualNode.getNodeValue(), offset);
- length = end - offset;
- break;
- case Node.ELEMENT_NODE:
- if (visualNode.getNodeType() == Node.TEXT_NODE) {
- // it's attribute
- sourceNode = null;
- if (isTextEditable(visualNode)) {
- String[] atributeNames = ((VpeElementMapping) nodeMapping)
- .getTemplate().getOutputAtributeNames();
- if (atributeNames != null && atributeNames.length > 0) {
- Element sourceElement = (Element) nodeMapping
- .getSourceNode();
- sourceNode = sourceElement
- .getAttributeNode(atributeNames[0]);
- end = TextUtil.sourceInnerPosition(visualNode
- .getNodeValue(), offset + length);
- offset = TextUtil.sourceInnerPosition(visualNode
- .getNodeValue(), offset);
- length = end - offset;
- }
- }
- }
- break;
- }
- }
- return new VpeSourceInnerDragInfo(sourceNode, offset, length);
- }
+ nsIDOMElement getDragElement(nsIDOMMouseEvent mouseEvent) {
- public nsIDOMText getOutputTextNode(Attr attr) {
- Element sourceElement = ((Attr) attr).getOwnerElement();
- VpeElementMapping elementMapping = domMapping
- .getNearElementMapping(sourceElement);
- if (elementMapping != null) {
+ nsIDOMElement selectedElement = xulRunnerEditor
+ .getLastSelectedElement();
+ if (selectedElement != null && canInnerDrag(selectedElement)) {
+ if (inDragArea(getNodeBounds(selectedElement), VisualDomUtil
+ .getMousePoint(mouseEvent))) {
+ return selectedElement;
+ }
+ }
+ return null;
+ }
- return elementMapping.getTemplate().getOutputTextNode(pageContext,
- sourceElement, elementMapping.getData());
- }
- return null;
- }
+ VpeSourceInnerDragInfo getSourceInnerDragInfo(
+ VpeVisualInnerDragInfo visualDragInfo) {
+ nsIDOMNode visualNode = visualDragInfo.getNode();
+ int offset = visualDragInfo.getOffset();
+ int length = visualDragInfo.getLength();
- nsIDOMElement getLastSelectedElement() {
+ VpeNodeMapping nodeMapping = domMapping.getNearNodeMapping(visualNode);
+ Node sourceNode = nodeMapping.getSourceNode();
- return xulRunnerEditor.getLastSelectedElement();
- }
+ if (sourceNode != null) {
+ switch (sourceNode.getNodeType()) {
+ case Node.TEXT_NODE:
+ int end = TextUtil.sourceInnerPosition(visualNode
+ .getNodeValue(), offset + length);
+ offset = TextUtil.sourceInnerPosition(
+ visualNode.getNodeValue(), offset);
+ length = end - offset;
+ break;
+ case Node.ELEMENT_NODE:
+ if (visualNode.getNodeType() == Node.TEXT_NODE) {
+ // it's attribute
+ sourceNode = null;
+ if (isTextEditable(visualNode)) {
+ String[] atributeNames = ((VpeElementMapping) nodeMapping)
+ .getTemplate().getOutputAtributeNames();
+ if (atributeNames != null && atributeNames.length > 0) {
+ Element sourceElement = (Element) nodeMapping
+ .getSourceNode();
+ sourceNode = sourceElement
+ .getAttributeNode(atributeNames[0]);
+ end = TextUtil.sourceInnerPosition(visualNode
+ .getNodeValue(), offset + length);
+ offset = TextUtil.sourceInnerPosition(visualNode
+ .getNodeValue(), offset);
+ length = end - offset;
+ }
+ }
+ }
+ break;
+ }
+ }
+ return new VpeSourceInnerDragInfo(sourceNode, offset, length);
+ }
- public void pushIncludeStack(VpeIncludeInfo includeInfo) {
- includeStack.add(includeInfo);
- }
+ public nsIDOMText getOutputTextNode(Attr attr) {
+ Element sourceElement = ((Attr) attr).getOwnerElement();
+ VpeElementMapping elementMapping = domMapping
+ .getNearElementMapping(sourceElement);
+ if (elementMapping != null) {
- public VpeIncludeInfo popIncludeStack() {
- VpeIncludeInfo includeInfo = null;
- if (includeStack.size() > 0) {
- includeInfo = (VpeIncludeInfo) includeStack.remove(includeStack
- .size() - 1);
- }
- return includeInfo;
- }
+ return elementMapping.getTemplate().getOutputTextNode(pageContext,
+ sourceElement, elementMapping.getData());
+ }
+ return null;
+ }
- public boolean isFileInIncludeStack(IFile file) {
- if (file == null)
- return false;
- for (int i = 0; i < includeStack.size(); i++) {
- if (file.equals(((VpeIncludeInfo) includeStack.get(i)).getFile())) {
- return true;
- }
- }
- return false;
- }
+ nsIDOMElement getLastSelectedElement() {
- protected boolean isCurrentMainDocument() {
- return includeStack.size() <= 1;
- }
+ return xulRunnerEditor.getLastSelectedElement();
+ }
- public int getCurrentMainIncludeOffset() {
- if (includeStack.size() <= 1)
- return -1;
- VpeIncludeInfo info = (VpeIncludeInfo) includeStack.get(1);
- return ((IndexedRegion) info.getElement()).getStartOffset();
- }
+ public void pushIncludeStack(VpeIncludeInfo includeInfo) {
+ includeStack.add(includeInfo);
+ }
- public VpeIncludeInfo getCurrentIncludeInfo() {
- if (includeStack.size() <= 0)
- return null;
- return (VpeIncludeInfo) includeStack.get(includeStack.size() - 1);
- }
+ public VpeIncludeInfo popIncludeStack() {
+ VpeIncludeInfo includeInfo = null;
+ if (includeStack.size() > 0) {
+ includeInfo = (VpeIncludeInfo) includeStack.remove(includeStack
+ .size() - 1);
+ }
+ return includeInfo;
+ }
- public VpeIncludeInfo getRootIncludeInfo() {
- if (includeStack.size() <= 1)
- return null;
- return (VpeIncludeInfo) includeStack.get(1);
- }
+ public boolean isFileInIncludeStack(IFile file) {
+ if (file == null)
+ return false;
+ for (int i = 0; i < includeStack.size(); i++) {
+ if (file.equals(((VpeIncludeInfo) includeStack.get(i)).getFile())) {
+ return true;
+ }
+ }
+ return false;
+ }
- public void dispose() {
- clearIncludeDocuments();
- includeDocuments = null;
- cleanHead();
- domMapping.clear(getContentArea());
- pageContext.dispose();
- super.dispose();
- }
+ protected boolean isCurrentMainDocument() {
+ return includeStack.size() <= 1;
+ }
- private void clearIncludeDocuments() {
- Collection<Document> documents = includeDocuments.values();
- for (Iterator iterator = documents.iterator(); iterator.hasNext();) {
- Document document = (Document) iterator.next();
- VpeCreatorUtil.releaseDocumentFromRead(document);
- }
- includeDocuments.clear();
- }
+ public int getCurrentMainIncludeOffset() {
+ if (includeStack.size() <= 1)
+ return -1;
+ VpeIncludeInfo info = (VpeIncludeInfo) includeStack.get(1);
+ return ((IndexedRegion) info.getElement()).getStartOffset();
+ }
- // protected Map createXmlns(Element sourceNode) {
- // NamedNodeMap attrs = ((Element) sourceNode).getAttributes();
- // if (attrs != null) {
- // Map xmlnsMap = new HashMap();
- // for (int i = 0; i < attrs.getLength(); i++) {
- // addTaglib(sourceNode, xmlnsMap, attrs.item(i).getNodeName(),
- // true);
- // }
- // if (xmlnsMap.size() > 0) {
- // return xmlnsMap;
- // }
- // }
- // return null;
- // }
+ public VpeIncludeInfo getCurrentIncludeInfo() {
+ if (includeStack.size() <= 0)
+ return null;
+ return (VpeIncludeInfo) includeStack.get(includeStack.size() - 1);
+ }
- // private void setXmlnsAttribute(VpeElementMapping elementMapping,
- // String name, String value) {
- // Element sourceElement = (Element) elementMapping.getSourceNode();
- // if (sourceElement != null) {
- // Map xmlnsMap = elementMapping.getXmlnsMap();
- // if (xmlnsMap == null)
- // xmlnsMap = new HashMap();
- // addTaglib(sourceElement, xmlnsMap, name, true);
- // elementMapping.setXmlnsMap(xmlnsMap.size() > 0 ? xmlnsMap : null);
- // }
- // }
+ public VpeIncludeInfo getRootIncludeInfo() {
+ if (includeStack.size() <= 1)
+ return null;
+ return (VpeIncludeInfo) includeStack.get(1);
+ }
- // private void removeXmlnsAttribute(VpeElementMapping elementMapping,
- // String name) {
- // Element sourceElement = (Element) elementMapping.getSourceNode();
- // if (sourceElement != null) {
- // Map xmlnsMap = elementMapping.getXmlnsMap();
- // if (xmlnsMap != null) {
- // Object id = xmlnsMap.remove(name);
- // if (id != null) {
- // pageContext.setTaglib(((Integer) id).intValue(), null,
- // null, true);
- // elementMapping.setXmlnsMap(xmlnsMap.size() > 0 ? xmlnsMap
- // : null);
- // }
- // }
- // }
- // }
- //
- // private void addTaglib(Element sourceElement, Map xmlnsMap,
- // String attrName, boolean ns) {
- // Attr attr = sourceElement.getAttributeNode(attrName);
- // if (ATTR_XMLNS.equals(attr.getPrefix())) {
- // xmlnsMap.put(attr.getNodeName(), Integer.valueOf(attr.hashCode()));
- // pageContext.setTaglib(attr.hashCode(), attr.getNodeValue(), attr
- // .getLocalName(), ns);
- // }
- // }
+ public void dispose() {
+ clearIncludeDocuments();
+ includeDocuments = null;
+ cleanHead();
+ domMapping.clear(getContentArea());
+ pageContext.dispose();
+ super.dispose();
+ }
- /**
- * @return the dnd
- */
- public VpeDnD getDnd() {
+ private void clearIncludeDocuments() {
+ Collection<Document> documents = includeDocuments.values();
+ for (Iterator iterator = documents.iterator(); iterator.hasNext();) {
+ Document document = (Document) iterator.next();
+ VpeCreatorUtil.releaseDocumentFromRead(document);
+ }
+ includeDocuments.clear();
+ }
- return dnd;
- }
+ // protected Map createXmlns(Element sourceNode) {
+ // NamedNodeMap attrs = ((Element) sourceNode).getAttributes();
+ // if (attrs != null) {
+ // Map xmlnsMap = new HashMap();
+ // for (int i = 0; i < attrs.getLength(); i++) {
+ // addTaglib(sourceNode, xmlnsMap, attrs.item(i).getNodeName(),
+ // true);
+ // }
+ // if (xmlnsMap.size() > 0) {
+ // return xmlnsMap;
+ // }
+ // }
+ // return null;
+ // }
- /**
- * @param dnd
- * the dnd to set
- */
- public void setDnd(VpeDnD dnd) {
+ // private void setXmlnsAttribute(VpeElementMapping elementMapping,
+ // String name, String value) {
+ // Element sourceElement = (Element) elementMapping.getSourceNode();
+ // if (sourceElement != null) {
+ // Map xmlnsMap = elementMapping.getXmlnsMap();
+ // if (xmlnsMap == null)
+ // xmlnsMap = new HashMap();
+ // addTaglib(sourceElement, xmlnsMap, name, true);
+ // elementMapping.setXmlnsMap(xmlnsMap.size() > 0 ? xmlnsMap : null);
+ // }
+ // }
- this.dnd = dnd;
- }
+ // private void removeXmlnsAttribute(VpeElementMapping elementMapping,
+ // String name) {
+ // Element sourceElement = (Element) elementMapping.getSourceNode();
+ // if (sourceElement != null) {
+ // Map xmlnsMap = elementMapping.getXmlnsMap();
+ // if (xmlnsMap != null) {
+ // Object id = xmlnsMap.remove(name);
+ // if (id != null) {
+ // pageContext.setTaglib(((Integer) id).intValue(), null,
+ // null, true);
+ // elementMapping.setXmlnsMap(xmlnsMap.size() > 0 ? xmlnsMap
+ // : null);
+ // }
+ // }
+ // }
+ // }
+ //
+ // private void addTaglib(Element sourceElement, Map xmlnsMap,
+ // String attrName, boolean ns) {
+ // Attr attr = sourceElement.getAttributeNode(attrName);
+ // if (ATTR_XMLNS.equals(attr.getPrefix())) {
+ // xmlnsMap.put(attr.getNodeName(), Integer.valueOf(attr.hashCode()));
+ // pageContext.setTaglib(attr.hashCode(), attr.getNodeValue(), attr
+ // .getLocalName(), ns);
+ // }
+ // }
- /**
- * @return the pageContext
- */
- protected VpePageContext getPageContext() {
- return pageContext;
- }
+ /**
+ * @return the dnd
+ */
+ public VpeDnD getDnd() {
- /**
- * @param pageContext
- * the pageContext to set
- */
- protected void setPageContext(VpePageContext pageContext) {
- this.pageContext = pageContext;
- }
+ return dnd;
+ }
- /**
- * @return the visualDocument
- */
- protected nsIDOMDocument getVisualDocument() {
- return visualDocument;
- }
+ /**
+ * @param dnd
+ * the dnd to set
+ */
+ public void setDnd(VpeDnD dnd) {
- /**
- * @param visualDocument
- * the visualDocument to set
- */
- protected void setVisualDocument(nsIDOMDocument visualDocument) {
- this.visualDocument = visualDocument;
- }
+ this.dnd = dnd;
+ }
- /**
- * Check this file is facelet
- *
- * @return this if file is facelet, otherwize false
- */
- private boolean isFacelet() {
- boolean isFacelet = false;
+ /**
+ * @return the pageContext
+ */
+ protected VpePageContext getPageContext() {
+ return pageContext;
+ }
- IEditorInput iEditorInput = pageContext.getEditPart().getEditorInput();
- if (iEditorInput instanceof IFileEditorInput) {
- IFileEditorInput iFileEditorInput = (IFileEditorInput) iEditorInput;
+ /**
+ * @param pageContext
+ * the pageContext to set
+ */
+ protected void setPageContext(VpePageContext pageContext) {
+ this.pageContext = pageContext;
+ }
- IFile iFile = iFileEditorInput.getFile();
+ /**
+ * @return the visualDocument
+ */
+ protected nsIDOMDocument getVisualDocument() {
+ return visualDocument;
+ }
- IProject project = iFile.getProject();
- IModelNature nature = EclipseResourceUtil.getModelNature(project);
- if (nature != null) {
- XModel model = nature.getModel();
- XModelObject webXML = WebAppHelper.getWebApp(model);
- XModelObject param = WebAppHelper.findWebAppContextParam(
- webXML, "javax.faces.DEFAULT_SUFFIX"); //$NON-NLS-1$
- if (param != null) {
- String value = param.getAttributeValue("param-value"); //$NON-NLS-1$
+ /**
+ * @param visualDocument
+ * the visualDocument to set
+ */
+ protected void setVisualDocument(nsIDOMDocument visualDocument) {
+ this.visualDocument = visualDocument;
+ }
- if (value.length() != 0 && iFile.getName().endsWith(value)) {
- isFacelet = true;
- }
- }
- }
- }
+ /**
+ * Check this file is facelet
+ *
+ * @return this if file is facelet, otherwize false
+ */
+ private boolean isFacelet() {
+ boolean isFacelet = false;
- return isFacelet;
- }
+ IEditorInput iEditorInput = pageContext.getEditPart().getEditorInput();
+ if (iEditorInput instanceof IFileEditorInput) {
+ IFileEditorInput iFileEditorInput = (IFileEditorInput) iEditorInput;
- /**
- * Create a visual element for text node
- *
- * @param sourceNode
- * @param registerFlag
- * @return a visual element for text node
- */
+ IFile iFile = iFileEditorInput.getFile();
-// protected nsIDOMNode createTextNode(Node sourceNode, boolean registerFlag) {
-// String sourceText = sourceNode.getNodeValue();
-// if(sourceText!=null){
-// final IFile file = getPageContext().getVisualBuilder().getCurrentIncludeInfo().getFile();
-//
-// sourceText = ElService.getInstance().replaceEl(file, sourceText);
-// }
-// /*
-// * Max Areshkau this code causes very slow work of visual editor
-// * when we editing in big files txt nodes.For example exmployee.xhtml
-// * from JBIDE1105
-// *
-// * Denis Maliarevich:
-// * To fix JBIDE-2003 and JBIDE-2042
-// * this code should be uncommented.
-// */
-// if (sourceText.trim().length() <= 0) {
-// if (registerFlag) {
-// registerNodes(new VpeNodeMapping(sourceNode, null));
-// }
-// return null;
-// }
-//
-// if (faceletFile) {
-// Matcher matcher_EL = REGEX_EL.matcher(sourceText);
-// if (matcher_EL.find()) {
-// BundleMap bundle = pageContext.getBundle();
-// int offset = pageContext.getVisualBuilder()
-// .getCurrentMainIncludeOffset();
-// if (offset == -1)
-// offset = ((IndexedRegion) sourceNode).getStartOffset();
-// String jsfValue = bundle.getBundleValue(sourceText, offset);
-// sourceText = jsfValue;
-// }
-// }
-// String visualText = TextUtil.visualText(sourceText);
-//
-// nsIDOMNode visualNewTextNode = visualDocument
-// .createTextNode(visualText);
-// nsIDOMElement element = visualDocument.createElement(HTML.TAG_SPAN);
-// element.setAttribute(HTML.ATTR_STYLE, ""); //$NON-NLS-1$
-// element.appendChild(visualNewTextNode);
-// if (registerFlag) {
-// registerNodes(new VpeNodeMapping(sourceNode, element));
-// }
-//
-// return element;
-// }
+ IProject project = iFile.getProject();
+ IModelNature nature = EclipseResourceUtil.getModelNature(project);
+ if (nature != null) {
+ XModel model = nature.getModel();
+ XModelObject webXML = WebAppHelper.getWebApp(model);
+ XModelObject param = WebAppHelper.findWebAppContextParam(
+ webXML, "javax.faces.DEFAULT_SUFFIX"); //$NON-NLS-1$
+ if (param != null) {
+ String value = param.getAttributeValue("param-value"); //$NON-NLS-1$
- /**
- * @return the xulRunnerEditor
- */
- public XulRunnerEditor getXulRunnerEditor() {
- return xulRunnerEditor;
- }
+ if (value.length() != 0 && iFile.getName().endsWith(value)) {
+ isFacelet = true;
+ }
+ }
+ }
+ }
- /**
- * @param xulRunnerEditor
- * the xulRunnerEditor to set
- */
- public void setXulRunnerEditor(XulRunnerEditor xulRunnerEditor) {
- this.xulRunnerEditor = xulRunnerEditor;
- }
+ return isFacelet;
+ }
- public Map<IFile, Document> getIncludeDocuments() {
- return includeDocuments;
- }
-
- public nsIDOMNode getHeadNode() {
- return visualEditor.getHeadNode();
- }
+ /**
+ * Create a visual element for text node
+ *
+ * @param sourceNode
+ * @param registerFlag
+ * @return a visual element for text node
+ */
+ // protected nsIDOMNode createTextNode(Node sourceNode, boolean
+ // registerFlag) {
+ // String sourceText = sourceNode.getNodeValue();
+ // if(sourceText!=null){
+ // final IFile file =
+ // getPageContext().getVisualBuilder().getCurrentIncludeInfo().getFile();
+ //
+ // sourceText = ElService.getInstance().replaceEl(file, sourceText);
+ // }
+ // /*
+ // * Max Areshkau this code causes very slow work of visual editor
+ // * when we editing in big files txt nodes.For example exmployee.xhtml
+ // * from JBIDE1105
+ // *
+ // * Denis Maliarevich:
+ // * To fix JBIDE-2003 and JBIDE-2042
+ // * this code should be uncommented.
+ // */
+ // if (sourceText.trim().length() <= 0) {
+ // if (registerFlag) {
+ // registerNodes(new VpeNodeMapping(sourceNode, null));
+ // }
+ // return null;
+ // }
+ //
+ // if (faceletFile) {
+ // Matcher matcher_EL = REGEX_EL.matcher(sourceText);
+ // if (matcher_EL.find()) {
+ // BundleMap bundle = pageContext.getBundle();
+ // int offset = pageContext.getVisualBuilder()
+ // .getCurrentMainIncludeOffset();
+ // if (offset == -1)
+ // offset = ((IndexedRegion) sourceNode).getStartOffset();
+ // String jsfValue = bundle.getBundleValue(sourceText, offset);
+ // sourceText = jsfValue;
+ // }
+ // }
+ // String visualText = TextUtil.visualText(sourceText);
+ //
+ // nsIDOMNode visualNewTextNode = visualDocument
+ // .createTextNode(visualText);
+ // nsIDOMElement element = visualDocument.createElement(HTML.TAG_SPAN);
+ // element.setAttribute(HTML.ATTR_STYLE, ""); //$NON-NLS-1$
+ // element.appendChild(visualNewTextNode);
+ // if (registerFlag) {
+ // registerNodes(new VpeNodeMapping(sourceNode, element));
+ // }
+ //
+ // return element;
+ // }
+ /**
+ * @return the xulRunnerEditor
+ */
+ public XulRunnerEditor getXulRunnerEditor() {
+ return xulRunnerEditor;
+ }
+
+ /**
+ * @param xulRunnerEditor
+ * the xulRunnerEditor to set
+ */
+ public void setXulRunnerEditor(XulRunnerEditor xulRunnerEditor) {
+ this.xulRunnerEditor = xulRunnerEditor;
+ }
+
+ public Map<IFile, Document> getIncludeDocuments() {
+ return includeDocuments;
+ }
+
+ public nsIDOMNode getHeadNode() {
+ return visualEditor.getHeadNode();
+ }
+
public boolean isShowInvisibleTags() {
return showInvisibleTags;
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/NodesManagingUtil.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/NodesManagingUtil.java 2008-08-29 19:11:40 UTC (rev 9968)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/NodesManagingUtil.java 2008-08-30 00:06:07 UTC (rev 9969)
@@ -106,12 +106,8 @@
* @return
*/
public static boolean isNodeContainsPosition(Node node, int position) {
-
- if ((NodesManagingUtil.getStartOffsetNode(node) <= position)
- && (NodesManagingUtil.getEndOffsetNode(node) >= position))
- return true;
-
- return false;
+ return NodesManagingUtil.getStartOffsetNode(node) <= position
+ && NodesManagingUtil.getEndOffsetNode(node) >= position;
}
/**
16 years, 3 months
JBoss Tools SVN: r9968 - trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-08-29 15:11:40 -0400 (Fri, 29 Aug 2008)
New Revision: 9968
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DropUtils.java
Log:
JBIDE-2302, JBIDE-2573, JBIDE-2355, JBIDE-2407 - Key binding issues in Ganymede
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DropUtils.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DropUtils.java 2008-08-29 16:46:27 UTC (rev 9967)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DropUtils.java 2008-08-29 19:11:40 UTC (rev 9968)
@@ -117,12 +117,6 @@
}
} catch (KbException ex) {
ModelUIPlugin.getPluginLog().logError(ex);
- } catch (InstantiationException ex) {
- ModelUIPlugin.getPluginLog().logError(ex);
- } catch (IllegalAccessException ex) {
- ModelUIPlugin.getPluginLog().logError(ex);
- } catch (ClassNotFoundException ex) {
- ModelUIPlugin.getPluginLog().logError(ex);
}
if(attributes==null)return new AttributeDescriptorValue[0];
List<AttributeDescriptorValue> attributesValues = new ArrayList<AttributeDescriptorValue>();
@@ -152,12 +146,6 @@
tagInfo = wtpKbConnector.getTagInformation("/"+(tagPrefix==TagProposal.EMPTY_PREFIX?"":tagPrefix+":")+tagName);
} catch (KbException ex) {
ModelUIPlugin.getPluginLog().logError(ex);
- } catch (InstantiationException ex) {
- ModelUIPlugin.getPluginLog().logError(ex);
- } catch (IllegalAccessException ex) {
- ModelUIPlugin.getPluginLog().logError(ex);
- } catch (ClassNotFoundException ex) {
- ModelUIPlugin.getPluginLog().logError(ex);
}
return tagInfo;
}
16 years, 3 months
JBoss Tools SVN: r9967 - trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template.
by jbosstools-commits@lists.jboss.org
Author: dsakovich
Date: 2008-08-29 12:46:27 -0400 (Fri, 29 Aug 2008)
New Revision: 9967
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInsertTemplate.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2684
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInsertTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInsertTemplate.java 2008-08-29 14:51:12 UTC (rev 9966)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInsertTemplate.java 2008-08-29 16:46:27 UTC (rev 9967)
@@ -108,7 +108,15 @@
}
try {
- IFile iFile = VpeCreatorUtil.getFile(srcValue, pageContext);
+ IFile iFile = VpeCreatorUtil.getFile(srcValue, pageContext);
+ if (iFile==null || !iFile.isAccessible()) {
+ div.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
+ ERROR_MESSAGE_STYLE);
+ nsIDOMText text = visualDocument
+ .createTextNode(RESOURCE_READING_ERROR_MESSAGE);
+ div.appendChild(text);
+ return vpeCreationData;
+ }
File file = new File(iFile.getLocation().toOSString());
BufferedReader br = new BufferedReader(new InputStreamReader(
new FileInputStream(file)));
@@ -116,8 +124,10 @@
finalStr += buf + "\n"; //$NON-NLS-1$
} catch (IOException e) {
- div.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, ERROR_MESSAGE_STYLE);
- nsIDOMText text = visualDocument.createTextNode(RESOURCE_READING_ERROR_MESSAGE);
+ div.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
+ ERROR_MESSAGE_STYLE);
+ nsIDOMText text = visualDocument
+ .createTextNode(RESOURCE_READING_ERROR_MESSAGE);
div.appendChild(text);
return vpeCreationData;
}
16 years, 3 months
JBoss Tools SVN: r9966 - in trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces: resources/menuGroup and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2008-08-29 10:51:12 -0400 (Fri, 29 Aug 2008)
New Revision: 9966
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/menuGroup/list-bg.png
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/menuGroup/menuGroup.css
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/menuItem/menuItem.css
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/dropDownMenu/dropDownMenu.css
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDropDownMenuTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMenuGroupTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMenuItemTemplate.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2497,
css files were added, styles were checked.
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/dropDownMenu/dropDownMenu.css
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/dropDownMenu/dropDownMenu.css 2008-08-29 14:21:10 UTC (rev 9965)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/dropDownMenu/dropDownMenu.css 2008-08-29 14:51:12 UTC (rev 9966)
@@ -1,3 +1,33 @@
+.rich-ddmenu-label {
+ font-family:Arial,Verdana,sans-serif;
+ font-size:11px;
+ height:auto;
+ left:0pt;
+ padding:2px 5px;
+ top:0pt;
+ white-space:nowrap;
+ width:auto;
+}
+.rich-ddmenu-label-unselect {
+ border:0pt solid transparent;
+ padding:3px 6px;
+}
+.rich-ddmenu-label-select {
+
+}
+.rich-ddmenu-label-disabled {
+
+}
+.rich-label-text-decor {
+ font-weight:bold;
+}
+.rich-menu-list-border {
+
+}
+.rich-menu-list-bg {
+
+}
+
.dr-menu-list-border {
border : 1px solid #bfbfc0;
background-color : #e7f2fb;
Added: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/menuGroup/list-bg.png
===================================================================
(Binary files differ)
Property changes on: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/menuGroup/list-bg.png
___________________________________________________________________
Name: svn:mime-type
+ image/png
Added: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/menuGroup/menuGroup.css
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/menuGroup/menuGroup.css (rev 0)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/menuGroup/menuGroup.css 2008-08-29 14:51:12 UTC (rev 9966)
@@ -0,0 +1,61 @@
+.rich-menu-group {
+ font-family:Arial,Verdana,sans-serif;
+ color:#000000;
+ font-size:11px;
+}
+.rich-menu-group-label {
+
+}
+.rich-menu-group-folder {
+
+}
+.rich-menu-group-over {
+
+}
+.rich-menu-item-label {
+
+}
+.rich-menu-item-icon {
+
+}
+.rich-menu-item-folder {
+
+}
+.rich-menu-item-label-disabled {
+
+}
+.rich-menu-item-icon-disabled {
+
+}
+.rich-menu-item-folder-disabled {
+
+}
+.rich-menu-item-icon-enabled {
+ border:0pt solid transparent;
+ padding:2px 36px 2px 2px;
+}
+.rich-menu-item-icon-selected {
+
+}
+.rich-menu-list-border {
+ font-family:Arial,Verdana,sans-serif;
+ /*background-color:#F1EEE9;*/
+ background-color:#C4C0B9;
+ border-color:#C4C0B9;
+ border:1px solid;
+}
+.rich-menu-list-bg {
+ background-image:url(list-bg.png);
+ border-left-color:#F1EEE9;
+ border-right-color:#F1EEE9;
+ border-top-color:#F1EEE9;
+
+ background:transparent none repeat-y scroll left center;
+ border-left-style:solid;
+ border-left-width:1px;
+ border-right-style:solid;
+ border-right-width:1px;
+ border-top-style:solid;
+ border-top-width:1px;
+
+}
\ No newline at end of file
Property changes on: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/menuGroup/menuGroup.css
___________________________________________________________________
Name: svn:mime-type
+ text/css
Name: svn:eol-style
+ native
Added: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/menuItem/menuItem.css
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/menuItem/menuItem.css (rev 0)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/menuItem/menuItem.css 2008-08-29 14:51:12 UTC (rev 9966)
@@ -0,0 +1,36 @@
+.rich-menu-item {
+
+}
+.rich-menu-item-label {
+
+}
+.rich-menu-item-icon {
+
+}
+.rich-menu-item-disabled {
+
+}
+.rich-menu-item-enabled {
+
+}
+.rich-menu-item-hover {
+
+}
+.rich-menu-item-label-disabled {
+
+}
+.rich-menu-item-icon-disabled {
+
+}
+.rich-menu-item-label-enabled {
+
+}
+.rich-menu-item-icon-enabled {
+
+}
+.rich-menu-item-label-selected {
+
+}
+.rich-menu-item-icon-selected {
+
+}
Property changes on: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/menuItem/menuItem.css
___________________________________________________________________
Name: svn:mime-type
+ text/css
Name: svn:eol-style
+ native
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDropDownMenuTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDropDownMenuTemplate.java 2008-08-29 14:21:10 UTC (rev 9965)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDropDownMenuTemplate.java 2008-08-29 14:51:12 UTC (rev 9966)
@@ -35,6 +35,8 @@
/*
* rich:dropDownMenu constants
*/
+ private final static String COMPONENT_NAME = "dropDownMenu"; //$NON-NLS-1$
+ private final static String STYLE_PATH = "dropDownMenu/dropDownMenu.css"; //$NON-NLS-1$
private static final String LABEL_FACET_NAME = "label"; //$NON-NLS-1$
private static final String EMPTY = ""; //$NON-NLS-1$
private static final String SPACE = " "; //$NON-NLS-1$
@@ -101,7 +103,7 @@
public VpeCreationData create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument visualDocument) {
VpeCreationData creationData = null;
Element sourceElement = (Element)sourceNode;
-
+ ComponentUtil.setCSSLink(pageContext, STYLE_PATH, COMPONENT_NAME);
readDropDownMenuAttributes(sourceElement);
/*
@@ -198,7 +200,7 @@
}
nsIDOMElement childDiv = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_DIV);
- ddmListBorderDiv.appendChild(childDiv);
+ ddmListBgDiv.appendChild(childDiv);
VpeChildrenInfo childDivInfo = new VpeChildrenInfo(childDiv);
childDivInfo.addSourceChild(child);
creationData.addChildrenInfo(childDivInfo);
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMenuGroupTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMenuGroupTemplate.java 2008-08-29 14:21:10 UTC (rev 9965)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMenuGroupTemplate.java 2008-08-29 14:51:12 UTC (rev 9966)
@@ -29,13 +29,16 @@
public class RichFacesMenuGroupTemplate extends VpeAbstractTemplate {
+ public static final String MENU_GROUP_ID = "MENU-GROUP-ID"; //$NON-NLS-1$
+
/*
* rich:menuGroup constants
*/
- public static final String MENU_GROUP_ID = "MENU-GROUP-ID"; //$NON-NLS-1$
+ private final static String COMPONENT_NAME = "menuGroup"; //$NON-NLS-1$
+ private final static String STYLE_PATH = "menuGroup/menuGroup.css"; //$NON-NLS-1$
+ private static final String SPACER_IMG_PATH = "menuGroup/spacer.gif"; //$NON-NLS-1$
private static final String ICON_FACET_NAME = "icon"; //$NON-NLS-1$
private static final String ICON_DISABLED_FACET_NAME = "iconDisabled"; //$NON-NLS-1$
- private static final String SPACER_IMG_PATH = "menuGroup/spacer.gif"; //$NON-NLS-1$
private static final String EMPTY = ""; //$NON-NLS-1$
private static final String SPACE = " "; //$NON-NLS-1$
@@ -53,7 +56,7 @@
private static final String CSS_RICH_MENU_ITEM_ICON_DISABLED = "rich-menu-item-icon-disabled"; //$NON-NLS-1$
private static final String CSS_RICH_MENU_ITEM_FOLDER_DISABLED = "rich-menu-item-folder-disabled"; //$NON-NLS-1$
private static final String CSS_RICH_MENU_ITEM_ICON_ENABLED = "rich-menu-item-icon-enabled"; //$NON-NLS-1$
- private static final String CSS_RICH_MENU_ITEM_ICON_SELECTED = "rich-menu-item-icon-seleceted"; //$NON-NLS-1$
+ private static final String CSS_RICH_MENU_ITEM_ICON_SELECTED = "rich-menu-item-icon-selected"; //$NON-NLS-1$
private static final String CSS_RICH_MENU_LIST_BORDER = "rich-menu-list-border"; //$NON-NLS-1$
private static final String CSS_RICH_MENU_LIST_BG = "rich-menu-list-bg"; //$NON-NLS-1$
private static final String CSS_RICH_LIST_FOLDER_DIV_STYLE = "position: relative; z-index: 100;"; //$NON-NLS-1$
@@ -103,6 +106,8 @@
nsIDOMDocument visualDocument) {
VpeCreationData creationData = null;
Element sourceElement = (Element)sourceNode;
+ ComponentUtil.setCSSLink(pageContext, STYLE_PATH, COMPONENT_NAME);
+ readMenuGroupAttributes(sourceElement);
/*
* MenuGroup component structure.
@@ -220,7 +225,7 @@
for (Node child : children) {
nsIDOMElement childDiv = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_DIV);
- grTopDiv.appendChild(childDiv);
+ grListBgDiv.appendChild(childDiv);
VpeChildrenInfo childDivInfo = new VpeChildrenInfo(childDiv);
childDivInfo.addSourceChild(child);
creationData.addChildrenInfo(childDivInfo);
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMenuItemTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMenuItemTemplate.java 2008-08-29 14:21:10 UTC (rev 9965)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMenuItemTemplate.java 2008-08-29 14:51:12 UTC (rev 9966)
@@ -32,9 +32,11 @@
/*
* rich:menuItem constants
*/
+ private final static String COMPONENT_NAME = "menuItem"; //$NON-NLS-1$
+ private final static String STYLE_PATH = "menuItem/menuItem.css"; //$NON-NLS-1$
+ private static final String SPACER_IMG_PATH = "menuItem/spacer.gif"; //$NON-NLS-1$
private static final String ICON_FACET_NAME = "icon"; //$NON-NLS-1$
private static final String ICON_DISABLED_FACET_NAME = "iconDisabled"; //$NON-NLS-1$
- private static final String SPACER_IMG_PATH = "menuItem/spacer.gif"; //$NON-NLS-1$
private static final String EMPTY = ""; //$NON-NLS-1$
private static final String SPACE = " "; //$NON-NLS-1$
@@ -43,7 +45,7 @@
*/
private static final String CSS_RICH_MENU_ITEM = "rich-menu-item"; //$NON-NLS-1$
private static final String CSS_RICH_MENU_ITEM_LABEL = "rich-menu-item-label"; //$NON-NLS-1$
- private static final String CSS_RICH_MENU_ITEM_ICON = "rich-menu-item-item"; //$NON-NLS-1$
+ private static final String CSS_RICH_MENU_ITEM_ICON = "rich-menu-item-icon"; //$NON-NLS-1$
private static final String CSS_RICH_MENU_ITEM_DISABLED = "rich-menu-item-disabled"; //$NON-NLS-1$
private static final String CSS_RICH_MENU_ITEM_ENABLED = "rich-menu-item-enabled"; //$NON-NLS-1$
private static final String CSS_RICH_MENU_ITEM_HOVER = "rich-menu-item-hover"; //$NON-NLS-1$
@@ -92,7 +94,7 @@
nsIDOMDocument visualDocument) {
VpeCreationData creationData = null;
Element sourceElement = (Element)sourceNode;
-
+ ComponentUtil.setCSSLink(pageContext, STYLE_PATH, COMPONENT_NAME);
readMenuItemAttributes(sourceElement);
/*
16 years, 3 months
JBoss Tools SVN: r9965 - in trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor: util and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: sdzmitrovich
Date: 2008-08-29 10:21:10 -0400 (Fri, 29 Aug 2008)
New Revision: 9965
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/SelectionManager.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/NodesManagingUtil.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-1972
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/SelectionManager.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/SelectionManager.java 2008-08-29 14:19:13 UTC (rev 9964)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/SelectionManager.java 2008-08-29 14:21:10 UTC (rev 9965)
@@ -298,7 +298,7 @@
// if mapping is elementMapping
-// SelectionUtil.clearSelection(selectionController);
+ SelectionUtil.clearSelection(selectionController);
if (nodeMapping instanceof VpeElementMapping) {
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/NodesManagingUtil.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/NodesManagingUtil.java 2008-08-29 14:19:13 UTC (rev 9964)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/NodesManagingUtil.java 2008-08-29 14:21:10 UTC (rev 9965)
@@ -108,7 +108,7 @@
public static boolean isNodeContainsPosition(Node node, int position) {
if ((NodesManagingUtil.getStartOffsetNode(node) <= position)
- && (NodesManagingUtil.getEndOffsetNode(node) > position))
+ && (NodesManagingUtil.getEndOffsetNode(node) >= position))
return true;
return false;
16 years, 3 months
JBoss Tools SVN: r9964 - trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/css.
by jbosstools-commits@lists.jboss.org
Author: smukhina
Date: 2008-08-29 10:19:13 -0400 (Fri, 29 Aug 2008)
New Revision: 9964
Modified:
trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/css/tools.css
Log:
https://jira.jboss.org/jira/browse/JBDS-402
nightly docs label is added to studio and tools docs
Modified: trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/css/tools.css
===================================================================
--- trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/css/tools.css 2008-08-29 12:46:13 UTC (rev 9963)
+++ trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/css/tools.css 2008-08-29 14:19:13 UTC (rev 9964)
@@ -42,7 +42,7 @@
}
div#overlay{
-background-image:url(../images/community/bkg_gradient.gif);
+/*background-image:url(../images/community/bkg_gradient.gif);*/
background-repeat:repeat-x;
width:100%;
height:100%;
16 years, 3 months
JBoss Tools SVN: r9963 - in trunk/documentation/jbosstools-jdocbook-style/src/main: com/css/css and 6 other directories.
by jbosstools-commits@lists.jboss.org
Author: smukhina
Date: 2008-08-29 08:46:13 -0400 (Fri, 29 Aug 2008)
New Revision: 9963
Added:
trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/images/jbds_label2.png
trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/
trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/toggle.js
trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/images/jbosstools_label2.png
trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/script/
trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/script/toggle.js
Removed:
trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/images/richfaces_label2.png
trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/images/richfaces_label2.png
Modified:
trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/css/tools.css
trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/css/tools.css
Log:
https://jira.jboss.org/jira/browse/JBDS-402
nightly docs label is added to studio and tools docs
Modified: trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/css/tools.css
===================================================================
--- trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/css/tools.css 2008-08-29 12:35:33 UTC (rev 9962)
+++ trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/css/tools.css 2008-08-29 12:46:13 UTC (rev 9963)
@@ -27,7 +27,7 @@
body {
-background-image:url(../images/richfaces_label2.png);
+background-image:url(../images/jbds_label2.png);
background-repeat:no-repeat;
background-attachment:fixed;
background-position:top left;
Added: trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/images/jbds_label2.png
===================================================================
(Binary files differ)
Property changes on: trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/images/jbds_label2.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/images/richfaces_label2.png
===================================================================
(Binary files differ)
Added: trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/toggle.js
===================================================================
--- trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/toggle.js (rev 0)
+++ trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/script/toggle.js 2008-08-29 12:46:13 UTC (rev 9963)
@@ -0,0 +1 @@
+document.write('<div id="overlay"> </div>');
Modified: trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/css/tools.css
===================================================================
--- trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/css/tools.css 2008-08-29 12:35:33 UTC (rev 9962)
+++ trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/css/tools.css 2008-08-29 12:46:13 UTC (rev 9963)
@@ -30,7 +30,7 @@
body {
-background-image:url(../images/richfaces_label2.png);
+background-image:url(../images/jbosstools_label2.png);
background-repeat:no-repeat;
background-attachment:fixed;
background-position:top left;
Added: trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/images/jbosstools_label2.png
===================================================================
(Binary files differ)
Property changes on: trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/images/jbosstools_label2.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/images/richfaces_label2.png
===================================================================
(Binary files differ)
Added: trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/script/toggle.js
===================================================================
--- trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/script/toggle.js (rev 0)
+++ trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/script/toggle.js 2008-08-29 12:46:13 UTC (rev 9963)
@@ -0,0 +1 @@
+document.write('<div id="overlay"> </div>');
16 years, 3 months
JBoss Tools SVN: r9962 - in trunk/documentation/jbosstools-jdocbook-style/src/main: org/css/images and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: smukhina
Date: 2008-08-29 08:35:33 -0400 (Fri, 29 Aug 2008)
New Revision: 9962
Added:
trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/images/richfaces_label2.png
trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/images/richfaces_label2.png
Log:
https://jira.jboss.org/jira/browse/JBDS-402
nightly docs label is added to studio and tools docs
Added: trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/images/richfaces_label2.png
===================================================================
(Binary files differ)
Property changes on: trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/images/richfaces_label2.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/images/richfaces_label2.png
===================================================================
(Binary files differ)
Property changes on: trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/images/richfaces_label2.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
16 years, 3 months
JBoss Tools SVN: r9961 - in trunk/documentation: jbosstools-docbook-xslt/src/main/resources/xslt/org/jboss/tools and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: smukhina
Date: 2008-08-29 08:14:31 -0400 (Fri, 29 Aug 2008)
New Revision: 9961
Modified:
trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt/com/jboss/tools/common.xsl
trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt/org/jboss/tools/common.xsl
trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/css/tools.css
trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/css/tools.css
Log:
https://jira.jboss.org/jira/browse/JBDS-402
nightly docs label is added to studio and tools docs
Modified: trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt/com/jboss/tools/common.xsl
===================================================================
--- trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt/com/jboss/tools/common.xsl 2008-08-29 11:54:52 UTC (rev 9960)
+++ trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt/com/jboss/tools/common.xsl 2008-08-29 12:14:31 UTC (rev 9961)
@@ -57,6 +57,8 @@
<link rel="shortcut icon" type="image/vnd.microsoft.icon" href="images/favicon0.ico" />
<xsl:apply-templates select="." mode="head.keywords.content"/>
+<script type="text/javascript" src="script/toggle.js"><xsl:comment>If you see this message, your web browser doesn't support JavaScript or JavaScript is disabled.</xsl:comment></script>
+
</xsl:template>
Modified: trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt/org/jboss/tools/common.xsl
===================================================================
--- trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt/org/jboss/tools/common.xsl 2008-08-29 11:54:52 UTC (rev 9960)
+++ trunk/documentation/jbosstools-docbook-xslt/src/main/resources/xslt/org/jboss/tools/common.xsl 2008-08-29 12:14:31 UTC (rev 9961)
@@ -55,7 +55,9 @@
<link rel="shortcut icon" type="image/vnd.microsoft.icon" href="images/favicon.ico" />
- <xsl:apply-templates select="." mode="head.keywords.content"/>
+ <xsl:apply-templates select="." mode="head.keywords.content"/>
+<script type="text/javascript" src="script/toggle.js"><xsl:comment>If you see this message, your web browser doesn't support JavaScript or JavaScript is disabled.</xsl:comment></script>
+
</xsl:template>
Modified: trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/css/tools.css
===================================================================
--- trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/css/tools.css 2008-08-29 11:54:52 UTC (rev 9960)
+++ trunk/documentation/jbosstools-jdocbook-style/src/main/com/css/css/tools.css 2008-08-29 12:14:31 UTC (rev 9961)
@@ -2,12 +2,56 @@
/* -----Override jbossenterprise-single.css----- */
-body {
- text-align:center;
- font-family:"Lucida Grande", verdana, "Luxi Sans","Trebuchet MS", helvetica,verdana,arial,sans-serif;
+/*body {
+background-image:url(../images/richfaces_label2.png);
+background-repeat:no-repeat;
+background-attachment:fixed;
+background-position:top left;
+z-index:1;
+text-align:center;
+font-family:"Lucida Grande", verdana, "Luxi Sans","Trebuchet MS", helvetica,verdana,arial,sans-serif;
}
+div#overlay{
+background-image:url(../images/community/bkg_gradient.gif);
+background-repeat:repeat-x;
+width:100%;
+height:100%;
+position:absolute;
+top:0px;
+left:0px;
+z-index:-1;
+}
+*/
+
+
+body {
+background-image:url(../images/richfaces_label2.png);
+background-repeat:no-repeat;
+background-attachment:fixed;
+background-position:top left;
+z-index:1;
+color:#333333;
+font-family:'Lucida Grande',Geneva,Verdana,Arial,sans-serif;
+font-size:12px;
+line-height:150%;
+max-width:1000px;
+padding:0em 2em;
+text-align:center;
+}
+
+div#overlay{
+background-image:url(../images/community/bkg_gradient.gif);
+background-repeat:repeat-x;
+width:100%;
+height:100%;
+position:absolute;
+top:0px;
+left:0px;
+z-index:-1;
+}
+
div.book, div.chapter, #title{
text-align:justify;
width: 70em;
Modified: trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/css/tools.css
===================================================================
--- trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/css/tools.css 2008-08-29 11:54:52 UTC (rev 9960)
+++ trunk/documentation/jbosstools-jdocbook-style/src/main/org/css/css/tools.css 2008-08-29 12:14:31 UTC (rev 9961)
@@ -2,14 +2,59 @@
/* -----Override jbossorg.css----- */
-body {
+/* body {
background-image:url(../images/community/bkg_gradient.gif);
background-repeat:repeat-x;
+background-image:url(../images/richfaces_label2.png);
+background-repeat:no-repeat;
+background-attachment:fixed;
+background-position:top left;
+z-index:1;
+
text-align:center;
margin:0 auto;
padding:0;
}
+div#overlay{
+background-image:url(../images/community/bkg_gradient.gif);
+background-repeat:repeat-x;
+width:100%;
+height:100%;
+position:absolute;
+top:0px;
+left:0px;
+z-index:-1;
+}
+*/
+
+
+body {
+background-image:url(../images/richfaces_label2.png);
+background-repeat:no-repeat;
+background-attachment:fixed;
+background-position:top left;
+z-index:1;
+color:#333333;
+font-family:'Lucida Grande',Geneva,Verdana,Arial,sans-serif;
+font-size:12px;
+line-height:150%;
+max-width:1000px;
+padding:0em 2em;
+text-align:center;
+}
+
+div#overlay{
+background-image:url(../images/community/bkg_gradient.gif);
+background-repeat:repeat-x;
+width:100%;
+height:100%;
+position:absolute;
+top:0px;
+left:0px;
+z-index:-1;
+}
+
div.book{
font-family:'Lucida Grande', Geneva, Verdana, Arial, sans-serif;
font-size:12px;
16 years, 3 months