JBoss Tools SVN: r38398 - in trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons: esb and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: bfitzpat
Date: 2012-02-02 12:39:09 -0500 (Thu, 02 Feb 2012)
New Revision: 38398
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/action.gif
trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/action_list.gif
trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/bus.gif
trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/config.gif
trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/esb_file.gif
trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/filter.gif
trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/from.gif
trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/listener.gif
trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/new_esb_file.gif
trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/objectpath.gif
trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/property.gif
trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/provider.gif
trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/schedule.gif
trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/service.gif
Log:
[JBIDE-10726] Cleanup after moving the ESB visualizer into the project.ui project
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/action.gif
===================================================================
(Binary files differ)
Property changes on: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/action.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/action_list.gif
===================================================================
(Binary files differ)
Property changes on: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/action_list.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/bus.gif
===================================================================
(Binary files differ)
Property changes on: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/bus.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/config.gif
===================================================================
(Binary files differ)
Property changes on: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/config.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/esb_file.gif
===================================================================
(Binary files differ)
Property changes on: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/esb_file.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/filter.gif
===================================================================
(Binary files differ)
Property changes on: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/filter.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/from.gif
===================================================================
(Binary files differ)
Property changes on: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/from.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/listener.gif
===================================================================
(Binary files differ)
Property changes on: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/listener.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/new_esb_file.gif
===================================================================
(Binary files differ)
Property changes on: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/new_esb_file.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/objectpath.gif
===================================================================
(Binary files differ)
Property changes on: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/objectpath.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/property.gif
===================================================================
(Binary files differ)
Property changes on: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/property.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/provider.gif
===================================================================
(Binary files differ)
Property changes on: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/provider.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/schedule.gif
===================================================================
(Binary files differ)
Property changes on: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/schedule.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/service.gif
===================================================================
(Binary files differ)
Property changes on: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/esb/service.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
12 years, 11 months
JBoss Tools SVN: r38397 - in trunk/esb/plugins/org.jboss.tools.esb.project.ui: META-INF and 4 other directories.
by jbosstools-commits@lists.jboss.org
Author: bfitzpat
Date: 2012-02-02 12:33:19 -0500 (Thu, 02 Feb 2012)
New Revision: 38397
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/horizontalTreeLayout.gif
trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/radialLayout.gif
trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/refresh.gif
trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/verticalTreeLayout.gif
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ESBDomParser.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ESBNode.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ESBNodeWithChildren.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ESBVisualizerView.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/FileSelectionGroup.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ViewerFileFilter.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/WorkbenchFileSelectionDialog.java
Modified:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/META-INF/MANIFEST.MF
trunk/esb/plugins/org.jboss.tools.esb.project.ui/plugin.properties
trunk/esb/plugins/org.jboss.tools.esb.project.ui/plugin.xml
trunk/esb/plugins/org.jboss.tools.esb.project.ui/pom.xml
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/ESBProjectPlugin.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/messages/JBossESBUI.properties
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/messages/JBossESBUIMessages.java
Log:
[JBIDE-10726] Moving the ESB visualizer into the project.ui project
Modified: trunk/esb/plugins/org.jboss.tools.esb.project.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/META-INF/MANIFEST.MF 2012-02-02 15:31:46 UTC (rev 38396)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/META-INF/MANIFEST.MF 2012-02-02 17:33:19 UTC (rev 38397)
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name.0
Bundle-SymbolicName: org.jboss.tools.esb.project.ui;singleton:=true
-Bundle-Version: 1.5.1.qualifier
+Bundle-Version: 1.5.2.qualifier
Bundle-Activator: org.jboss.tools.esb.project.ui.ESBProjectPlugin
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
@@ -36,7 +36,9 @@
org.jboss.ide.eclipse.as.ui;bundle-version="1.0.0",
org.jboss.ide.eclipse.as.wtp.core;bundle-version="1.0.0",
org.jboss.ide.eclipse.as.core;bundle-version="1.0.0",
- org.jboss.tools.common.ui;bundle-version="3.1.0"
+ org.jboss.tools.common.ui;bundle-version="3.1.0",
+ org.eclipse.zest.core,
+ org.eclipse.zest.layouts
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %Bundle-Vendor.0
Eclipse-RegisterBuddy: org.eclipse.jst.ws.annotations.core
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/horizontalTreeLayout.gif
===================================================================
(Binary files differ)
Property changes on: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/horizontalTreeLayout.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/radialLayout.gif
===================================================================
(Binary files differ)
Property changes on: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/radialLayout.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/refresh.gif
===================================================================
(Binary files differ)
Property changes on: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/refresh.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/verticalTreeLayout.gif
===================================================================
(Binary files differ)
Property changes on: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/verticalTreeLayout.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/esb/plugins/org.jboss.tools.esb.project.ui/plugin.properties
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/plugin.properties 2012-02-02 15:31:46 UTC (rev 38396)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/plugin.properties 2012-02-02 17:33:19 UTC (rev 38397)
@@ -3,4 +3,12 @@
Preference_Page_Runtimes=JBoss ESB Runtimes
Bundle-Vendor.0 = JBoss by Red Hat
Bundle-Name.0 = JBoss ESB Project UI Plugin
-annotations-category = JBoss ESB
\ No newline at end of file
+annotations-category = JBoss ESB
+esb.project.wizard.name = ESB Project
+esb.file.decorator.label = JBoss ESB Project Decorator
+esb.file.classpathContainerPage.name = JBoss ESB Libraries
+esb.file.category.name = ESB
+esb.file.wizard.name = ESB File
+esb.file.wizard.description = ESB File
+visualizer.view.category = JBoss ESB
+visualizer.view.name = JBoss ESB Configuration Visualizer
\ No newline at end of file
Modified: trunk/esb/plugins/org.jboss.tools.esb.project.ui/plugin.xml
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/plugin.xml 2012-02-02 15:31:46 UTC (rev 38396)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/plugin.xml 2012-02-02 17:33:19 UTC (rev 38397)
@@ -8,7 +8,7 @@
class="org.jboss.tools.esb.project.ui.wizards.ESBProjectWizard"
icon="$nl$/icons/wizards/esb.gif"
id="JBoss.ESB.Project.Wizard"
- name="ESB Project"
+ name="%esb.project.wizard.name"
project="true">
</wizard>
</extension>
@@ -52,7 +52,7 @@
<decorator
class="org.jboss.tools.esb.project.ui.ESBProjectDecorator"
id="org.jboss.tools.esb.project.ui.decorator"
- label="JBoss ESB Project Decorator"
+ label="%esb.file.decorator.label"
lightweight="true"
location="TOP_LEFT"
state="true">
@@ -73,7 +73,7 @@
<classpathContainerPage
class="org.jboss.tools.esb.project.ui.wizards.pages.JBossESBRuntimeContainerPage"
id="org.jboss.esb.runtime.classpath"
- name="JBoss ESB Libraries">
+ name="%esb.file.classpathContainerPage.name">
</classpathContainerPage>
</extension>
@@ -81,17 +81,17 @@
<extension
point="org.eclipse.ui.exportWizards">
<category
- name="ESB"
+ name="%esb.file.category.name"
id="org.jboss.tools.esb.category">
</category>
<wizard
- name="ESB File"
+ name="%esb.file.wizard.name"
icon="icons/obj16/esb_module.gif"
class="org.jboss.tools.esb.project.ui.wizards.export.ESBComponentExportWizard"
category="org.jboss.tools.esb.category"
id="org.jboss.tools.esb.project.ui.wizards.temp.ESBExportWizard">
<description>
- ESB File
+ %esb.file.wizard.description
</description>
<selection
class="org.eclipse.core.resources.IResource">
@@ -154,5 +154,41 @@
name="AttachmentParam">
</annotation>
</extension>
+ <extension
+ point="org.eclipse.ui.views">
+ <category
+ id="org.jboss.tools.esb.visualizer"
+ name="%visualizer.view.category">
+ </category>
+ <view
+ allowMultiple="false"
+ category="org.jboss.tools.esb.visualizer"
+ class="org.jboss.tools.esb.project.ui.visualizer.ESBVisualizerView"
+ icon="icons/esb/esb_file.gif"
+ id="org.jboss.tools.esb.visualizer.views.ESBVisualizerView"
+ name="%visualizer.view.name">
+ </view>
+ </extension>
+ <extension
+ point="org.eclipse.ui.perspectiveExtensions">
+ <perspectiveExtension
+ targetID="org.eclipse.ui.resourcePerspective">
+ <showInPart
+ id="org.jboss.tools.esb.visualizer.views.ESBVisualizerView">
+ </showInPart>
+ </perspectiveExtension>
+ <perspectiveExtension
+ targetID="org.eclipse.jst.j2ee.J2EEPerspective">
+ <showInPart
+ id="org.jboss.tools.esb.visualizer.views.ESBVisualizerView">
+ </showInPart>
+ </perspectiveExtension>
+ <perspectiveExtension
+ targetID="org.jboss.tools.common.ui.JBossPerspective">
+ <showInPart
+ id="org.jboss.tools.esb.visualizer.views.ESBVisualizerView">
+ </showInPart>
+ </perspectiveExtension>
+ </extension>
</plugin>
Modified: trunk/esb/plugins/org.jboss.tools.esb.project.ui/pom.xml
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/pom.xml 2012-02-02 15:31:46 UTC (rev 38396)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/pom.xml 2012-02-02 17:33:19 UTC (rev 38397)
@@ -9,7 +9,7 @@
</parent>
<groupId>org.jboss.tools.esb.plugins</groupId>
<artifactId>org.jboss.tools.esb.project.ui</artifactId>
- <version>1.5.1-SNAPSHOT</version>
+ <version>1.5.2-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
Modified: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/ESBProjectPlugin.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/ESBProjectPlugin.java 2012-02-02 15:31:46 UTC (rev 38396)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/ESBProjectPlugin.java 2012-02-02 17:33:19 UTC (rev 38397)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.esb.project.ui;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -60,4 +62,22 @@
return plugin;
}
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+
+ /**
+ * Log a message
+ * @param ex
+ */
+ public static void log(Throwable ex) {
+ plugin.getLog().log(new Status(Status.ERROR, PLUGIN_ID, Status.OK, "No message", ex));
+ }
}
Modified: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/messages/JBossESBUI.properties
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/messages/JBossESBUI.properties 2012-02-02 15:31:46 UTC (rev 38396)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/messages/JBossESBUI.properties 2012-02-02 17:33:19 UTC (rev 38397)
@@ -51,6 +51,8 @@
JBossRuntimeListFieldEditor_ErrorMessageAtLeastOneJar=The library must contain at least one jar.
+ESBDomParser_Providers_Label=Providers
+ESBDomParser_Services_Label=Services
ESBFacetInstallationPage_Button_Text_New=New
ESBFacetInstallationPage_Default_SRC_Folder=src
ESBFacetInstallationPage_Description=Configure project structure and classpath
@@ -78,4 +80,14 @@
ESBExportWizard_NotValidProject=Project "{0}" is not a valid ESB Project
ESBExportWizard_Title=ESB Export
ESBExportWizard_Description=Export an ESB project to the local file system.
-ESBExportWizard_ESBProject=ESB Project\:
\ No newline at end of file
+ESBExportWizard_ESBProject=ESB Project\:
+ESBVisualizerView_Change_Layout_Action_Label=Change Layout
+ESBVisualizerView_EmptyNodeLabel=Select an ESB Configuration file in the navigator\n or use the 'Open JBoss ESB Configuration' view menu\n to show a configuration graphically.
+ESBVisualizerView_Open_ESB_Config_Action_Label=Open ESB Configuration
+ESBVisualizerView_Open_ESB_Config_Dialog_Field_Text=Select ESB file:
+ESBVisualizerView_Open_ESB_Config_Dialog_Title=Open ESB Configuration
+ESBVisualizerView_Refresh_Layout_Action_Label=Refresh Layout
+ESBVisualizerView_Select_ESB_File_Warning=Please select an ESB configuration file.
+ESBVisualizerView_Use_Horizontal_Tree_Layout_Action_Label=Use Horizontal Tree Layout
+ESBVisualizerView_Use_Radial_Layout_Action_Label=Use Radial Layout
+ESBVisualizerView_Use_Vertical_Tree_Layout_Action_Label=Use Vertical Tree Layout
Modified: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/messages/JBossESBUIMessages.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/messages/JBossESBUIMessages.java 2012-02-02 15:31:46 UTC (rev 38396)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/messages/JBossESBUIMessages.java 2012-02-02 17:33:19 UTC (rev 38397)
@@ -55,6 +55,10 @@
public static String JBoss_ESBRuntime_Classpath_Container_5;
public static String JBoss_Runtime_List_Field_Editor_Configuration;
+ public static String ESBDomParser_Providers_Label;
+
+ public static String ESBDomParser_Services_Label;
+
public static String ESBRuntimeContainerPage_Button_Text;
public static String JBoss_ESBRuntime_Classpath_Container_Description;
@@ -137,6 +141,27 @@
public static String ESBExportWizard_ESBProject;
+ public static String ESBVisualizerView_Change_Layout_Action_Label;
+
+ public static String ESBVisualizerView_EmptyNodeLabel;
+
+ public static String ESBVisualizerView_Open_ESB_Config_Action_Label;
+
+ public static String ESBVisualizerView_Open_ESB_Config_Dialog_Field_Text;
+
+ public static String ESBVisualizerView_Open_ESB_Config_Dialog_Title;
+
+ public static String ESBVisualizerView_Refresh_Layout_Action_Label;
+
+ public static String ESBVisualizerView_Select_ESB_File_Warning;
+
+ public static String ESBVisualizerView_Use_Horizontal_Tree_Layout_Action_Label;
+
+ public static String ESBVisualizerView_Use_Radial_Layout_Action_Label;
+
+ public static String ESBVisualizerView_Use_Vertical_Tree_Layout_Action_Label;
+
+
static {
NLS.initializeMessages(BUNDLE_NAME, JBossESBUIMessages.class);
}
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ESBDomParser.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ESBDomParser.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ESBDomParser.java 2012-02-02 17:33:19 UTC (rev 38397)
@@ -0,0 +1,237 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.esb.project.ui.visualizer;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Collections;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.jboss.tools.esb.project.ui.ESBProjectPlugin;
+import org.jboss.tools.esb.project.ui.messages.JBossESBUIMessages;
+import org.jboss.tools.esb.project.ui.visualizer.ESBNode.ESBType;
+import org.osgi.framework.Bundle;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * Take an incoming jboss-esb config file and parse it into nodes for the graphical view
+ * @author bfitzpat
+ *
+ */
+public class ESBDomParser {
+
+ Document dom;
+ ESBNodeWithChildren root;
+
+ /**
+ * Utility method to verify that a file is an ESB config
+ * @param filepath
+ * @return
+ */
+ public boolean isFileESBConfig ( String filepath ) {
+ //get the factory
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+
+ try {
+
+ //Using factory get an instance of document builder
+ DocumentBuilder db = dbf.newDocumentBuilder();
+
+ //parse using builder to get DOM representation of the XML file
+ dom = db.parse(filepath);
+
+ dom.getDocumentElement().normalize();
+
+ if (dom.getDocumentElement().getTagName().equalsIgnoreCase("jbossesb")) { //$NON-NLS-1$
+ return true;
+ }
+ }catch(ParserConfigurationException pce) {
+ pce.printStackTrace();
+ }catch(SAXException se) {
+ se.printStackTrace();
+ }catch(IOException ioe) {
+ ioe.printStackTrace();
+ }
+
+ return false;
+ }
+
+ /**
+ * Parse the file into the nodes
+ * @param filepath
+ */
+ public void parseXmlFile(String filepath){
+
+ root = new ESBNodeWithChildren("Invisible Root"); //$NON-NLS-1$
+
+ //get the factory
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+
+ try {
+
+ //Using factory get an instance of document builder
+ DocumentBuilder db = dbf.newDocumentBuilder();
+
+ try {
+ if (filepath == null) {
+ Bundle bundle = ESBProjectPlugin.getDefault().getBundle();
+ IPath path = new Path("META-INF/jboss-esb.xml"); //$NON-NLS-1$
+ URL setupUrl = FileLocator.find(bundle, path, Collections.EMPTY_MAP);
+ File setupFile = new File(FileLocator.toFileURL(setupUrl).toURI());
+ if (setupFile.exists() && setupFile.canRead())
+ filepath = setupFile.getAbsolutePath();
+ else
+ return;
+ }
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ }
+
+ //parse using builder to get DOM representation of the XML file
+ dom = db.parse(filepath);
+ dom.getDocumentElement().normalize();
+ root.setName(dom.getDocumentElement().getTagName());
+ root.setEsbObjectType(ESBType.ESB);
+
+ parseDocument();
+
+ }catch(ParserConfigurationException pce) {
+ pce.printStackTrace();
+ }catch(SAXException se) {
+ se.printStackTrace();
+ }catch(IOException ioe) {
+ ioe.printStackTrace();
+ }
+ }
+
+ /*
+ * Work through the configuration
+ */
+ private void parseDocument(){
+ //get the root elememt
+ Element docEle = dom.getDocumentElement();
+
+ //get a nodelist of <providers> elements
+ NodeList nl = docEle.getElementsByTagName("providers"); //$NON-NLS-1$
+ if(nl != null && nl.getLength() > 0) {
+ Element providersElement= null;
+ for (int j = 0; j < nl.getLength(); j++) {
+ if (nl.item(j) instanceof Element) {
+ providersElement = (Element) nl.item(j);
+ break;
+ }
+ }
+ if(providersElement != null) {
+ ESBNodeWithChildren providersRoot = new ESBNodeWithChildren(JBossESBUIMessages.ESBDomParser_Providers_Label);
+ providersRoot.setEsbObjectType(ESBNode.ESBType.PROVIDER);
+ processChildren(providersRoot, providersElement);
+ root.addChild(providersRoot);
+ }
+ }
+
+ //get a nodelist of <services> elements
+ NodeList nl2 = docEle.getElementsByTagName("services"); //$NON-NLS-1$
+ if(nl2 != null && nl2.getLength() > 0) {
+ Element servicesElement= null;
+ for (int j = 0; j < nl2.getLength(); j++) {
+ if (nl2.item(j) instanceof Element) {
+ servicesElement = (Element) nl2.item(j);
+ break;
+ }
+ }
+ if(servicesElement != null) {
+ ESBNodeWithChildren servicesRoot = new ESBNodeWithChildren(JBossESBUIMessages.ESBDomParser_Services_Label);
+ servicesRoot.setEsbObjectType(ESBNode.ESBType.SERVICE);
+ processChildren(servicesRoot, servicesElement);
+ root.addChild(servicesRoot);
+ }
+ }
+ }
+
+ /*
+ * Work down the children tree
+ * @param parent
+ * @param el
+ */
+ private void processChildren ( ESBNodeWithChildren parent, Element el ) {
+ el.normalize();
+ parent.setData(el);
+
+ if (parent.getEsbObjectType() == null) {
+ String tag = el.getTagName();
+ if (tag.endsWith("-bus") && el.getAttribute("busid") != null) { //$NON-NLS-1$ //$NON-NLS-2$
+ parent.setEsbObjectType(ESBType.BUS);
+ } else if (tag.endsWith("-listener") && el.getAttribute("busidref") != null) { //$NON-NLS-1$ //$NON-NLS-2$
+ parent.setEsbObjectType(ESBType.LISTENER);
+ } else if (tag.endsWith("-provider")) { //$NON-NLS-1$
+ parent.setEsbObjectType(ESBType.PROVIDER);
+ } else if (tag.equalsIgnoreCase("service")) { //$NON-NLS-1$
+ parent.setEsbObjectType(ESBType.SERVICE);
+ } else if (tag.equalsIgnoreCase("listeners")) { //$NON-NLS-1$
+ parent.setEsbObjectType(ESBType.LISTENER);
+ } else if (tag.equalsIgnoreCase("actions")) { //$NON-NLS-1$
+ parent.setEsbObjectType(ESBType.ACTION);
+ } else if (tag.equalsIgnoreCase("action")) { //$NON-NLS-1$
+ parent.setEsbObjectType(ESBType.ACTION);
+ } else if (tag.equalsIgnoreCase("property")) { //$NON-NLS-1$
+ parent.setEsbObjectType(ESBType.PROPERTY);
+ return;
+ }
+ }
+ NodeList children = el.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ if (children.item(i) instanceof Element) {
+ Element child = (Element) children.item(i);
+ String name = child.getAttribute("name"); //$NON-NLS-1$
+ if (name == null || name.trim().length() == 0) {
+ name = child.getAttribute("busid"); //$NON-NLS-1$
+ }
+ if (name == null || name.trim().length() == 0) {
+ name = child.getAttribute("dest-name"); //$NON-NLS-1$
+ }
+ if (name == null || name.trim().length() == 0) {
+ name = child.getTagName();
+ }
+
+ ESBNodeWithChildren childNode = new ESBNodeWithChildren(name);
+ String ref = child.getAttribute("busidref"); //$NON-NLS-1$
+ if (ref != null && ref.trim().length() > 0) {
+ childNode.setRef(ref);
+ }
+ processChildren(childNode, child);
+ if (childNode.getEsbObjectType() != null && !childNode.getEsbObjectType().equals(ESBType.PROPERTY)) {
+ parent.addChild(childNode);
+ childNode.setEsbObjectType(parent.getEsbObjectType());
+ }
+ }
+ }
+ }
+
+ /**
+ * Return the actual root
+ * @return
+ */
+ public ESBNodeWithChildren getRoot() {
+ return this.root;
+ }
+
+}
Property changes on: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ESBDomParser.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ESBNode.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ESBNode.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ESBNode.java 2012-02-02 17:33:19 UTC (rev 38397)
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.esb.project.ui.visualizer;
+
+import org.eclipse.core.runtime.IAdaptable;
+
+/**
+ * Simple container node
+ * @author bfitzpat
+ *
+ */
+public class ESBNode implements IAdaptable {
+
+ private String name;
+ private ESBNodeWithChildren parent;
+ private String ref;
+ private boolean isLockedFlag = false;
+ private ESBType esbObjectType;
+ private Object data;
+
+ /**
+ * Enumerated list of node types
+ * @author bfitzpat
+ */
+ public enum ESBType {
+ ACTION, BUS, LISTENER, PROVIDER,
+ ESB, PROPERTY, SERVICE
+ }
+
+ /**
+ * Constructor
+ * @param name
+ */
+ public ESBNode(String name) {
+ this.name = name;
+ }
+ /**
+ * Get the name (basic string)
+ * @return
+ */
+ public String getName() {
+ return name;
+ }
+ /**
+ * Set the name (basic string)
+ * @param newName
+ */
+ public void setName(String newName) {
+ this.name = newName;
+ }
+ /**
+ * Add the parent node so we can claw back up the chain
+ * @param parent
+ */
+ public void setParent(ESBNodeWithChildren parent) {
+ this.parent = parent;
+ }
+ /**
+ * Get the parent node
+ * @return
+ */
+ public ESBNodeWithChildren getParent() {
+ return parent;
+ }
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return getName();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ */
+ @SuppressWarnings("rawtypes")
+ public Object getAdapter(Class key) {
+ return null;
+ }
+ /**
+ * Get the referenced node
+ * @return
+ */
+ public String getRef() {
+ return ref;
+ }
+ /**
+ * Set the referenced node
+ * @param ref
+ */
+ public void setRef(String ref) {
+ this.ref = ref;
+ }
+ /**
+ * Is this node locked for movement?
+ * @return
+ */
+ protected boolean isMovementLocked() {
+ return isLockedFlag;
+ }
+ /**
+ * Set the "isLocked" flag
+ * @param isLocked
+ */
+ protected void setIsMovementLocked(boolean isLocked) {
+ this.isLockedFlag = isLocked;
+ }
+ /**
+ * Get the node type
+ * @return
+ */
+ protected ESBType getEsbObjectType() {
+ return esbObjectType;
+ }
+ /**
+ * @param esbObjectType
+ */
+ protected void setEsbObjectType(ESBType esbObjectType) {
+ this.esbObjectType = esbObjectType;
+ }
+ /**
+ * Return the stashed Java object
+ * @return
+ */
+ protected Object getData() {
+ return data;
+ }
+ /**
+ * Stash a java object
+ * @param data
+ */
+ protected void setData(Object data) {
+ this.data = data;
+ }
+}
\ No newline at end of file
Property changes on: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ESBNode.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ESBNodeWithChildren.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ESBNodeWithChildren.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ESBNodeWithChildren.java 2012-02-02 17:33:19 UTC (rev 38397)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.esb.project.ui.visualizer;
+
+import java.util.ArrayList;
+
+/**
+ * Extend the base node so it can track a list of children
+ * @author bfitzpat
+ */
+public class ESBNodeWithChildren extends ESBNode {
+
+ private ArrayList<ESBNode> children;
+ /**
+ * Constructor
+ * @param name
+ */
+ public ESBNodeWithChildren(String name) {
+ super(name);
+ children = new ArrayList<ESBNode>();
+ }
+ /**
+ * Add a child to the child list
+ * @param child
+ */
+ public void addChild(ESBNode child) {
+ children.add(child);
+ child.setParent(this);
+ }
+ /**
+ * Remove a child from the child list
+ * @param child
+ */
+ public void removeChild(ESBNode child) {
+ children.remove(child);
+ child.setParent(null);
+ }
+ /**
+ * Get the list of children
+ * @return
+ */
+ public ESBNode [] getChildren() {
+ return (ESBNode [])children.toArray(new ESBNode[children.size()]);
+ }
+ /**
+ * Does the node have children?
+ * @return
+ */
+ public boolean hasChildren() {
+ return children.size()>0;
+ }
+}
Property changes on: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ESBNodeWithChildren.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ESBVisualizerView.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ESBVisualizerView.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ESBVisualizerView.java 2012-02-02 17:33:19 UTC (rev 38397)
@@ -0,0 +1,590 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.esb.project.ui.visualizer;
+
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.dialogs.ISelectionValidator;
+import org.eclipse.ui.part.IShowInTarget;
+import org.eclipse.ui.part.ShowInContext;
+import org.eclipse.ui.part.ViewPart;
+import org.eclipse.zest.core.viewers.AbstractZoomableViewer;
+import org.eclipse.zest.core.viewers.GraphViewer;
+import org.eclipse.zest.core.viewers.IZoomableWorkbenchPart;
+import org.eclipse.zest.core.viewers.ZoomContributionViewItem;
+import org.eclipse.zest.core.widgets.ConstraintAdapter;
+import org.eclipse.zest.core.widgets.Graph;
+import org.eclipse.zest.core.widgets.GraphConnection;
+import org.eclipse.zest.core.widgets.GraphNode;
+import org.eclipse.zest.core.widgets.ZestStyles;
+import org.eclipse.zest.layouts.LayoutAlgorithm;
+import org.eclipse.zest.layouts.LayoutStyles;
+import org.eclipse.zest.layouts.algorithms.HorizontalTreeLayoutAlgorithm;
+import org.eclipse.zest.layouts.algorithms.RadialLayoutAlgorithm;
+import org.eclipse.zest.layouts.algorithms.TreeLayoutAlgorithm;
+import org.eclipse.zest.layouts.constraints.BasicEntityConstraint;
+import org.eclipse.zest.layouts.constraints.LayoutConstraint;
+import org.jboss.tools.esb.project.ui.ESBProjectPlugin;
+import org.jboss.tools.esb.project.ui.messages.JBossESBUIMessages;
+import org.jboss.tools.esb.project.ui.visualizer.ESBNode.ESBType;
+
+/**
+ * This class serves as a simple read-only way to visualize an ESB configuration
+ * graphically.
+ *
+ * @author bfitzpat
+ *
+ */
+public class ESBVisualizerView extends ViewPart implements IZoomableWorkbenchPart, IShowInTarget {
+
+ /**
+ * The ID of the view as specified by the extension.
+ */
+ public static final String ID = "org.jboss.tools.esb.visualizer.views.ESBVisualizerView";//$NON-NLS-1$
+
+ private static final String ACTION_ICON_TAG = "/icons/esb/action.gif";//$NON-NLS-1$
+ private static final String SERVICE_ICON_TAG = "/icons/esb/service.gif";//$NON-NLS-1$
+ private static final String PROVIDER_ICON_TAG = "/icons/esb/provider.gif";//$NON-NLS-1$
+ private static final String BUS_ICON_TAG = "/icons/esb/bus.gif";//$NON-NLS-1$
+ private static final String PROPERTY_ICON_TAG = "/icons/esb/property.gif";//$NON-NLS-1$
+ private static final String LISTENER_ICON_TAG = "/icons/esb/listener.gif";//$NON-NLS-1$
+ private static final String ESB_FILE_ICON_TAG = "/icons/esb/esb_file.gif";//$NON-NLS-1$
+ private static final String REFRESH_ICON_TAG = "/icons/refresh.gif";//$NON-NLS-1$
+ private static final String HORIZONTAL_TREE_LAYOUT_ICON_TAG = "/icons/horizontalTreeLayout.gif";//$NON-NLS-1$
+ private static final String VERTICAL_TREE_LAYOUT_ICON_TAG = "/icons/verticalTreeLayout.gif";//$NON-NLS-1$
+ private static final String RADIAL_LAYOUT_ICON_TAG = "/icons/radialLayout.gif";//$NON-NLS-1$
+
+ private GraphViewer gv;
+
+ // Some stashed colors
+ private Color defaultBorder;
+
+ // menu items
+ private Action openESBFileAction;
+
+ // toolbar buttons for different layouts
+ private IAction horizontalLayoutAction;
+ private IAction verticalLayoutAction;
+ private IAction radialLayoutAction;
+ private Action refreshLayoutAction;
+
+ // the listener we register with the selection service
+ private ISelectionListener listener = new ISelectionListener() {
+ public void selectionChanged(IWorkbenchPart sourcepart, ISelection selection) {
+ // we ignore our own selections
+ if (sourcepart != ESBVisualizerView.this) {
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection ssel = (IStructuredSelection) selection;
+ if (ssel.getFirstElement() instanceof IFile) {
+ IFile selectedFile = (IFile) ssel.getFirstElement();
+ String path = selectedFile.getLocation().toOSString();
+ ESBDomParser parser = new ESBDomParser();
+ if (parser.isFileESBConfig(path)) {
+ if (!gv.getGraphControl().isDisposed()) {
+ visualizeESB(path);
+ refreshLayoutAction.run();
+ }
+ }
+ }
+ }
+ }
+ }
+ };
+
+ /**
+ * The constructor.
+ */
+ public ESBVisualizerView() {
+ // empty
+ }
+
+ /**
+ * This is a callback that will allow us
+ * to create the viewer and initialize it.
+ */
+ public void createPartControl(Composite parent) {
+ this.gv = new GraphViewer(parent, SWT.NONE);
+ gv.getGraphControl().addConstraintAdapter(new ESBViewerConstraintAdapter());
+ gv.addDoubleClickListener(new FixNodeDoubleClickListener());
+ makeActions();
+ hookContextMenu();
+ fillToolBar();
+// visualizeESB(null);
+ setEmptyGraph();
+ horizontalLayoutAction.setChecked(true);
+ horizontalLayoutAction.run();
+ getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(listener);
+ }
+
+ /*
+ * Clear all the graph nodes and connections
+ */
+ private void clearGraph() {
+ while (gv.getGraphControl().getNodes().size() > 0) {
+ GraphNode node = (GraphNode) gv.getGraphControl().getNodes().remove(0);
+ node.dispose();
+ }
+ while (gv.getGraphControl().getConnections().size() > 0) {
+ GraphConnection node = (GraphConnection) gv.getGraphControl().getConnections().remove(0);
+ node.dispose();
+ }
+ }
+
+ /*
+ * Clear the graph and add a default node
+ */
+ private void setEmptyGraph() {
+ clearGraph();
+ new GraphNode (gv.getGraphControl(), ZestStyles.NODES_CACHE_LABEL,
+ JBossESBUIMessages.ESBVisualizerView_EmptyNodeLabel);
+// refreshLayoutAction.run();
+ }
+
+ /**
+ * Import the esb XML file and render nodes and connections
+ * @param filepath
+ */
+ public void visualizeESB ( String filepath ) {
+ ESBDomParser parser = new ESBDomParser();
+ parser.parseXmlFile(filepath);
+ clearGraph();
+ ESBNodeWithChildren root = parser.getRoot();
+ root.setEsbObjectType(ESBType.ESB);
+ GraphNode rootnode = new GraphNode(gv.getGraphControl(),
+ ZestStyles.NODES_CACHE_LABEL,
+ root.getName());
+ rootnode.setImage(getImageFromPlugin("/icons/esb/esb_file.gif")); //$NON-NLS-1$
+ this.defaultBorder = rootnode.getBorderColor();
+ rootnode.setData(root);
+ drawNodes(rootnode, root);
+ drawRefs(rootnode);
+ if (horizontalLayoutAction.isChecked()) {
+ horizontalLayoutAction.run();
+ } else if (verticalLayoutAction.isChecked()) {
+ verticalLayoutAction.run();
+ } else if (radialLayoutAction.isChecked()) {
+ radialLayoutAction.run();
+ }
+ }
+
+ /*
+ * Simple image management
+ * @param path
+ * @return
+ */
+ private Image getImageFromPlugin( String path ) {
+ if (ESBProjectPlugin.getDefault().getImageRegistry().get(path) == null) {
+ ImageDescriptor descriptor = ESBProjectPlugin.getImageDescriptor(path);
+ if (descriptor != null) {
+ ESBProjectPlugin.getDefault().getImageRegistry().put(path, descriptor);
+ return ESBProjectPlugin.getDefault().getImageRegistry().get(path);
+ }
+ }
+ return ESBProjectPlugin.getDefault().getImageRegistry().get(path);
+ }
+
+ /*
+ * Actually draw the nodes and connections from the parsed ESB xml file
+ * @param root
+ * @param parent
+ */
+ private void drawNodes ( GraphNode root, ESBNodeWithChildren parent ) {
+ if (parent.hasChildren()) {
+ for (int i = 0; i < parent.getChildren().length; i++) {
+ ESBNodeWithChildren tp = (ESBNodeWithChildren) parent.getChildren()[i];
+ GraphNode p = new GraphNode(gv.getGraphControl(), SWT.NONE, tp.getName());
+ if (tp.getEsbObjectType() != null) {
+ switch (tp.getEsbObjectType()) {
+ case ACTION:
+ p.setImage(getImageFromPlugin(ACTION_ICON_TAG));
+ break;
+ case SERVICE:
+ p.setImage(getImageFromPlugin(SERVICE_ICON_TAG));
+ break;
+ case PROVIDER:
+ p.setImage(getImageFromPlugin(PROVIDER_ICON_TAG));
+ break;
+ case BUS:
+ p.setImage(getImageFromPlugin(BUS_ICON_TAG));
+ break;
+ case PROPERTY:
+ p.setImage(getImageFromPlugin(PROPERTY_ICON_TAG));
+ break;
+ case LISTENER:
+ p.setImage(getImageFromPlugin(LISTENER_ICON_TAG));
+ break;
+ case ESB:
+ p.setImage(getImageFromPlugin(ESB_FILE_ICON_TAG));
+ break;
+ default:
+ break;
+ }
+ }
+ p.setData(tp);
+ drawNodes(p, tp);
+ new GraphConnection(gv.getGraphControl(), ZestStyles.CONNECTIONS_DASH, root, p);
+ }
+ }
+ }
+
+ /*
+ * Draw any references between items
+ * @param root
+ */
+ private void drawRefs ( GraphNode root ) {
+ if (gv.getGraphControl().getGraphModel().getNodes() != null && gv.getGraphControl().getGraphModel().getNodes().size() > 0) {
+ @SuppressWarnings("unchecked")
+ Iterator<GraphNode> nodeIter = gv.getGraphControl().getGraphModel().getNodes().iterator();
+ while (nodeIter.hasNext()) {
+ GraphNode node = nodeIter.next();
+ if (node.getData() != null && node.getData() instanceof ESBNodeWithChildren) {
+ ESBNodeWithChildren tp = (ESBNodeWithChildren) node.getData();
+ if (tp.getRef() != null && tp.getRef().trim().length() > 0) {
+ GraphNode refNode = findNode(tp.getRef(), root);
+ if (refNode != null) {
+ GraphConnection refConnection =
+ new GraphConnection(gv.getGraphControl(), ZestStyles.CONNECTIONS_DIRECTED, node, refNode);
+ refConnection.changeLineColor(gv.getGraphControl().getDisplay().getSystemColor(
+ SWT.COLOR_BLUE));
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /*
+ * Look for a node by name (for reference connections)
+ * @param name
+ * @param root
+ * @return
+ */
+ private GraphNode findNode ( String name, GraphNode root ) {
+ if (name != null && name.trim().length() > 0) {
+ if (gv.getGraphControl().getGraphModel().getNodes() != null && gv.getGraphControl().getGraphModel().getNodes().size() > 0) {
+ @SuppressWarnings("unchecked")
+ Iterator<GraphNode> nodeIter = gv.getGraphControl().getGraphModel().getNodes().iterator();
+ while (nodeIter.hasNext()) {
+ GraphNode node = nodeIter.next();
+ if (node.getText().equalsIgnoreCase(name)) {
+ return node;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Passing the focus request to the viewer's control.
+ */
+ public void setFocus() {
+ gv.getGraphControl().setFocus();
+ }
+
+ /*
+ * Fill the view menu
+ */
+ private void hookContextMenu() {
+ MenuManager menuMgr = new MenuManager("#PopupMenu");//$NON-NLS-1$
+ menuMgr.setRemoveAllWhenShown(true);
+ menuMgr.addMenuListener(new IMenuListener() {
+ public void menuAboutToShow(IMenuManager manager) {
+ ESBVisualizerView.this.fillContextMenu(manager);
+ }
+ });
+ Menu menu = menuMgr.createContextMenu(gv.getGraphControl());
+ gv.getGraphControl().setMenu(menu);
+
+ // if we decide to add a popup menu...
+// getSite().registerContextMenu(menuMgr, );
+ }
+
+ /*
+ * Add any menus
+ * @param manager
+ */
+ private void fillContextMenu(IMenuManager manager) {
+ manager.add(openESBFileAction);
+ }
+
+ /*
+ * Make the few actions we have
+ */
+ private void makeActions() {
+
+ refreshLayoutAction = new Action() {
+ @Override
+ public void run() {
+ if (gv != null && gv.getGraphControl().getLayoutAlgorithm() != null) {
+ gv.setLayoutAlgorithm(gv.getGraphControl().getLayoutAlgorithm(), true);
+ }
+ }
+ };
+
+ refreshLayoutAction.setText(JBossESBUIMessages.ESBVisualizerView_Refresh_Layout_Action_Label);
+ refreshLayoutAction.setToolTipText(JBossESBUIMessages.ESBVisualizerView_Refresh_Layout_Action_Label);
+ refreshLayoutAction.setImageDescriptor(ESBProjectPlugin.getImageDescriptor(REFRESH_ICON_TAG));
+
+ openESBFileAction = new Action() {
+ public void run() {
+
+ WorkbenchFileSelectionDialog dialog = new WorkbenchFileSelectionDialog(
+ ESBVisualizerView.this.getSite().getShell().getShell(),
+ null,
+ JBossESBUIMessages.ESBVisualizerView_Open_ESB_Config_Dialog_Field_Text,
+ ".xml");//$NON-NLS-1$
+ dialog.setTitle(JBossESBUIMessages.ESBVisualizerView_Open_ESB_Config_Dialog_Title);
+ dialog.setImage(getImageFromPlugin(ESB_FILE_ICON_TAG));
+ dialog.setValidator(new ISelectionValidator() {
+
+ public String isValid(Object selection) {
+ if (selection instanceof IPath) {
+ IPath selectedpath = (IPath) selection;
+ IPath totalPath = ResourcesPlugin.getWorkspace().getRoot().getLocation().append(selectedpath);
+ String path = totalPath.toOSString();
+ ESBDomParser parser = new ESBDomParser();
+ if (parser.isFileESBConfig(path)) {
+ return null;
+ }
+ return JBossESBUIMessages.ESBVisualizerView_Select_ESB_File_Warning;
+ } else if (selection == null) {
+ return JBossESBUIMessages.ESBVisualizerView_Select_ESB_File_Warning;
+ }
+ return null;
+ }
+ });
+ int rtn_code = dialog.open();
+
+ if (rtn_code == WorkbenchFileSelectionDialog.OK) {
+ IPath resultPath = dialog.getFullPath();
+ IPath totalPath = ResourcesPlugin.getWorkspace().getRoot().getLocation().append(resultPath);
+ String path = totalPath.toOSString();
+ visualizeESB(path);
+ }
+ }
+ };
+ openESBFileAction.setText(JBossESBUIMessages.ESBVisualizerView_Open_ESB_Config_Action_Label);
+ openESBFileAction.setToolTipText(JBossESBUIMessages.ESBVisualizerView_Open_ESB_Config_Action_Label);
+ openESBFileAction.setImageDescriptor(ESBProjectPlugin.getImageDescriptor(ESB_FILE_ICON_TAG));
+
+ }
+
+ /*
+ * Fill the toolbar with a few buttons
+ */
+ private void fillToolBar() {
+ ZoomContributionViewItem toolbarZoomContributionViewItem = new ZoomContributionViewItem(
+ this);
+ IActionBars bars = getViewSite().getActionBars();
+ bars.getMenuManager().add(openESBFileAction);
+
+ IToolBarManager toolbar = bars.getToolBarManager();
+
+ toolbar.add(refreshLayoutAction);
+
+ horizontalLayoutAction = new LayoutAction(gv, new HorizontalTreeLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING));
+ horizontalLayoutAction.setImageDescriptor(ESBProjectPlugin.getImageDescriptor(HORIZONTAL_TREE_LAYOUT_ICON_TAG));
+ horizontalLayoutAction.setToolTipText(JBossESBUIMessages.ESBVisualizerView_Use_Horizontal_Tree_Layout_Action_Label);
+ horizontalLayoutAction.addPropertyChangeListener(new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equalsIgnoreCase("checked")) {//$NON-NLS-1$
+ Boolean state = (Boolean)event.getNewValue();
+ if (state.equals(Boolean.TRUE)) {
+ verticalLayoutAction.setChecked(false);
+ radialLayoutAction.setChecked(false);
+ } else {
+ if (!verticalLayoutAction.isChecked() &&
+ !radialLayoutAction.isChecked())
+ horizontalLayoutAction.setChecked(true);
+ }
+ }
+ }
+ });
+ toolbar.add(horizontalLayoutAction);
+
+ verticalLayoutAction = new LayoutAction(gv, new TreeLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING));
+ verticalLayoutAction.setImageDescriptor(ESBProjectPlugin.getImageDescriptor(VERTICAL_TREE_LAYOUT_ICON_TAG));
+ verticalLayoutAction.setToolTipText(JBossESBUIMessages.ESBVisualizerView_Use_Vertical_Tree_Layout_Action_Label);
+ verticalLayoutAction.addPropertyChangeListener(new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equalsIgnoreCase("checked")) {//$NON-NLS-1$
+ Boolean state = (Boolean)event.getNewValue();
+ if (state.equals(Boolean.TRUE)) {
+ horizontalLayoutAction.setChecked(false);
+ radialLayoutAction.setChecked(false);
+ } else {
+ if (!horizontalLayoutAction.isChecked() &&
+ !radialLayoutAction.isChecked())
+ verticalLayoutAction.setChecked(true);
+ }
+ }
+ }
+ });
+ toolbar.add(verticalLayoutAction);
+
+ radialLayoutAction = new LayoutAction(gv, new RadialLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING));
+ radialLayoutAction.setImageDescriptor(ESBProjectPlugin.getImageDescriptor(RADIAL_LAYOUT_ICON_TAG));
+ radialLayoutAction.setToolTipText(JBossESBUIMessages.ESBVisualizerView_Use_Radial_Layout_Action_Label);
+ radialLayoutAction.addPropertyChangeListener(new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equalsIgnoreCase("checked")) {//$NON-NLS-1$
+ Boolean state = (Boolean)event.getNewValue();
+ if (state.equals(Boolean.TRUE)) {
+ horizontalLayoutAction.setChecked(false);
+ verticalLayoutAction.setChecked(false);
+ } else {
+ if (!horizontalLayoutAction.isChecked() &&
+ !verticalLayoutAction.isChecked())
+ radialLayoutAction.setChecked(true);
+ }
+ }
+ }
+ });
+ toolbar.add(radialLayoutAction);
+
+ toolbar.add(toolbarZoomContributionViewItem);
+ }
+
+ public AbstractZoomableViewer getZoomableViewer() {
+ return gv;
+ }
+
+ /*
+ * @author bfitzpat
+ * Check to see if the node has been "frozen" and if so, don't move it
+ * when we redo the layout
+ */
+ private class ESBViewerConstraintAdapter implements ConstraintAdapter {
+ public void populateConstraint(Object object, LayoutConstraint constraint) {
+ if (constraint instanceof BasicEntityConstraint) {
+
+ BasicEntityConstraint basicEntityConstraint = (BasicEntityConstraint) constraint;
+ GraphNode graphnode = (GraphNode) object;
+
+ Object data = graphnode.getData();
+ if (data != null && data instanceof ESBNode) {
+ boolean wasMoved = ((ESBNode)data).isMovementLocked();
+ basicEntityConstraint.hasPreferredLocation = wasMoved;
+ }
+ }
+ }
+ }
+
+ /*
+ * @author bfitzpat
+ * If the user double-clicks on a node, "fix" it in place. If they double-
+ * click again, un-"fix" it.
+ */
+ private class FixNodeDoubleClickListener implements IDoubleClickListener {
+ public void doubleClick(DoubleClickEvent e) {
+ if (e.getSource() instanceof GraphViewer) {
+ Graph graph = ((GraphViewer) e.getSource()).getGraphControl();
+ if (!graph.getSelection().isEmpty()) {
+ GraphNode node = (GraphNode) graph.getSelection().get(0);
+ if (node.getData() != null && node.getData() instanceof ESBNode) {
+ ESBNode to = (ESBNode)node.getData();
+ to.setIsMovementLocked(!to.isMovementLocked());
+ if (to.isMovementLocked()) {
+ node.setBorderWidth(3);
+ node.setBorderColor(gv.getGraphControl().getDisplay().getSystemColor(
+ SWT.COLOR_BLUE));
+ } else {
+ node.setBorderWidth(1);
+ node.setBorderColor(defaultBorder);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /*
+ * @author bfitzpat
+ * Handle layout duties
+ */
+ private class LayoutAction extends Action {
+
+ private LayoutAlgorithm[] layouts;
+ private int currentLayout = 0;
+ private GraphViewer gv;
+
+ public LayoutAction(GraphViewer gv, LayoutAlgorithm layout) {
+ super(JBossESBUIMessages.ESBVisualizerView_Change_Layout_Action_Label);
+ this.gv = gv;
+ layouts = new LayoutAlgorithm[1];
+ layouts[0] = layout;
+ }
+
+ @Override
+ public void run() {
+ super.run();
+ int temp = currentLayout + 1;
+ if (temp == layouts.length)
+ temp = 0;
+ currentLayout = temp;
+ if (gv.getGraphControl().getLayoutAlgorithm() == null ||
+ !gv.getGraphControl().getLayoutAlgorithm().equals(layouts[currentLayout]))
+ gv.setLayoutAlgorithm(layouts[currentLayout], true);
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.IShowInTarget#show(org.eclipse.ui.part.ShowInContext)
+ */
+ public boolean show(ShowInContext context) {
+ if (gv == null || context == null)
+ return false;
+ ISelection sel = context.getSelection();
+ if (sel instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection)sel;
+ Object first = ss.getFirstElement();
+ if (first instanceof IFile) {
+ String path = ((IFile)first).getLocation().toOSString();
+ ESBDomParser parser = new ESBDomParser();
+ if (parser.isFileESBConfig(path)) {
+ visualizeESB(path);
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
+ return false;
+ }
+
+
+}
Property changes on: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ESBVisualizerView.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/FileSelectionGroup.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/FileSelectionGroup.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/FileSelectionGroup.java 2012-02-02 17:33:19 UTC (rev 38397)
@@ -0,0 +1,221 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.esb.project.ui.visualizer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.eclipse.ui.part.DrillDownComposite;
+
+public class FileSelectionGroup extends Composite {
+
+ // The listener to notify of events
+ private Listener listener;
+
+ private String message;
+
+ // Last selection made by user
+ private IResource selectedResource;
+
+ // handle on parts
+ private TreeViewer treeViewer;
+
+ // Filters
+ private ViewerFileFilter viewerFileFilter;
+ // private ViewerFileFilterMatcher viewerFileFilterMatcher
+ private String filterPatterns;
+ // sizing constants
+ private static final int SIZING_SELECTION_PANE_HEIGHT = 175;
+ private static final int SIZING_SELECTION_PANE_WIDTH = 200;
+ /**
+ * Creates a new instance of the widget.
+ */
+ public FileSelectionGroup(
+ Composite parent,
+ Listener listener,
+ String message) {
+ this(parent, listener, message, null);
+ }
+ public FileSelectionGroup(
+ Composite parent,
+ Listener listener,
+ String message,
+ String filterPatterns) {
+ super(parent, SWT.NONE);
+
+ this.filterPatterns = filterPatterns;
+ this.listener = listener;
+ this.message = message;
+ this.setFont(parent.getFont());
+
+ createViewerFileFilter();
+ createContents();
+ }
+ public void setFileFilter(String filter) {
+ filterPatterns = filter;
+ createViewerFileFilter();
+ treeViewer.setFilters(new ViewerFilter[] {viewerFileFilter});
+ treeViewer.setInput(ResourcesPlugin.getWorkspace());
+ }
+ /**
+ * Creates ViewerFileFilter using array of objects.
+ */
+ public void createViewerFileFilter() {
+ if (filterPatterns != null) {
+ viewerFileFilter = new ViewerFileFilter(filterPatterns);
+ }
+ }
+ /**
+ * Creates the contents of the composite.
+ */
+ public void createContents() {
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ setLayout(layout);
+ setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ Label label = new Label(this, SWT.WRAP);
+ label.setText(message != null ? message : ""); //$NON-NLS-1$
+ label.setFont(this.getFont());
+
+ createTreeViewer();
+ }
+ /**
+ * Returns a new drill down viewer for this dialog.
+ */
+ protected void createTreeViewer() {
+
+ // Create drill down.
+ DrillDownComposite drillDown = new DrillDownComposite(this, SWT.BORDER);
+ GridData spec =
+ new GridData(
+ GridData.VERTICAL_ALIGN_FILL
+ | GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.GRAB_HORIZONTAL
+ | GridData.GRAB_VERTICAL);
+ spec.widthHint = SIZING_SELECTION_PANE_WIDTH;
+ spec.heightHint = SIZING_SELECTION_PANE_HEIGHT;
+ drillDown.setLayoutData(spec);
+
+ // Create tree viewer inside drill down.
+ treeViewer = new TreeViewer(drillDown, SWT.NONE);
+ drillDown.setChildTree(treeViewer);
+ treeViewer.setContentProvider(new WorkbenchContentProvider());
+ treeViewer.setLabelProvider(new WorkbenchLabelProvider());
+ treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+ resourceSelectionChanged((IResource) selection.getFirstElement());
+ // allow null
+ }
+ });
+ treeViewer.addDoubleClickListener(new IDoubleClickListener() {
+ public void doubleClick(DoubleClickEvent event) {
+ ISelection selection = event.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ Object item = ((IStructuredSelection) selection).getFirstElement();
+ if (treeViewer.getExpandedState(item))
+ treeViewer.collapseToLevel(item, 1);
+ else
+ treeViewer.expandToLevel(item, 1);
+ }
+ }
+ });
+
+ if (viewerFileFilter != null)
+ treeViewer.addFilter(viewerFileFilter);
+ // This has to be done after the viewer has been laid out
+ treeViewer.setInput(ResourcesPlugin.getWorkspace());
+ }
+ /**
+ * Returns the "full path" (i.e. first segment is project name) of the currently selected file.
+ */
+ public IPath getResourceFullPath() {
+ if (selectedResource == null) return null;
+ return selectedResource.getFullPath();
+ }
+
+
+ public IResource getSelectedResource () {
+ return selectedResource;
+ }
+
+
+ /**
+ * Returns the tree viewer.
+ */
+ public TreeViewer getTreeViewer() {
+ return treeViewer;
+ }
+ /**
+ * The file selection has changed in the
+ * tree view. Update the file name field
+ * value and notify all listeners.
+ */
+ public void resourceSelectionChanged(IResource resource) {
+ selectedResource = resource;
+
+ // fire an event so the parent can update its controls
+ if (listener != null) {
+ Event changeEvent = new Event();
+ changeEvent.type = SWT.Selection;
+ changeEvent.widget = this;
+ listener.handleEvent(changeEvent);
+ }
+ }
+ /**
+ * Gives focus to one of the widgets in the group, as determined by the group.
+ */
+ public void setInitialFocus() {
+ treeViewer.getTree().setFocus();
+ }
+ /**
+ * Sets the selected existing file.
+ */
+ public void setSelectedResource(IResource resource) {
+ // https://issues.jboss.org/browse/JBIDE-8738
+ if (resource==null)
+ return;
+ selectedResource = resource;
+
+ //expand to and select the specified file
+ List<IContainer> itemsToExpand = new ArrayList<IContainer>();
+ IContainer parent = resource.getParent();
+ while (parent != null) {
+ itemsToExpand.add(0, parent);
+ parent = parent.getParent();
+ }
+ treeViewer.setExpandedElements(itemsToExpand.toArray());
+ treeViewer.setSelection(new StructuredSelection(resource), true);
+ }
+}
Property changes on: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/FileSelectionGroup.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ViewerFileFilter.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ViewerFileFilter.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ViewerFileFilter.java 2012-02-02 17:33:19 UTC (rev 38397)
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.esb.project.ui.visualizer;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+public class ViewerFileFilter extends ViewerFilter {
+
+ private String[] patterns;
+
+ static String COMMA_SEPARATOR = ","; //$NON-NLS-1$
+
+ public ViewerFileFilter() {
+ this(null);
+ }
+ /**
+ * Creates a new resource pattern filter.
+ */
+ public ViewerFileFilter(String patterns) {
+ super();
+
+ if (patterns != null) {
+ //Get the strings separated by a comma and filter them from the currently
+ //defined ones
+ StringTokenizer entries = new StringTokenizer(patterns, COMMA_SEPARATOR);
+ List<String> localPatterns = new ArrayList<String>();
+
+ while (entries.hasMoreElements()) {
+ String nextToken = entries.nextToken();
+ if (patterns.indexOf(nextToken) > -1)
+ localPatterns.add(nextToken);
+ }
+
+ //Convert to an array of Strings
+ String[] patternArray = new String[localPatterns.size()];
+ localPatterns.toArray(patternArray);
+ setPatterns(patternArray);
+ }
+ }
+ /**
+ * Return the currently configured StringMatchers. If there aren't any look
+ * them up.
+ */
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ IResource resource = null;
+ if (element instanceof IFile) {
+ resource = (IFile) element;
+ }
+ else
+ return true;
+ String name = resource.getName();
+ for (int i = 0; i < patterns.length; i++) {
+ if (name.endsWith(patterns[i]))
+ return true;
+ }
+ return false;
+ }
+ /**
+ * Sets the patterns to filter out for the receiver.
+ */
+ public void setPatterns(String[] newPatterns) {
+
+ this.patterns = newPatterns;
+ }
+}
Property changes on: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/ViewerFileFilter.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/WorkbenchFileSelectionDialog.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/WorkbenchFileSelectionDialog.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/WorkbenchFileSelectionDialog.java 2012-02-02 17:33:19 UTC (rev 38397)
@@ -0,0 +1,224 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.esb.project.ui.visualizer;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+
+
+public class WorkbenchFileSelectionDialog
+ extends org.eclipse.ui.dialogs.SelectionDialog {
+
+ // the initial selection
+ private IResource initialSelection;
+
+ // message and title
+ private String title;
+ private String message;
+
+ // image
+ private Image image;
+
+ // Filters
+ private String filterPatterns;
+ // the result
+ private IPath resultPath;
+
+ // the validation message
+ private Label statusMessage;
+
+ //for validating the selection
+ private org.eclipse.ui.dialogs.ISelectionValidator validator;
+
+ // the widget group;
+ private FileSelectionGroup resourceGroup;
+ /**
+ * A WorkbenchFileSelectionDialog takes the following arguments:
+ * <ul>
+ * <li> parentShell, the parent shell of the caller.(required)</li>
+ * <li> initialSelection, (resuired)</li>
+ * = null, takes the initial selection of the file from store, where it was memorizaed
+ * != null, starts the selection right from the specified path.
+ * <li> message, shows the message on titel bar for this dialog.(required)</li>
+ * <li> filterPatterns, a string of extentions separated with "," as deliminator (eg; "wsdl, xsd, java")(optional)
+ */
+ public WorkbenchFileSelectionDialog(
+ Shell parentShell,
+ IPath initialSelection,
+ String message) {
+ this(parentShell, initialSelection, message, null);
+ }
+ /**
+ * A WorkbenchFileSelectionDialog takes the following arguments:
+ * <ul>
+ * <li> parentShell, the parent shell of the caller.(required)</li>
+ * <li> initialSelection, (resuired)</li>
+ * = null, takes the initial selection of the file from store, where it was memorizaed
+ * != null, starts the selection right from the specified path.
+ * <li> message, shows the message on titel bar for this dialog.(required)</li>
+ * <li> filterPatterns, a string of extentions separated with "," as deliminator (eg; "wsdl, xsd, java")(optional)
+ */
+ public WorkbenchFileSelectionDialog(
+ Shell parentShell,
+ IPath initialSelection,
+ String message,
+ String filterPatterns) {
+ super(parentShell);
+
+ IPath initial = initialSelection;
+ if (initial == null) {
+ // Before launch the dialog, get the path in WorkbenchSlectionDialogStore, which is the path recently selected
+ //String pathString = (String)WorkbenchSlectionDialogStore.getInstance().getPreferences(workbenchFileSlectionStoreID);
+ //if (pathString.length()>0) {
+ // initial=(IPath)new Path(pathString);
+ //}
+ }
+ try {
+ if (initial != null) {
+ this.initialSelection =
+ ResourcesPlugin.getWorkspace().getRoot().getFile(initial);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ this.title = "Some fun title";
+ this.message = message;
+ setShellStyle(getShellStyle() | SWT.RESIZE);
+ this.filterPatterns = filterPatterns;
+ }
+
+ /* (non-Javadoc)
+ * Method declared in Window.
+ */
+ @Override
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ shell.setText(title);
+ if (image != null)
+ shell.setImage(image);
+ }
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
+ createButton(
+ parent,
+ IDialogConstants.CANCEL_ID,
+ IDialogConstants.CANCEL_LABEL,
+ false);
+ }
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+
+ // create composite
+ Composite dialogArea = (Composite) super.createDialogArea(parent);
+
+ Listener listener = new Listener() {
+ public void handleEvent(Event event) {
+ if (statusMessage != null && validator != null) {
+ String errorMsg =
+ validator.isValid(resourceGroup.getResourceFullPath());
+ if (errorMsg == null || errorMsg.equals("")) { //$NON-NLS-1$
+ statusMessage.setText(""); //$NON-NLS-1$
+ getOkButton().setEnabled(true);
+ } else {
+ statusMessage.setForeground(
+ statusMessage.getDisplay().getSystemColor(SWT.COLOR_RED));
+ statusMessage.setText(errorMsg);
+ getOkButton().setEnabled(false);
+ }
+ }
+ }
+ };
+
+ // file selection group
+ resourceGroup =
+ new FileSelectionGroup(dialogArea, listener, message, filterPatterns);
+ resourceGroup.getTreeViewer().addDoubleClickListener(new IDoubleClickListener() {
+
+ public void doubleClick(DoubleClickEvent event) {
+ ISelection selection = event.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ if (!selection.isEmpty()) {
+ if (((IStructuredSelection) selection).getFirstElement() instanceof IFile) {
+ IFile resultFile = (IFile) ((IStructuredSelection) selection).getFirstElement();
+ resultPath = resultFile.getFullPath();
+ okPressed();
+ }
+ }
+ }
+ }
+ });
+
+ if (initialSelection != null) {
+ resourceGroup.setSelectedResource(initialSelection);
+ }
+
+ statusMessage = new Label(parent, SWT.NONE);
+ statusMessage.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ return dialogArea;
+ }
+
+ /**
+ * Returns the "full path" (i.e. first segment is project name) of the selected file.
+ */
+ public IPath getFullPath() {
+ return resultPath;
+ }
+ /**
+ * Closes this dialog.
+ */
+ @Override
+ protected void okPressed() {
+ resultPath = resourceGroup.getResourceFullPath();
+ // after file selected, save the path to WorkbenchSlectionDialogStore
+ //WorkbenchSlectionDialogStore.getInstance().setPreferences(workbenchFileSlectionStoreID,result.toString());
+
+ super.okPressed();
+ }
+ /**
+ * Sets the validator to use.
+ */
+ public void setValidator(org.eclipse.ui.dialogs.ISelectionValidator validator) {
+ this.validator = validator;
+ }
+ @Override
+ public void setTitle(String title) {
+ super.setTitle(title);
+ this.title = title;
+ }
+ public void setImage(Image image) {
+ this.image = image;
+ }
+}
Property changes on: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/visualizer/WorkbenchFileSelectionDialog.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
12 years, 11 months
JBoss Tools SVN: r38396 - trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-02-02 10:31:46 -0500 (Thu, 02 Feb 2012)
New Revision: 38396
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util/IServerFilter.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util/ServerModelUtilities.java
Log:
https://issues.jboss.org/browse/JBIDE-10528 - utility method for xav
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util/IServerFilter.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util/IServerFilter.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util/IServerFilter.java 2012-02-02 15:31:46 UTC (rev 38396)
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.wtp.core.util;
+
+import org.eclipse.wst.server.core.IServer;
+
+/**
+ * An interface to filter out servers that are undesirable
+ */
+public interface IServerFilter {
+ public boolean accepts(IServer server);
+}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util/ServerModelUtilities.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util/ServerModelUtilities.java 2012-02-02 14:44:20 UTC (rev 38395)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util/ServerModelUtilities.java 2012-02-02 15:31:46 UTC (rev 38396)
@@ -13,11 +13,14 @@
import java.util.ArrayList;
import java.util.Arrays;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jst.server.core.IEnterpriseApplication;
import org.eclipse.jst.server.core.IJ2EEModule;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.server.core.ServerUtil;
import org.jboss.ide.eclipse.as.wtp.core.modules.IJBTModule;
public class ServerModelUtilities {
@@ -109,4 +112,32 @@
return deleted;
}
+
+ public static IServer[] findServersFor(IProject p, IServerFilter filter) {
+ ArrayList<IServer> match = new ArrayList<IServer>();
+ IServer[] allServers = ServerCore.getServers();
+ IModule[] mods = ServerUtil.getModules(p);
+ for( int i = 0; i < allServers.length; i++ ) {
+ if( filter == null || filter.accepts(allServers[i])) {
+ IModule[] serversMods = allServers[i].getModules();
+ for( int j = 0; j < mods.length; j++ ) {
+ if( !isBinaryModule(mods[j]) && moduleListContainsMod(serversMods, mods[j])) {
+ if( !match.contains(allServers[i])) {
+ match.add(allServers[i]);
+ }
+ }
+ }
+ }
+ }
+ return (IServer[]) match.toArray(new IServer[match.size()]);
+ }
+
+ public static boolean moduleListContainsMod(IModule[] list, IModule module) {
+ for( int i = 0; i < list.length; i++ ) {
+ if( list[i].equals(module))
+ return true;
+ }
+ return false;
+ }
+
}
12 years, 11 months
JBoss Tools SVN: r38395 - 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: dmaliarevich
Date: 2012-02-02 09:44:20 -0500 (Thu, 02 Feb 2012)
New Revision: 38395
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java
Log:
https://issues.jboss.org/browse/JBIDE-8701 - source scrolling was updated.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2012-02-02 12:47:39 UTC (rev 38394)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2012-02-02 14:44:20 UTC (rev 38395)
@@ -363,14 +363,18 @@
sourceScrollSelectionListener = new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
+ /*
+ * Check that scrolling is reasonable:
+ * when scrollMaxYVisual > 0
+ */
+ int scrollMaxYVisual = windowInternal.getScrollMaxY();
if (JspEditorPlugin.getDefault().getPreferenceStore().getBoolean(
IVpePreferencesPage.SYNCHRONIZE_SCROLLING_BETWEEN_SOURCE_VISUAL_PANES)
&& !visualScrollEventFlag && !selectionManager.isUpdateSelectionEventPerformed()
- && editPart.getVisualMode() == VpeEditorPart.VISUALSOURCE_MODE) { // ignore internal visual scroll event
+ && editPart.getVisualMode() == VpeEditorPart.VISUALSOURCE_MODE
+ && scrollMaxYVisual > 0) { // ignore internal visual scroll event
sourceScrollEventFlag = true;
int posY = scrollCoordinator.computeVisualPositionFromSource();
- int scrollMaxYVisual = -1;
- scrollMaxYVisual = windowInternal.getScrollMaxY();
if (posY > scrollMaxYVisual) {
posY = scrollMaxYVisual;
}
@@ -1085,6 +1089,7 @@
IVpePreferencesPage.SYNCHRONIZE_SCROLLING_BETWEEN_SOURCE_VISUAL_PANES)
&& !sourceScrollEventFlag && !selectionManager.isUpdateSelectionEventPerformed()
&& editPart.getVisualMode() == VpeEditorPart.VISUALSOURCE_MODE) { // ignore internal event from source
+ System.out.println("vis scroll");
removeSourceScrollListener();
visualScrollEventFlag = true;
int line = scrollCoordinator.computeSourcePositionFromVisual();
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java 2012-02-02 12:47:39 UTC (rev 38394)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java 2012-02-02 14:44:20 UTC (rev 38395)
@@ -207,16 +207,14 @@
int resultOffset = -1;
StyledText textWidget = itextViewer.getTextWidget();
if (textWidget != null) {
- // lineIndex-1 because calculating of line begins in eclipse from
- // one, but should be form zero
- resultOffset = textWidget.getOffsetAtLine(lineIndex - 1);
+ resultOffset = textWidget.getOffsetAtLine(lineIndex);
// here we get's tabs length
// for more example you can see code
// org.eclipse.ui.texteditor.AbstractTextEditor@getCursorPosition()
// and class $PositionLabelValue
int tabWidth = textWidget.getTabs();
int characterOffset = 0;
- String currentString = textWidget.getLine(lineIndex - 1);
+ String currentString = textWidget.getLine(lineIndex);
int pos = 1;
for (int i = 0; (i < currentString.length())
&& (pos < linePosition); i++) {
@@ -229,7 +227,7 @@
}
}
resultOffset += characterOffset;
- if (textWidget.getLineAtOffset(resultOffset) != (lineIndex - 1)) {
+ if (textWidget.getLineAtOffset(resultOffset) != lineIndex) {
resultOffset = -1;
}
}
12 years, 11 months
JBoss Tools SVN: r38394 - in trunk/vpe/plugins: org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/util and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2012-02-02 07:47:39 -0500 (Thu, 02 Feb 2012)
New Revision: 38394
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/util/XulRunnerVpeUtils.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeDomMapping.java
Log:
https://issues.jboss.org/browse/JBIDE-8701 - comments were added.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeDomMapping.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeDomMapping.java 2012-02-02 12:01:18 UTC (rev 38393)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeDomMapping.java 2012-02-02 12:47:39 UTC (rev 38394)
@@ -258,6 +258,12 @@
return null;
}
+ /**
+ * Returns the nearest visual element for the source node
+ *
+ * @param sourceNode the source node
+ * @return nearest visual element
+ */
public nsIDOMElement getNearVisualElement(Node sourceNode) {
nsIDOMElement element = null;
VpeNodeMapping nodeMapping = getNearNodeMappingAtSourceNode(sourceNode);
@@ -299,6 +305,12 @@
return null;
}
+ /**
+ * Returns the nearest source element for the visual node
+ *
+ * @param visualNode the visual node
+ * @return nearest source element
+ */
public ElementImpl getNearSourceElementImpl(nsIDOMNode visualNode) {
ElementImpl element = null;
VpeNodeMapping nodeMapping = getNearNodeMappingAtVisualNode(visualNode);
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/util/XulRunnerVpeUtils.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/util/XulRunnerVpeUtils.java 2012-02-02 12:01:18 UTC (rev 38393)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/util/XulRunnerVpeUtils.java 2012-02-02 12:47:39 UTC (rev 38394)
@@ -142,6 +142,12 @@
return element;
}
+ /**
+ * Returns the offset for visual node
+ *
+ * @param node the visual node
+ * @return node's offset in browser
+ */
public static Point getVisualNodeOffset(nsIDOMNode node) {
Point p = new Point(-1, -1);
try {
12 years, 11 months
JBoss Tools SVN: r38393 - in trunk/vpe/plugins: org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2012-02-02 07:01:18 -0500 (Thu, 02 Feb 2012)
New Revision: 38393
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/scrolling/
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/scrolling/IScrollCoordinator.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/scrolling/ScrollCoordinator.java
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/util/XulRunnerVpeUtils.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeDomMapping.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
Log:
https://issues.jboss.org/browse/JBIDE-8701 - Simple scroll functions to correlate between source and visual nodes were added, +code adjustments.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2012-02-02 05:58:57 UTC (rev 38392)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2012-02-02 12:01:18 UTC (rev 38393)
@@ -12,9 +12,7 @@
import static org.jboss.tools.vpe.xulrunner.util.XPCOM.queryInterface;
-import java.text.MessageFormat;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -33,6 +31,7 @@
import org.eclipse.jface.bindings.keys.KeyStroke;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
@@ -42,8 +41,6 @@
import org.eclipse.swt.custom.LineStyleListener;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.MenuEvent;
import org.eclipse.swt.events.MenuListener;
import org.eclipse.swt.events.SelectionEvent;
@@ -60,13 +57,11 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.internal.keys.WorkbenchKeyboard;
import org.eclipse.ui.keys.IBindingService;
import org.eclipse.ui.progress.UIJob;
-import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import org.eclipse.wst.sse.core.internal.model.ModelLifecycleEvent;
import org.eclipse.wst.sse.core.internal.provisional.IModelLifecycleListener;
import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
@@ -78,6 +73,7 @@
import org.eclipse.wst.sse.ui.internal.view.events.ITextSelectionListener;
import org.eclipse.wst.sse.ui.internal.view.events.NodeSelectionChangedEvent;
import org.eclipse.wst.sse.ui.internal.view.events.TextSelectionChangedEvent;
+import org.eclipse.wst.xml.core.internal.document.ElementImpl;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.jboss.tools.common.el.core.ELReferenceList;
@@ -86,7 +82,6 @@
import org.jboss.tools.common.model.event.XModelTreeEvent;
import org.jboss.tools.common.model.event.XModelTreeListener;
import org.jboss.tools.common.model.project.IModelNature;
-import org.jboss.tools.common.model.ui.dnd.ModelTransfer;
import org.jboss.tools.common.model.ui.util.ModelUtilities;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.model.util.XModelTreeListenerSWTSync;
@@ -108,7 +103,6 @@
import org.jboss.tools.vpe.dnd.VpeDnD;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
-import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
import org.jboss.tools.vpe.editor.menu.VpeMenuCreator;
import org.jboss.tools.vpe.editor.mozilla.MozillaEditor;
@@ -121,6 +115,7 @@
import org.jboss.tools.vpe.editor.mozilla.listener.MozillaScrollListener;
import org.jboss.tools.vpe.editor.mozilla.listener.MozillaSelectionListener;
import org.jboss.tools.vpe.editor.mozilla.listener.MozillaTooltipListener;
+import org.jboss.tools.vpe.editor.scrolling.ScrollCoordinator;
import org.jboss.tools.vpe.editor.selection.VpeSelectionController;
import org.jboss.tools.vpe.editor.template.IKeyEventHandler;
import org.jboss.tools.vpe.editor.template.ISelectionManager;
@@ -132,20 +127,10 @@
import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
import org.jboss.tools.vpe.editor.template.ZoomEventManager;
import org.jboss.tools.vpe.editor.toolbar.format.FormatControllerManager;
-import org.jboss.tools.vpe.editor.util.Constants;
import org.jboss.tools.vpe.editor.util.DocTypeUtil;
import org.jboss.tools.vpe.editor.util.SelectionUtil;
import org.jboss.tools.vpe.editor.util.VisualDomUtil;
import org.jboss.tools.vpe.editor.util.VpeDebugUtil;
-import org.jboss.tools.vpe.editor.util.VpeNodesManagingUtil;
-import org.jboss.tools.vpe.handlers.PageDesignOptionsHandler;
-import org.jboss.tools.vpe.handlers.PreferencesHandler;
-import org.jboss.tools.vpe.handlers.RefreshHandler;
-import org.jboss.tools.vpe.handlers.RotateEditorsHandler;
-import org.jboss.tools.vpe.handlers.ShowBorderHandler;
-import org.jboss.tools.vpe.handlers.ShowBundleAsELHandler;
-import org.jboss.tools.vpe.handlers.ShowNonVisualTagsHandler;
-import org.jboss.tools.vpe.handlers.ShowTextFormattingHandler;
import org.jboss.tools.vpe.handlers.VisualPartAbstractHandler;
import org.jboss.tools.vpe.messages.VpeUIMessages;
import org.jboss.tools.vpe.resref.core.AbsoluteFolderReferenceList;
@@ -185,6 +170,7 @@
* https://issues.jboss.org/browse/JBIDE-8701
* Scroll listeners staff.
*/
+ private ScrollCoordinator scrollCoordinator;
private SelectionListener sourceScrollSelectionListener;
private ScrollBar sourceEditorVerticalScrollBar;
private boolean sourceScrollEventFlag = false;
@@ -358,6 +344,7 @@
* https://issues.jboss.org/browse/JBIDE-8701
* Add Source ScrollBar Listener
*/
+ scrollCoordinator = new ScrollCoordinator(sourceEditor, visualEditor, domMapping);
if ((visualEditor != null) && (sourceEditor != null)) {
sourceEditorVerticalScrollBar = textWidget.getVerticalBar();
if (sourceEditorVerticalScrollBar != null) {
@@ -378,21 +365,16 @@
public void widgetSelected(SelectionEvent e) {
if (JspEditorPlugin.getDefault().getPreferenceStore().getBoolean(
IVpePreferencesPage.SYNCHRONIZE_SCROLLING_BETWEEN_SOURCE_VISUAL_PANES)
- && !visualScrollEventFlag && !selectionManager.isUpdateSelectionEventPerformed()) { // ignore internal visual scroll event
+ && !visualScrollEventFlag && !selectionManager.isUpdateSelectionEventPerformed()
+ && editPart.getVisualMode() == VpeEditorPart.VISUALSOURCE_MODE) { // ignore internal visual scroll event
sourceScrollEventFlag = true;
- ScrollBar sb = (ScrollBar)e.widget;
- int pageYOffsetSrc = sb.getSelection();
- int scrollMaxYSrc = sb.getMaximum() - sb.getThumb();
- float percentsSrc = ((float)pageYOffsetSrc/scrollMaxYSrc);
- if (windowInternal.getScrollbars().getVisible()) {
- int scrollMaxYVisual = -1;
- scrollMaxYVisual = windowInternal.getScrollMaxY();
- if (scrollMaxYVisual != 0 && scrollMaxYVisual != -1) {
- // there is a visual scroll bar
- int posY = ((int) (scrollMaxYVisual*percentsSrc));
- domWindow.scrollTo(windowInternal.getPageXOffset(),posY);
- }
+ int posY = scrollCoordinator.computeVisualPositionFromSource();
+ int scrollMaxYVisual = -1;
+ scrollMaxYVisual = windowInternal.getScrollMaxY();
+ if (posY > scrollMaxYVisual) {
+ posY = scrollMaxYVisual;
}
+ domWindow.scrollTo(windowInternal.getPageXOffset(),posY);
} else {
visualScrollEventFlag = false;
selectionManager.setUpdateSelectionEventFlag(false);
@@ -1101,29 +1083,15 @@
*/
if (JspEditorPlugin.getDefault().getPreferenceStore().getBoolean(
IVpePreferencesPage.SYNCHRONIZE_SCROLLING_BETWEEN_SOURCE_VISUAL_PANES)
- && !sourceScrollEventFlag && !selectionManager.isUpdateSelectionEventPerformed()) { // ignore internal event from source
- if (visualEditor.getXulRunnerEditor() != null) {
- visualScrollEventFlag = true;
- final nsIWebBrowser webBrowser = visualEditor.getXulRunnerEditor().getWebBrowser();
- removeSourceScrollListener();
- final StyledText textWidget = SelectionHelper.getSourceTextWidget(sourceEditor);
- final nsIDOMWindow domWindow = webBrowser.getContentDOMWindow();
- nsIDOMWindowInternal windowInternal = org.jboss.tools.vpe.xulrunner.util.XPCOM
- .queryInterface(domWindow, nsIDOMWindowInternal.class);
- int pageYOffsetVisual = windowInternal.getPageYOffset();
- int scrollMaxYVisual = windowInternal.getScrollMaxY();
- float percentsVisual = ((float)pageYOffsetVisual/scrollMaxYVisual);
- ScrollBar sb = getSourceEditorVerticalScrollBar();
- if ((sb != null) && (sb.getMaximum() != 1)) {
- int srcLinesCount = textWidget.getLineCount();
- // there is a source scroll bar
- if (srcLinesCount != 1) {
- int posLines = ((int) (srcLinesCount*percentsVisual));
- textWidget.setTopIndex(posLines);
- }
- }
- addSourceScrollListener();
+ && !sourceScrollEventFlag && !selectionManager.isUpdateSelectionEventPerformed()
+ && editPart.getVisualMode() == VpeEditorPart.VISUALSOURCE_MODE) { // ignore internal event from source
+ removeSourceScrollListener();
+ visualScrollEventFlag = true;
+ int line = scrollCoordinator.computeSourcePositionFromVisual();
+ if ((line != -1) && (sourceEditor.getTextViewer() != null)){
+ sourceEditor.getTextViewer().setTopIndex(line);
}
+ addSourceScrollListener();
} else {
sourceScrollEventFlag = false;
selectionManager.setUpdateSelectionEventFlag(false);
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 2012-02-02 05:58:57 UTC (rev 38392)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2012-02-02 12:01:18 UTC (rev 38393)
@@ -25,7 +25,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.regex.Matcher;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IStorage;
@@ -35,6 +34,7 @@
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
+import org.eclipse.wst.xml.core.internal.document.ElementImpl;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.jboss.tools.common.resref.core.ResourceReference;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
@@ -58,7 +58,6 @@
import org.jboss.tools.vpe.editor.template.VpeTemplateSafeWrapper;
import org.jboss.tools.vpe.editor.template.VpeToggableTemplate;
import org.jboss.tools.vpe.editor.template.expression.VpeExpressionException;
-import org.jboss.tools.vpe.editor.util.Constants;
import org.jboss.tools.vpe.editor.util.Docbook;
import org.jboss.tools.vpe.editor.util.FaceletUtil;
import org.jboss.tools.vpe.editor.util.HTML;
@@ -529,20 +528,16 @@
}
protected void correctVisualAttribute(nsIDOMElement element) {
- String styleValue = element.getAttribute(HTML.TAG_STYLE);
- String backgroundValue = element
- .getAttribute(VpeStyleUtil.PARAMETR_BACKGROND);
+ String styleValue = element.getAttribute(HTML.ATTR_STYLE);
+ String backgroundValue = element.getAttribute(HTML.ATTR_BACKGROUND);
if (styleValue != null) {
- styleValue = VpeStyleUtil.addFullPathIntoURLValue(styleValue,
- pageContext);
- element.setAttribute(HTML.TAG_STYLE, styleValue);
+ styleValue = VpeStyleUtil.addFullPathIntoURLValue(styleValue, pageContext);
+ element.setAttribute(HTML.ATTR_STYLE, styleValue);
}
if (backgroundValue != null) {
- backgroundValue = VpeStyleUtil
- .addFullPathIntoBackgroundValue(backgroundValue,
- pageContext.getEditPart().getEditorInput());
- element.setAttribute(VpeStyleUtil.PARAMETR_BACKGROND,
- backgroundValue);
+ backgroundValue = VpeStyleUtil.addFullPathIntoBackgroundValue(
+ backgroundValue, pageContext.getEditPart().getEditorInput());
+ element.setAttribute(HTML.ATTR_BACKGROUND, backgroundValue);
}
//fix for jbide-3209
if(element.hasAttribute(HTML.ATTR_DIR)) {
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeDomMapping.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeDomMapping.java 2012-02-02 05:58:57 UTC (rev 38392)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeDomMapping.java 2012-02-02 12:01:18 UTC (rev 38393)
@@ -17,6 +17,7 @@
import java.util.Map;
import java.util.Set;
+import org.eclipse.wst.xml.core.internal.document.ElementImpl;
import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.xulrunner.editor.XulRunnerEditor;
@@ -24,7 +25,6 @@
import org.mozilla.interfaces.nsIDOMNode;
import org.mozilla.xpcom.XPCOMException;
import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -258,21 +258,72 @@
return null;
}
+ public nsIDOMElement getNearVisualElement(Node sourceNode) {
+ nsIDOMElement element = null;
+ VpeNodeMapping nodeMapping = getNearNodeMappingAtSourceNode(sourceNode);
+ if (sourceNode != null) {
+ if (nodeMapping != null) {
+ nsIDOMNode visualNode = nodeMapping.getVisualNode();
+ if (visualNode != null) {
+ try {
+ element = queryInterface(visualNode, nsIDOMElement.class);
+ } catch (XPCOMException xpcomException) {
+ if (sourceNode.getPreviousSibling() != null) {
+ element = getNearVisualElement(sourceNode.getPreviousSibling());
+ } else {
+ element = getNearVisualElement(sourceNode.getParentNode());
+ }
+ }
+ }
+ } else {
+ if (sourceNode.getPreviousSibling() != null) {
+ element = getNearVisualElement(sourceNode.getPreviousSibling());
+ } else {
+ element = getNearVisualElement(sourceNode.getParentNode());
+ }
+ }
+ }
+ return element;
+ }
+
public nsIDOMNode getNearVisualNode(Node sourceNode) {
if (sourceNode == null) return null;
VpeNodeMapping nodeMapping = getNearNodeMappingAtSourceNode(sourceNode);
if (nodeMapping != null) {
if (nodeMapping.getVisualNode() == null) {
-
return getNearVisualNode(sourceNode.getParentNode());
} else {
-
return nodeMapping.getVisualNode();
}
}
return null;
}
+ public ElementImpl getNearSourceElementImpl(nsIDOMNode visualNode) {
+ ElementImpl element = null;
+ VpeNodeMapping nodeMapping = getNearNodeMappingAtVisualNode(visualNode);
+ if (visualNode != null) {
+ if ((nodeMapping != null) && (nodeMapping.getSourceNode() != null)
+ && (nodeMapping.getSourceNode() instanceof ElementImpl)) {
+ /*
+ * This visual node is OK and src node is Element
+ */
+ element = (ElementImpl) nodeMapping.getSourceNode();
+ } else {
+ /*
+ * Else continue searching
+ */
+ if (visualNode.getNextSibling() != null) {
+ element = getNearSourceElementImpl(visualNode.getNextSibling());
+ } else {
+ element = getNearSourceElementImpl(visualNode.getParentNode());
+ }
+ }
+ }
+// System.out.println("--near src element = " + element);
+ return element;
+ }
+
public Node getNearSourceNode(nsIDOMNode visualNode) {
VpeNodeMapping nodeMapping = getNearNodeMapping(visualNode);
if (nodeMapping != null) {
Added: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/scrolling/IScrollCoordinator.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/scrolling/IScrollCoordinator.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/scrolling/IScrollCoordinator.java 2012-02-02 12:01:18 UTC (rev 38393)
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.scrolling;
+
+/**
+ * Interface that coordinates scroll position in source and visual editors
+ * @author dmaliarevich
+ */
+public interface IScrollCoordinator {
+ /**
+ * Computes visual editor scroll position
+ * based on the source editor text position
+ *
+ * @return visual editor scroll position
+ */
+ int computeVisualPositionFromSource();
+
+ /**
+ * Computes source editor text position
+ * based on the visual editor scroll position
+ *
+ * @return source editor scroll position
+ */
+ int computeSourcePositionFromVisual();
+}
Added: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/scrolling/ScrollCoordinator.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/scrolling/ScrollCoordinator.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/scrolling/ScrollCoordinator.java 2012-02-02 12:01:18 UTC (rev 38393)
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.scrolling;
+
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.eclipse.wst.xml.core.internal.document.ElementImpl;
+import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
+import org.jboss.tools.vpe.editor.mozilla.MozillaEditor;
+import org.jboss.tools.vpe.editor.util.SourceDomUtil;
+import org.jboss.tools.vpe.xulrunner.util.XulRunnerVpeUtils;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMWindow;
+import org.mozilla.interfaces.nsIDOMWindowUtils;
+import org.mozilla.interfaces.nsIInterfaceRequestor;
+import org.w3c.dom.Node;
+
+/**
+ * Base implementation of IScrollCoordinator
+ * @author dmaliarevich
+ */
+public class ScrollCoordinator implements IScrollCoordinator {
+
+ StructuredTextEditor sourceEditor = null;
+ MozillaEditor visualEditor = null;
+ VpeDomMapping domMapping = null;
+
+ public ScrollCoordinator(StructuredTextEditor sourceEditor,
+ MozillaEditor visualEditor, VpeDomMapping domMapping) {
+ super();
+ this.sourceEditor = sourceEditor;
+ this.visualEditor = visualEditor;
+ this.domMapping = domMapping;
+ }
+
+ /**
+ * Compute an absolute pixel offset to scroll the xulrunner window to.
+ */
+ @Override
+ public int computeVisualPositionFromSource() {
+ int posY = -1;
+ if (sourceEditor != null) {
+ ITextViewer textViewer = sourceEditor.getTextViewer();
+ if (textViewer != null) {
+ int topLine = textViewer.getTopIndex();
+ Node n = SourceDomUtil.getSourceNodeByEditorPosition(textViewer, topLine, 1);
+ if (n != null) {
+ nsIDOMElement visualElement = domMapping.getNearVisualElement(n);
+ if (visualElement != null) {
+ Point r = XulRunnerVpeUtils.getVisualNodeOffset(visualElement);
+ posY = r.y;
+ }
+ }
+ }
+ }
+ return posY;
+ }
+
+ /**
+ * Compute top line index to scroll the source editor to.
+ */
+ @Override
+ public int computeSourcePositionFromVisual() {
+ int line = -1;
+ if ((sourceEditor != null) && (visualEditor != null)) {
+ if (visualEditor.getXulRunnerEditor() != null) {
+ nsIDOMWindow domWindow = visualEditor.getXulRunnerEditor().getWebBrowser().getContentDOMWindow();
+ nsIInterfaceRequestor iInterfaceRequestor = (nsIInterfaceRequestor)
+ domWindow.queryInterface(nsIInterfaceRequestor.NS_IINTERFACEREQUESTOR_IID);
+ nsIDOMWindowUtils windowUtils = (nsIDOMWindowUtils)
+ iInterfaceRequestor.getInterface(nsIDOMWindowUtils.NS_IDOMWINDOWUTILS_IID);
+ int x = 40;//windowInternal.getInnerWidth()/5;
+ int y = 30;//windowInternal.getInnerHeight()/5;
+ nsIDOMElement elementFromPoint = windowUtils.elementFromPoint(x, y, true, false);
+ if (elementFromPoint != null) {
+ ElementImpl sourceElement = domMapping.getNearSourceElementImpl(elementFromPoint);
+ /*
+ * Transform offset to line number
+ */
+ line = sourceEditor.getTextViewer().getTextWidget().getLineAtOffset(sourceElement.getStartEndOffset());
+ }
+ }
+ }
+ return line;
+ }
+}
\ No newline at end of file
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java 2012-02-02 05:58:57 UTC (rev 38392)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java 2012-02-02 12:01:18 UTC (rev 38393)
@@ -13,6 +13,9 @@
import java.util.HashSet;
import java.util.Set;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
import org.eclipse.wst.xml.xpath.core.util.XSLTXPathHelper;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
@@ -189,4 +192,66 @@
return currentNode;
}
+
+ /**
+ * Utility function which is used to calculate offset in document by line number and character position.
+ *
+ * @param linePosition the line position
+ * @param textWidget the text viewer
+ * @param lineIndex the line index
+ *
+ * @return offset in document, -1 for wrong offset
+ *
+ */
+ public static final int getLinePositionOffset(ITextViewer itextViewer, int lineIndex, int linePosition) {
+ int resultOffset = -1;
+ StyledText textWidget = itextViewer.getTextWidget();
+ if (textWidget != null) {
+ // lineIndex-1 because calculating of line begins in eclipse from
+ // one, but should be form zero
+ resultOffset = textWidget.getOffsetAtLine(lineIndex - 1);
+ // here we get's tabs length
+ // for more example you can see code
+ // org.eclipse.ui.texteditor.AbstractTextEditor@getCursorPosition()
+ // and class $PositionLabelValue
+ int tabWidth = textWidget.getTabs();
+ int characterOffset = 0;
+ String currentString = textWidget.getLine(lineIndex - 1);
+ int pos = 1;
+ for (int i = 0; (i < currentString.length())
+ && (pos < linePosition); i++) {
+ if ('\t' == currentString.charAt(i)) {
+ characterOffset += (tabWidth == 0 ? 0 : 1);
+ pos += tabWidth;
+ } else {
+ pos++;
+ characterOffset++;
+ }
+ }
+ resultOffset += characterOffset;
+ if (textWidget.getLineAtOffset(resultOffset) != (lineIndex - 1)) {
+ resultOffset = -1;
+ }
+ }
+ return resultOffset;
+ }
+
+ /**
+ * Returns source node by source editor position(line and position in line).
+ *
+ * @param linePosition the line position
+ * @param lineIndex the line index
+ * @param itextViewer the itext viewer
+ *
+ * @return node for specified src position
+ */
+ @SuppressWarnings("restriction")
+ public static Node getSourceNodeByEditorPosition(ITextViewer itextViewer, int lineIndex, int linePosition) {
+ int offset = getLinePositionOffset(itextViewer, lineIndex, linePosition);
+ if (offset != -1) {
+ return (Node) ContentAssistUtils.getNodeAt(itextViewer, offset);
+ } else {
+ return null;
+ }
+ }
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2012-02-02 05:58:57 UTC (rev 38392)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2012-02-02 12:01:18 UTC (rev 38393)
@@ -435,17 +435,16 @@
}
/**
+ * Adds full path for URL value
*
- * @param value
- * Css string
- * @param input
- * The editor input
- * @return format style string
+ * @param url the url
+ * @param pageContext VPE page context
+ * @return the full path string
*/
- public static String addFullPathIntoURLValue(String value, VpePageContext pageContext) {
- String urls[] = value.split(ATTR_URL);
+ public static String addFullPathIntoURLValue(String url, VpePageContext pageContext) {
+ String urls[] = url.split(ATTR_URL);
if (urls.length == 1) {
- return value;
+ return url;
}
IFile file = getSourceFileFromPageContext(pageContext);
for (int i = 1; i < urls.length; i++) {
@@ -463,17 +462,16 @@
}
/**
+ * Adds full path for URL value
*
- * @param value
- * Css string
- * @param href_val
- * Path of css file
- * @return Format style string
+ * @param url css url string
+ * @param href_val path to css file
+ * @return the full path string
*/
- public static String addFullPathIntoURLValue(String value, String href_val) {
- String urls[] = value.split(ATTR_URL);
+ public static String addFullPathIntoURLValue(String url, String href_val) {
+ String urls[] = url.split(ATTR_URL);
if (urls.length == 1) {
- return value;
+ return url;
}
for (int i = 1; i < urls.length; i++) {
urls[i] = removeQuotesUpdate(urls[i]);
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/util/XulRunnerVpeUtils.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/util/XulRunnerVpeUtils.java 2012-02-02 05:58:57 UTC (rev 38392)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/util/XulRunnerVpeUtils.java 2012-02-02 12:01:18 UTC (rev 38393)
@@ -142,6 +142,15 @@
return element;
}
+ public static Point getVisualNodeOffset(nsIDOMNode node) {
+ Point p = new Point(-1, -1);
+ try {
+ p = getDocumentPos(queryInterface(node, nsIDOMNSHTMLElement.class));
+ } catch (XPCOMException xpcomException) {
+ // do nothing
+ }
+ return p;
+ }
private static Point getDocumentPos(nsIDOMNSHTMLElement boxElement) {
int x = 0;
@@ -152,7 +161,6 @@
y += curBoxElement.getOffsetTop();
curBoxElement = getOffsetParent(curBoxElement);
}
-
return new Point(x, y);
}
12 years, 11 months
JBoss Tools SVN: r38392 - trunk/build/target-platform.
by jbosstools-commits@lists.jboss.org
Author: nickboldt
Date: 2012-02-02 00:58:57 -0500 (Thu, 02 Feb 2012)
New Revision: 38392
Modified:
trunk/build/target-platform/jbds.target
trunk/build/target-platform/multiple.target
trunk/build/target-platform/unified.target
Log:
newer GDT version on TP
Modified: trunk/build/target-platform/jbds.target
===================================================================
--- trunk/build/target-platform/jbds.target 2012-02-02 02:13:02 UTC (rev 38391)
+++ trunk/build/target-platform/jbds.target 2012-02-02 05:58:57 UTC (rev 38392)
@@ -269,8 +269,8 @@
<unit id="javax.el" version="2.2.0.v201105051105"/>
<!-- GWT/GPE dependencies (include only those which are EPL or other OSS licensed!) -->
- <unit id="com.google.gdt.eclipse.suite.e37.feature.feature.group" version="2.5.0.v201201120043-rel-r37"/>
+ <unit id="com.google.gdt.eclipse.suite.e37.feature.feature.group" version="2.5.1.v201201120043-rel-r37"/>
<unit id="com.google.gwt.eclipse.sdkbundle.e37.feature.feature.group" version="2.4.0.v201201120043-rel-r37"/>
</location>
</locations>
-</target>
+</target>
\ No newline at end of file
Modified: trunk/build/target-platform/multiple.target
===================================================================
--- trunk/build/target-platform/multiple.target 2012-02-02 02:13:02 UTC (rev 38391)
+++ trunk/build/target-platform/multiple.target 2012-02-02 05:58:57 UTC (rev 38392)
@@ -310,7 +310,7 @@
<unit id="org.eclipse.birt.chart.integration.wtp.feature.group" version="3.7.1.v20110905-1820-4607w31221A1602931"/>
<!-- GWT/GPE dependencies (include only those which are EPL or other OSS licensed!) -->
- <unit id="com.google.gdt.eclipse.suite.e37.feature.feature.group" version="2.5.0.v201201120043-rel-r37"/>
+ <unit id="com.google.gdt.eclipse.suite.e37.feature.feature.group" version="2.5.1.v201201120043-rel-r37"/>
<unit id="com.google.gwt.eclipse.sdkbundle.e37.feature.feature.group" version="2.4.0.v201201120043-rel-r37"/>
<!-- SAVARA dependencies -->
@@ -338,4 +338,4 @@
<feature id="org.mozilla.xpcom.feature"/>
</includeBundles>
<targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
-</target>
+</target>
\ No newline at end of file
Modified: trunk/build/target-platform/unified.target
===================================================================
--- trunk/build/target-platform/unified.target 2012-02-02 02:13:02 UTC (rev 38391)
+++ trunk/build/target-platform/unified.target 2012-02-02 05:58:57 UTC (rev 38392)
@@ -310,7 +310,7 @@
<unit id="org.eclipse.birt.chart.integration.wtp.feature.group" version="3.7.1.v20110905-1820-4607w31221A1602931"/>
<!-- GWT/GPE dependencies (include only those which are EPL or other OSS licensed!) -->
- <unit id="com.google.gdt.eclipse.suite.e37.feature.feature.group" version="2.5.0.v201201120043-rel-r37"/>
+ <unit id="com.google.gdt.eclipse.suite.e37.feature.feature.group" version="2.5.1.v201201120043-rel-r37"/>
<unit id="com.google.gwt.eclipse.sdkbundle.e37.feature.feature.group" version="2.4.0.v201201120043-rel-r37"/>
<!-- SAVARA dependencies -->
@@ -338,4 +338,4 @@
<feature id="org.mozilla.xpcom.feature"/>
</includeBundles>
<targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
-</target>
+</target>
\ No newline at end of file
12 years, 11 months
JBoss Tools SVN: r38391 - in trunk/jst/plugins: org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/util and 4 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2012-02-01 21:13:02 -0500 (Wed, 01 Feb 2012)
New Revision: 38391
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbAbstractModelResource.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/util/XmlUtil.java
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/model/helpers/WebProcessStructureHelper.java
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/model/pv/handler/ProjectsResourceRedirectHandler.java
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/model/pv/handler/ProjectsTaglibsRedirectHandler.java
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/refactoring/WebRenameTLDWebAppChange.java
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/tld/TaglibMapping.java
Log:
Exception catching code cleanup
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbAbstractModelResource.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbAbstractModelResource.java 2012-02-02 01:54:03 UTC (rev 38390)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbAbstractModelResource.java 2012-02-02 02:13:02 UTC (rev 38391)
@@ -30,19 +30,13 @@
public WTPKbAbstractModelResource(IEditorInput fEditorInput) {
this.fEditorInput = fEditorInput;
fProvider = WebPromptingProvider.getInstance();
- try {
- if(fEditorInput instanceof IModelObjectEditorInput) {
- fXModelObject = ((IModelObjectEditorInput)fEditorInput).getXModelObject();
- } else if(fEditorInput instanceof IFileEditorInput) {
- IFile file = ((IFileEditorInput)fEditorInput).getFile();
- fXModelObject = EclipseResourceUtil.getObjectByResource(file);
- }
- fXModel = (fXModelObject == null) ? null : fXModelObject.getModel();
- } catch (Exception x) {
- JspEditorPlugin.getPluginLog().logError(x);
- this.fProvider = null;
- this.fXModel = null;
+ if(fEditorInput instanceof IModelObjectEditorInput) {
+ fXModelObject = ((IModelObjectEditorInput)fEditorInput).getXModelObject();
+ } else if(fEditorInput instanceof IFileEditorInput) {
+ IFile file = ((IFileEditorInput)fEditorInput).getFile();
+ fXModelObject = EclipseResourceUtil.getObjectByResource(file);
}
+ fXModel = (fXModelObject == null) ? null : fXModelObject.getModel();
}
public XModel getXModel() {
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/util/XmlUtil.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/util/XmlUtil.java 2012-02-02 01:54:03 UTC (rev 38390)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/util/XmlUtil.java 2012-02-02 02:13:02 UTC (rev 38391)
@@ -11,6 +11,7 @@
package org.jboss.tools.jst.jsp.util;
import java.io.FileInputStream;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
@@ -45,7 +46,7 @@
} finally {
try {
if (inStream != null) inStream.close();
- } catch (Exception e) {
+ } catch (IOException e) {
JspEditorPlugin.getPluginLog().logError(e);
}
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/model/helpers/WebProcessStructureHelper.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/model/helpers/WebProcessStructureHelper.java 2012-02-02 01:54:03 UTC (rev 38390)
+++ trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/model/helpers/WebProcessStructureHelper.java 2012-02-02 02:13:02 UTC (rev 38391)
@@ -94,7 +94,7 @@
for (int i = 0; i < s.length; i++) {
try {
result[i] = Integer.parseInt(s[i]);
- } catch (Exception e) {
+ } catch (NumberFormatException e) {
WebModelPlugin.getPluginLog().logError(e);
result[i] = 0;
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/model/pv/handler/ProjectsResourceRedirectHandler.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/model/pv/handler/ProjectsResourceRedirectHandler.java 2012-02-02 01:54:03 UTC (rev 38390)
+++ trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/model/pv/handler/ProjectsResourceRedirectHandler.java 2012-02-02 02:13:02 UTC (rev 38391)
@@ -11,6 +11,7 @@
package org.jboss.tools.jst.web.model.pv.handler;
import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.QualifiedName;
import org.jboss.tools.common.meta.action.impl.handlers.DefaultRedirectHandler;
import org.jboss.tools.common.model.XModelObject;
@@ -27,7 +28,7 @@
QualifiedName n = new QualifiedName("", action.getName() + "_lastPath"); //$NON-NLS-1$ //$NON-NLS-2$
String path = p.getPersistentProperty(n);
if(path != null) r = p.getWorkspace().getRoot().findMember(path);
- } catch (Exception e) {
+ } catch (CoreException e) {
WebModelPlugin.getPluginLog().logError(e);
}
if(r == null) r = EclipseResourceUtil.getJavaSourceRoot(p);
Modified: trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/model/pv/handler/ProjectsTaglibsRedirectHandler.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/model/pv/handler/ProjectsTaglibsRedirectHandler.java 2012-02-02 01:54:03 UTC (rev 38390)
+++ trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/model/pv/handler/ProjectsTaglibsRedirectHandler.java 2012-02-02 02:13:02 UTC (rev 38391)
@@ -11,6 +11,7 @@
package org.jboss.tools.jst.web.model.pv.handler;
import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.QualifiedName;
import org.jboss.tools.common.meta.action.impl.handlers.DefaultRedirectHandler;
import org.jboss.tools.common.model.XModelObject;
@@ -27,7 +28,7 @@
QualifiedName n = new QualifiedName("", action.getName() + "_lastPath"); //$NON-NLS-1$ //$NON-NLS-2$
String path = p.getPersistentProperty(n);
if(path != null) r = p.getWorkspace().getRoot().findMember(path);
- } catch (Exception e) {
+ } catch (CoreException e) {
WebModelPlugin.getPluginLog().logError(e);
}
XModelObject o = EclipseResourceUtil.getObjectByResource(r);
Modified: trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/refactoring/WebRenameTLDWebAppChange.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/refactoring/WebRenameTLDWebAppChange.java 2012-02-02 01:54:03 UTC (rev 38390)
+++ trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/refactoring/WebRenameTLDWebAppChange.java 2012-02-02 02:13:02 UTC (rev 38391)
@@ -35,14 +35,10 @@
int i = oldText.lastIndexOf("/"); //$NON-NLS-1$
String newText = oldText.substring(0, i + 1) + newName;
replacements.setProperty(oldText, newText);
- try {
- addChanges();
- } catch (Exception e) {
- WebModelPlugin.getPluginLog().logError(e);
- }
+ addChanges();
}
- private void addChanges() throws Exception {
+ private void addChanges() {
if(object == null) return;
XModelObject webxml = object.getModel().getByPath("/web.xml"); //$NON-NLS-1$
XModelObject[] fs = (webxml == null) ? new XModelObject[0] : new XModelObject[]{webxml};
Modified: trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/tld/TaglibMapping.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/tld/TaglibMapping.java 2012-02-02 01:54:03 UTC (rev 38390)
+++ trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/tld/TaglibMapping.java 2012-02-02 02:13:02 UTC (rev 38391)
@@ -11,6 +11,7 @@
package org.jboss.tools.jst.web.tld;
import java.io.File;
+import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
@@ -194,7 +195,7 @@
if(r != null && r.getLocation() != null) {
url = r.getLocation().toFile().toURL().toString();
}
- } catch (Exception e) {
+ } catch (MalformedURLException e) {
WebModelPlugin.getPluginLog().logError(e);
}
if(url != null) findTldsInFolder(webinf, url);
@@ -232,7 +233,7 @@
String url = null;
try {
url = "jar:" + new File(location).toURL().toString() + "!/META-INF/"; //$NON-NLS-1$ //$NON-NLS-2$
- } catch (Exception e) {
+ } catch (MalformedURLException e) {
WebModelPlugin.getPluginLog().logError("TaglibMapping:findTldsInJar:" + e.getMessage(), e); //$NON-NLS-1$
return;
}
12 years, 11 months
JBoss Tools SVN: r38390 - in trunk: common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2012-02-01 20:54:03 -0500 (Wed, 01 Feb 2012)
New Revision: 38390
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllDisposerDuplicantMarkerResolution.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/MarkerResolutionUtils.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AbstractSeamMarkerResolution.java
Log:
Seam quick fixes insert incorrectly formated code https://issues.jboss.org/browse/JBIDE-10766
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllDisposerDuplicantMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllDisposerDuplicantMarkerResolution.java 2012-02-02 01:40:01 UTC (rev 38389)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllDisposerDuplicantMarkerResolution.java 2012-02-02 01:54:03 UTC (rev 38390)
@@ -58,7 +58,6 @@
DeleteAllDisposerAnnotationsProcessor processor = new DeleteAllDisposerAnnotationsProcessor(file, method, label);
ProcessorBasedRefactoring refactoring = new ProcessorBasedRefactoring(processor);
DeletePreviewWizard wizard = new DeletePreviewWizard(refactoring);
- //RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(wizard);
wizard.showWizard();
}
Modified: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/MarkerResolutionUtils.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/MarkerResolutionUtils.java 2012-02-02 01:40:01 UTC (rev 38389)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/MarkerResolutionUtils.java 2012-02-02 01:54:03 UTC (rev 38390)
@@ -274,7 +274,7 @@
spaces += SPACE;
}
- String text = "";
+ String text = lineSeparator;
for(String line : lines){
text += spaces;
text += line;
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AbstractSeamMarkerResolution.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AbstractSeamMarkerResolution.java 2012-02-02 01:40:01 UTC (rev 38389)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AbstractSeamMarkerResolution.java 2012-02-02 01:54:03 UTC (rev 38390)
@@ -81,18 +81,6 @@
}
}
- private IType getType(IJavaElement element){
- IJavaElement elem = element;
- while(elem != null){
- if(elem instanceof IType)
- return (IType)elem;
- elem = elem.getParent();
- }
- return null;
- }
-
-
-
protected boolean validateComponentName(String value){
ISeamProject seamProject = getSeamProject();
Map<String, IStatus> errors = SeamValidatorFactory.SEAM_COMPONENT_NAME_VALIDATOR.validate(value, seamProject);
12 years, 11 months
JBoss Tools SVN: r38389 - in trunk/jst/tests/org.jboss.tools.jst.web.test: .settings and 9 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2012-02-01 20:40:01 -0500 (Wed, 01 Feb 2012)
New Revision: 38389
Added:
trunk/jst/tests/org.jboss.tools.jst.web.test/.settings/
trunk/jst/tests/org.jboss.tools.jst.web.test/.settings/org.eclipse.jdt.core.prefs
trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/
trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.classpath
trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.project
trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.settings/
trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.settings/.jsdtscope
trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.settings/org.eclipse.jdt.core.prefs
trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.settings/org.eclipse.wst.common.component
trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.settings/org.eclipse.wst.common.project.facet.core.xml
trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.settings/org.eclipse.wst.jsdt.ui.superType.container
trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.settings/org.eclipse.wst.jsdt.ui.superType.name
trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/WebContent/
trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/WebContent/META-INF/
trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/WebContent/META-INF/MANIFEST.MF
trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/WebContent/WEB-INF/
trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/WebContent/WEB-INF/lib/
trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/build/
trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/build/classes/
trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/inputUserName.jsp
trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/src/
trunk/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/WebUtil2Test.java
trunk/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/WebUtil2TestSetup.java
Modified:
trunk/jst/tests/org.jboss.tools.jst.web.test/META-INF/MANIFEST.MF
trunk/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/JstWebAllTests.java
Log:
JBIDE-10739
https://issues.jboss.org/browse/JBIDE-10739
Tests are added.
Added: trunk/jst/tests/org.jboss.tools.jst.web.test/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.web.test/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.web.test/.settings/org.eclipse.jdt.core.prefs 2012-02-02 01:40:01 UTC (rev 38389)
@@ -0,0 +1,8 @@
+#Fri Sep 30 12:13:50 PDT 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Property changes on: trunk/jst/tests/org.jboss.tools.jst.web.test/.settings/org.eclipse.jdt.core.prefs
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/jst/tests/org.jboss.tools.jst.web.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.web.test/META-INF/MANIFEST.MF 2012-02-02 01:06:45 UTC (rev 38388)
+++ trunk/jst/tests/org.jboss.tools.jst.web.test/META-INF/MANIFEST.MF 2012-02-02 01:40:01 UTC (rev 38389)
@@ -16,7 +16,8 @@
org.eclipse.jst.standard.schemas,
org.eclipse.wst.common.frameworks;bundle-version="1.2.0",
org.eclipse.ui,
- org.eclipse.wst.validation;bundle-version="1.2.0"
+ org.eclipse.wst.validation;bundle-version="1.2.0",
+ org.eclipse.jface.text
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %Bundle-Vendor.0
Export-Package: org.jboss.tools.jst.web.test
Added: trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.classpath
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.classpath (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.classpath 2012-02-02 01:40:01 UTC (rev 38389)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
+ <attributes>
+ <attribute name="owner.project.facets" value="java"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
+ <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
+ <classpathentry kind="output" path="build/classes"/>
+</classpath>
Property changes on: trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.classpath
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.project
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.project (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.project 2012-02-02 01:40:01 UTC (rev 38389)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>testProjectRootAsWebContent</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.jboss.tools.jst.web.kb.kbbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
+ <nature>org.jboss.tools.jst.web.kb.kbnature</nature>
+ </natures>
+</projectDescription>
Property changes on: trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.project
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.settings/.jsdtscope
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.settings/.jsdtscope (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.settings/.jsdtscope 2012-02-02 01:40:01 UTC (rev 38389)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="WebContent"/>
+ <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
+ <attributes>
+ <attribute name="hide" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
+ <classpathentry kind="output" path=""/>
+</classpath>
Added: trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.settings/org.eclipse.jdt.core.prefs 2012-02-02 01:40:01 UTC (rev 38389)
@@ -0,0 +1,8 @@
+#Wed Feb 01 15:04:35 PST 2012
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Property changes on: trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.settings/org.eclipse.jdt.core.prefs
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.settings/org.eclipse.wst.common.component
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.settings/org.eclipse.wst.common.component (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.settings/org.eclipse.wst.common.component 2012-02-02 01:40:01 UTC (rev 38389)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-modules id="moduleCoreId" project-version="1.5.0">
+ <wb-module deploy-name="testProjectRootAsWebContent">
+ <wb-resource deploy-path="/" source-path="/"/>
+ <wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
+ <property name="context-root" value="testProjectRootAsWebContent"/>
+ <property name="java-output-path" value="/testProjectRootAsWebContent/build/classes"/>
+ </wb-module>
+</project-modules>
Added: trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.settings/org.eclipse.wst.common.project.facet.core.xml
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.settings/org.eclipse.wst.common.project.facet.core.xml (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.settings/org.eclipse.wst.common.project.facet.core.xml 2012-02-02 01:40:01 UTC (rev 38389)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <fixed facet="java"/>
+ <fixed facet="jst.web"/>
+ <fixed facet="wst.jsdt.web"/>
+ <installed facet="java" version="1.6"/>
+ <installed facet="jst.web" version="3.0"/>
+ <installed facet="wst.jsdt.web" version="1.0"/>
+</faceted-project>
Property changes on: trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.settings/org.eclipse.wst.common.project.facet.core.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.settings/org.eclipse.wst.jsdt.ui.superType.container
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.settings/org.eclipse.wst.jsdt.ui.superType.container (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.settings/org.eclipse.wst.jsdt.ui.superType.container 2012-02-02 01:40:01 UTC (rev 38389)
@@ -0,0 +1 @@
+org.eclipse.wst.jsdt.launching.baseBrowserLibrary
\ No newline at end of file
Added: trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.settings/org.eclipse.wst.jsdt.ui.superType.name
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.settings/org.eclipse.wst.jsdt.ui.superType.name (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/.settings/org.eclipse.wst.jsdt.ui.superType.name 2012-02-02 01:40:01 UTC (rev 38389)
@@ -0,0 +1 @@
+Window
\ No newline at end of file
Added: trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/WebContent/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/WebContent/META-INF/MANIFEST.MF (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/WebContent/META-INF/MANIFEST.MF 2012-02-02 01:40:01 UTC (rev 38389)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on: trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/WebContent/META-INF/MANIFEST.MF
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/inputUserName.jsp
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/inputUserName.jsp (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.web.test/projects/testProjectRootAsWebContent/inputUserName.jsp 2012-02-02 01:40:01 UTC (rev 38389)
@@ -0,0 +1,29 @@
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+
+<f:loadBundle var="Message" basename="demo.Messages"/>
+
+<html>
+ <head>
+ <title>Input User Name Page</title>
+ </head>
+ <body>
+
+ <f:view>
+ <h1><h:outputText value="#{Message.header}" id="q"/></h1>
+
+ <h:messages style="color: red"/>
+
+ <h:form id="greetingForm">
+ <h:outputText value="#{Message.header}"/>
+ <h:inputText value="#{user.name}" required="true">
+ <f:validateLength maximum="30" minimum="3"/>
+ </h:inputText>
+
+ <h:commandButton action="hello" value="Say Hello!" />
+
+ </h:form>
+ </f:view>
+ </body>
+</html>
\ No newline at end of file
Modified: trunk/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/JstWebAllTests.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/JstWebAllTests.java 2012-02-02 01:06:45 UTC (rev 38388)
+++ trunk/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/JstWebAllTests.java 2012-02-02 01:40:01 UTC (rev 38389)
@@ -29,6 +29,8 @@
WebUtilTest.class,
WebAppHelperTest.class,
WebXMLValidationTest.class)));
+ suite.addTest(new WebUtil2TestSetup(new TestSuite(
+ WebUtil2Test.class)));
return suite;
}
}
\ No newline at end of file
Added: trunk/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/WebUtil2Test.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/WebUtil2Test.java (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/WebUtil2Test.java 2012-02-02 01:40:01 UTC (rev 38389)
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.test;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.jboss.tools.common.base.test.validation.TestUtil;
+import org.jboss.tools.jst.web.WebUtils;
+import org.jboss.tools.jst.web.kb.PageContextFactory;
+import org.jboss.tools.test.util.ResourcesUtils;
+
+/**
+ * Tests for a project that declares its root as the web root.
+ *
+ * @author Viacheslav Kabanovich
+ */
+public class WebUtil2Test extends TestCase {
+
+ private IProject project;
+
+ @Override
+ protected void setUp() throws Exception {
+ project = getTestProject();
+ }
+
+ public IProject getTestProject() {
+ if(project==null) {
+ try {
+ project = WebUtil2TestSetup.findTestProject();
+ if(project==null || !project.exists()) {
+ project = ResourcesUtils.importProject(JstWebAllTests.PLUGIN_ID, WebUtil2TestSetup.PROJECT_PATH);
+ TestUtil._waitForValidation(project);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Can't import CDI test project: " + e.getMessage()); //$NON-NLS-1$
+ }
+ }
+ return project;
+ }
+
+ /**
+ * This test should correctly find web root in the case when it is the same as the project root.
+ * See https://issues.jboss.org/browse/JBIDE-10739
+ *
+ * @throws Exception
+ */
+ public void testGetWebRootFolder() throws Exception {
+ IContainer[] roots = WebUtils.getWebRootFolders(getTestProject());
+ assertEquals(1, roots.length);
+ assertEquals(getTestProject(), roots[0]);
+
+ IPath path = org.jboss.tools.common.web.WebUtils.getFirstWebContentPath(getTestProject());
+ assertEquals(getTestProject().getFullPath(), path);
+ }
+
+ /**
+ * This test should not throw exception 'Path must include project and resource name'
+ * See https://issues.jboss.org/browse/JBIDE-10739
+ *
+ * @throws Exception
+ */
+ public void testFileFromProject() throws Exception {
+ IFile f = getTestProject().getFile("inputUserName.jsp"); //$NON-NLS-1$
+ IFile f1 = PageContextFactory.getFileFromProject(f.getName(), f);
+ assertNotNull(f1);
+
+ f1 = PageContextFactory.getFileFromProject("abc.jsp", f);
+ assertNull(f1);
+ }
+}
\ No newline at end of file
Property changes on: trunk/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/WebUtil2Test.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/WebUtil2TestSetup.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/WebUtil2TestSetup.java (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/WebUtil2TestSetup.java 2012-02-02 01:40:01 UTC (rev 38389)
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.test;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.jboss.tools.common.base.test.validation.TestUtil;
+import org.jboss.tools.test.util.JobUtils;
+import org.jboss.tools.test.util.ResourcesUtils;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public class WebUtil2TestSetup extends TestSetup {
+ static String PROJECT_NAME = "testProjectRootAsWebContent"; //$NON-NLS-1$
+ static String PROJECT_PATH = "/projects/" + PROJECT_NAME; //$NON-NLS-1$
+
+ protected IProject project;
+
+ public WebUtil2TestSetup(Test test) {
+ super(test);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ project = getTestProject();
+ boolean state = ResourcesUtils.setBuildAutomatically(false);
+ project.build(IncrementalProjectBuilder.FULL_BUILD, null);
+ TestUtil._waitForValidation(project);
+ ResourcesUtils.setBuildAutomatically(state);
+ }
+
+ public IProject getTestProject() {
+ if(project==null) {
+ try {
+ project = findTestProject();
+ if(project==null || !project.exists()) {
+ project = ResourcesUtils.importProject(JstWebAllTests.PLUGIN_ID, PROJECT_PATH);
+ TestUtil._waitForValidation(project);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Can't import test project: " + e.getMessage()); //$NON-NLS-1$
+ }
+ }
+ return project;
+ }
+
+ public static IProject findTestProject() {
+ return ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ boolean saveAutoBuild = ResourcesUtils.setBuildAutomatically(false);
+ project.delete(true, true, null);
+ JobUtils.waitForIdle();
+ ResourcesUtils.setBuildAutomatically(saveAutoBuild);
+ }
+}
\ No newline at end of file
Property changes on: trunk/jst/tests/org.jboss.tools.jst.web.test/src/org/jboss/tools/jst/web/test/WebUtil2TestSetup.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
12 years, 11 months