JBoss Tools SVN: r14301 - in workspace/dart/plugins/org.jboss.tools.smooks.testui: src/org/smooks/tools/testui and 4 other directories.
by jbosstools-commits@lists.jboss.org
Author: DartPeng
Date: 2009-03-23 19:47:09 -0400 (Mon, 23 Mar 2009)
New Revision: 14301
Added:
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/popup/
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/popup/actions/
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/popup/actions/NewAction.java
Modified:
workspace/dart/plugins/org.jboss.tools.smooks.testui/plugin.xml
workspace/dart/…
[View More]plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/java/JavaBeanInstanceModel.java
workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/views/SmooksTestEditor.java
Log:
Modified: workspace/dart/plugins/org.jboss.tools.smooks.testui/plugin.xml
===================================================================
--- workspace/dart/plugins/org.jboss.tools.smooks.testui/plugin.xml 2009-03-23 23:47:00 UTC (rev 14300)
+++ workspace/dart/plugins/org.jboss.tools.smooks.testui/plugin.xml 2009-03-23 23:47:09 UTC (rev 14301)
@@ -3,20 +3,6 @@
<plugin>
<extension
- point="org.eclipse.ui.views">
- <category
- name="Smooks"
- id="org.smooks.tools.testui">
- </category>
- <view
- name="Smooks Test View"
- icon="icons/sample.gif"
- category="org.smooks.tools.testui"
- class="org.smooks.tools.testui.views.TestProjectsView"
- id="org.smooks.tools.testui.views.TestProjectView1">
- </view>
- </extension>
- <extension
point="org.eclipse.ui.editors">
<editor
class="org.smooks.tools.testui.editors.SmooksTestMultiPageEditor"
@@ -25,5 +11,27 @@
name="Smooks Test Editor">
</editor>
</extension>
+ <extension
+ point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ id="org.smooks.tools.testui.contribution1"
+ objectClass="org.eclipse.core.resources.IFile">
+ <menu
+ id="org.smooks.tools.testui.menu1"
+ label="New Submenu"
+ path="additions">
+ <separator
+ name="group1">
+ </separator>
+ </menu>
+ <action
+ class="org.smooks.tools.testui.popup.actions.NewAction"
+ enablesFor="1"
+ id="org.smooks.tools.testui.newAction"
+ label="New Action"
+ menubarPath="org.smooks.tools.testui.menu1/group1">
+ </action>
+ </objectContribution>
+ </extension>
</plugin>
Modified: workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/java/JavaBeanInstanceModel.java
===================================================================
--- workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/java/JavaBeanInstanceModel.java 2009-03-23 23:47:00 UTC (rev 14300)
+++ workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/java/JavaBeanInstanceModel.java 2009-03-23 23:47:09 UTC (rev 14301)
@@ -72,7 +72,7 @@
protected void createArrayChildren(Class<Object> clazz, String name,
PropertyDescriptor pd, Class<? extends Object> parentClass,
boolean lazyLoad) {
- if(instanceModel.getClass().isArray()){
+ if(instanceModel != null && instanceModel.getClass().isArray()){
Object[] objs = (Object[])instanceModel;
for (int i = 0; i < objs.length; i++) {
Object obj = objs[i];
Added: workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/popup/actions/NewAction.java
===================================================================
--- workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/popup/actions/NewAction.java (rev 0)
+++ workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/popup/actions/NewAction.java 2009-03-23 23:47:09 UTC (rev 14301)
@@ -0,0 +1,76 @@
+package org.smooks.tools.testui.popup.actions;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
+import org.jboss.tools.smooks.ui.editors.SmooksFileEditorInput;
+
+public class NewAction implements IObjectActionDelegate {
+
+ private ISelection selection = null;
+ private IWorkbenchPart workbenchPart = null;
+
+ /**
+ * Constructor for Action1.
+ */
+ public NewAction() {
+ super();
+ }
+
+ /**
+ * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ this.workbenchPart = targetPart;
+ }
+
+ /**
+ * @see IActionDelegate#run(IAction)
+ */
+ public void run(IAction action) {
+ if (selection != null) {
+ SmooksFileEditorInput input = null;
+ Object element = ((IStructuredSelection) selection)
+ .getFirstElement();
+ if (element instanceof IFile) {
+ input = new SmooksFileEditorInput((IFile) element);
+ } else {
+ if (element instanceof IAdaptable) {
+ Object newFile = ((IAdaptable) element)
+ .getAdapter(IResource.class);
+ if (newFile instanceof IFile) {
+ input = new SmooksFileEditorInput((IFile) newFile);
+ }
+ }
+ }
+ try {
+ if (this.workbenchPart != null) {
+ workbenchPart
+ .getSite()
+ .getWorkbenchWindow()
+ .getActivePage()
+ .openEditor(input,
+ "org.smooks.tools.testui.editors.SmooksTestEditor");
+
+ }
+ } catch (PartInitException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * @see IActionDelegate#selectionChanged(IAction, ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ this.selection = selection;
+ }
+
+}
Property changes on: workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/popup/actions/NewAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/views/SmooksTestEditor.java
===================================================================
--- workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/views/SmooksTestEditor.java 2009-03-23 23:47:00 UTC (rev 14300)
+++ workspace/dart/plugins/org.jboss.tools.smooks.testui/src/org/smooks/tools/testui/views/SmooksTestEditor.java 2009-03-23 23:47:09 UTC (rev 14301)
@@ -40,6 +40,7 @@
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.EditorPart;
+import org.eclipse.ui.part.FileEditorInput;
import org.jboss.tools.smooks.graphical.GraphInformations;
import org.jboss.tools.smooks.graphical.Param;
import org.jboss.tools.smooks.graphical.Params;
[View Less]
15 years, 11 months
JBoss Tools SVN: r14299 - in trunk/smooks/plugins/org.jboss.tools.smooks.ui: src/org/jboss/tools/smooks/graphical/util and 6 other directories.
by jbosstools-commits@lists.jboss.org
Author: DartPeng
Date: 2009-03-23 19:43:00 -0400 (Mon, 23 Mar 2009)
New Revision: 14299
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksConstants.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2xml/XML2XMLConnectionSection.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2xml/XML2XMLSectionFilter.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/…
[View More]xml2xml/ui/
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/util/GraphicalInformationSaver.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/AbstractSmooksPropertySection.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/LineConnectionSectionFilter.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksResourceChangeListener.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksUIActivator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksNewWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/AbstractXMLModelAnalyzer.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2xml/XML2XMLAnalyzer.java
Log:
JBIDE-2870
Add new feature for x2x
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml 2009-03-23 23:07:59 UTC (rev 14298)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml 2009-03-23 23:43:00 UTC (rev 14299)
@@ -17,7 +17,7 @@
point="org.eclipse.ui.editors">
<editor
name="Smooks Editor"
- extensions="smooks"
+ extensions="xml"
icon="icons/smooks-sm.gif"
class="org.jboss.tools.smooks.ui.editors.SmooksFormEditor"
id="org.jboss.tools.smooks.ui.editors.SmooksFormEditor">
@@ -61,6 +61,12 @@
id="org.jboss.tools.smooks.ui.connection.beanpopulator.section"
tab="org.jboss.tools.smooks.ui.connection.beanpopulator.propertyTab">
</propertySection>
+ <propertySection
+ class="org.jboss.tools.smooks.xml2xml.XML2XMLConnectionSection"
+ filter="org.jboss.tools.smooks.xml2xml.XML2XMLSectionFilter"
+ id="org.jboss.tools.smooks.ui.xml2xml.propertySection"
+ tab="org.jboss.tools.smooks.ui.xml2xml.propertySection.tab">
+ </propertySection>
</propertySections>
</extension>
<extension
@@ -104,6 +110,11 @@
id="org.jboss.tools.smooks.ui.connection.beanpopulator.propertyTab"
label="BeanPopulator Connection">
</propertyTab>
+ <propertyTab
+ category="connection"
+ id="org.jboss.tools.smooks.ui.xml2xml.propertySection.tab"
+ label="XML2XML Properties">
+ </propertyTab>
</propertyTabs>
</extension>
<extension
@@ -244,7 +255,7 @@
point="org.eclipse.core.contenttype.contentTypes">
<content-type
base-type="org.eclipse.core.runtime.xml"
- file-extensions="smooks"
+ file-extensions="xml"
id="org.jboss.tools.smooks.ui.smooks.contentType"
name="Smooks Configuration File"
priority="normal">
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/util/GraphicalInformationSaver.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/util/GraphicalInformationSaver.java 2009-03-23 23:07:59 UTC (rev 14298)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/util/GraphicalInformationSaver.java 2009-03-23 23:43:00 UTC (rev 14299)
@@ -34,6 +34,7 @@
import org.jboss.tools.smooks.graphical.MappingDataType;
import org.jboss.tools.smooks.graphical.Param;
import org.jboss.tools.smooks.graphical.Params;
+import org.jboss.tools.smooks.ui.SmooksConstants;
import org.jboss.tools.smooks.ui.modelparser.SmooksConfigurationFileGenerateContext;
/**
@@ -58,8 +59,8 @@
IFile file = ((IFileEditorInput) input).getFile();
IContainer container = file.getParent();
String fileName = file.getName();
- if (fileName.endsWith(".smooks")) {
- String gfileName = fileName + ".graph";
+ if (fileName.endsWith(SmooksConstants.SMOOKS_EXTENTION_NAME_WITHDOT)) {
+ String gfileName = fileName + SmooksConstants.SMOOKS_GRAPH_EXTENTION_NAME_WITHDOT;
if (container != null) {
IFile gfile = container.getFile(new Path(gfileName));
if (!gfile.exists()) {
@@ -83,8 +84,8 @@
public GraphicalInformationSaver(IFile file) {
IContainer container = file.getParent();
String fileName = file.getName();
- if (fileName.endsWith(".smooks")) {
- String gfileName = fileName + ".graph";
+ if (fileName.endsWith(SmooksConstants.SMOOKS_EXTENTION_NAME_WITHDOT)) {
+ String gfileName = fileName + SmooksConstants.SMOOKS_GRAPH_EXTENTION_NAME_WITHDOT;
if (container != null) {
IFile gfile = container.getFile(new Path(gfileName));
if (!gfile.exists()) {
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModel.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModel.java 2009-03-23 23:07:59 UTC (rev 14298)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModel.java 2009-03-23 23:43:00 UTC (rev 14299)
@@ -35,6 +35,8 @@
public class JavaBeanModel implements IValidatable, IXMLStructuredObject,
Cloneable, ITransformTreeNode {
+ private boolean flat = false;
+
private Properties extendProperties = new Properties();
protected PropertyChangeSupport support = new PropertyChangeSupport(this);
@@ -82,6 +84,14 @@
return isRootClassModel || getParent() == null;
}
+ public boolean isFlat() {
+ return flat;
+ }
+
+ public void setFlat(boolean flat) {
+ this.flat = flat;
+ }
+
/**
* @param isRootClassModel
* the isRootClassModel to set
@@ -220,8 +230,10 @@
if (returnType instanceof ParameterizedType) {
Type gtype = ((ParameterizedType) returnType)
.getActualTypeArguments()[0];
- beanType = (Class) gtype;
- componentClass = beanType;
+ if (gtype instanceof Class) {
+ beanType = (Class) gtype;
+ componentClass = beanType;
+ }
}
}
}
@@ -344,7 +356,11 @@
private List properties;
public List getProperties() {
-
+ JavaBeanModel parent = this.getParent();
+ if (parent != null) {
+ if (parent.isFlat())
+ return Collections.emptyList();
+ }
if (properties == null) {
properties = new ArrayList();
if (isPrimitive())
@@ -399,8 +415,7 @@
protected JavaBeanModel newChildJavaBean(Class clazz, String name,
PropertyDescriptor pd, Class parentClass, boolean lazyLoading) {
- return new JavaBeanModel(clazz, name, pd, parentClass,
- lazyLoading);
+ return new JavaBeanModel(clazz, name, pd, parentClass, lazyLoading);
}
public void setProperties(List properties) {
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/AbstractSmooksPropertySection.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/AbstractSmooksPropertySection.java 2009-03-23 23:07:59 UTC (rev 14298)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/AbstractSmooksPropertySection.java 2009-03-23 23:43:00 UTC (rev 14299)
@@ -17,6 +17,7 @@
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
import org.jboss.tools.smooks.ui.editors.SmooksFormEditor;
import org.jboss.tools.smooks.ui.editors.SmooksGraphicalFormPage;
+import org.jboss.tools.smooks.ui.gef.model.AbstractStructuredDataModel;
import org.jboss.tools.smooks.ui.gef.model.LineConnectionModel;
/**
@@ -82,7 +83,30 @@
}
return null;
}
+
+ protected Object getReferenceSourceModel() {
+ LineConnectionModel line = getLineConnectionModel();
+ if (line != null) {
+ AbstractStructuredDataModel s = (AbstractStructuredDataModel) line
+ .getSource();
+ if (s != null)
+ return s.getReferenceEntityModel();
+ }
+ return null;
+ }
+ protected Object getReferenceTargetModel() {
+ LineConnectionModel line = getLineConnectionModel();
+ if (line != null) {
+ AbstractStructuredDataModel s = (AbstractStructuredDataModel) line
+ .getTarget();
+ if (s != null)
+ return s.getReferenceEntityModel();
+ }
+ return null;
+ }
+
+
public boolean isLock() {
return lock;
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/LineConnectionSectionFilter.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/LineConnectionSectionFilter.java 2009-03-23 23:07:59 UTC (rev 14298)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/LineConnectionSectionFilter.java 2009-03-23 23:43:00 UTC (rev 14299)
@@ -15,7 +15,8 @@
* @see org.eclipse.jface.viewers.IFilter#select(java.lang.Object)
*/
public boolean select(Object toTest) {
- return false;
+ // for debug
+ return true;
}
}
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksConstants.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksConstants.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksConstants.java 2009-03-23 23:43:00 UTC (rev 14299)
@@ -0,0 +1,18 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.ui;
+
+/**
+ * @author DartPeng
+ *
+ */
+public class SmooksConstants {
+ public static final String SMOOKS_EXTENTION_NAME = "xml";
+
+ public static final String SMOOKS_EXTENTION_NAME_WITHDOT = "." + SMOOKS_EXTENTION_NAME;
+
+ public static final String SMOOKS_GRAPH_EXTENTION_NAME = "graph";
+
+ public static final String SMOOKS_GRAPH_EXTENTION_NAME_WITHDOT = "." +SMOOKS_GRAPH_EXTENTION_NAME;
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksConstants.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksResourceChangeListener.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksResourceChangeListener.java 2009-03-23 23:07:59 UTC (rev 14298)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksResourceChangeListener.java 2009-03-23 23:43:00 UTC (rev 14299)
@@ -17,7 +17,6 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
@@ -110,9 +109,7 @@
public boolean visit(IResourceDelta delta) {
IResource res = delta.getResource();
String fileExtension = res.getFileExtension();
- if (!Messages
- .getString(
- "SmooksResourceChangeListener.SmooksFileExtensionName").equals(fileExtension)) { //$NON-NLS-1$
+ if (!SmooksConstants.SMOOKS_EXTENTION_NAME.equals(fileExtension)) { //$NON-NLS-1$
return true;
}
int flags = delta.getFlags();
@@ -128,21 +125,17 @@
fileExtension = fileName.substring(dotIndex + 1,
fileName.length());
}
- if (!Messages
- .getString(
- "SmooksResourceChangeListener.SmooksFileExtensionName").equals(fileExtension)) { //$NON-NLS-1$
+ if (!SmooksConstants.SMOOKS_EXTENTION_NAME.equals(fileExtension)) { //$NON-NLS-1$
return true;
}
- fileName += Messages
- .getString("SmooksResourceChangeListener.SmooksGraphFileExtensionName"); //$NON-NLS-1$
+ fileName += SmooksConstants.SMOOKS_GRAPH_EXTENTION_NAME_WITHDOT; //$NON-NLS-1$
path = path.removeLastSegments(1);
path = path.append(fileName);
}
IPath newPath = res.getFullPath();
fileName = newPath.lastSegment();
- fileName += Messages
- .getString("SmooksResourceChangeListener.SmooksGraphFileExtensionName"); //$NON-NLS-1$
+ fileName += SmooksConstants.SMOOKS_GRAPH_EXTENTION_NAME_WITHDOT; //$NON-NLS-1$
newPath = newPath.removeLastSegments(1).append(fileName);
newFile(path, newPath);
}
@@ -170,8 +163,7 @@
}
IPath path = res.getFullPath();
String fileName = path.lastSegment();
- fileName += Messages
- .getString("SmooksResourceChangeListener.SmooksGraphFileExtensionName"); //$NON-NLS-1$
+ fileName += SmooksConstants.SMOOKS_GRAPH_EXTENTION_NAME_WITHDOT; //$NON-NLS-1$
path = path.removeLastSegments(1).append(fileName);
deleteFile(path);
break;
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksUIActivator.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksUIActivator.java 2009-03-23 23:07:59 UTC (rev 14298)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/SmooksUIActivator.java 2009-03-23 23:43:00 UTC (rev 14299)
@@ -2,7 +2,6 @@
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
-import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.jboss.tools.smooks.javabean.ui.JavaImageConstants;
import org.jboss.tools.smooks.utils.SmooksGraphConstants;
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizardPage.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizardPage.java 2009-03-23 23:07:59 UTC (rev 14298)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizardPage.java 2009-03-23 23:43:00 UTC (rev 14299)
@@ -246,6 +246,20 @@
}
});
+
+ Button x2xButton = new Button(mainComposite,SWT.RADIO);
+ x2xButton.setText("XML-to-XML(XSL inner)");
+ x2xButton.addSelectionListener(new SelectionAdapter(){
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setPageComplete(true);
+ setSourceID("org.jboss.tools.smooks.xml.viewerInitor.xml");
+ setTargetID("org.jboss.tools.smooks.xml.viewerInitor.xml");
+ getContainer().updateButtons();
+ }
+
+ });
setPageComplete(false);
// GridLayout gl = new GridLayout();
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizardPage.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizardPage.java 2009-03-23 23:07:59 UTC (rev 14298)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizardPage.java 2009-03-23 23:43:00 UTC (rev 14299)
@@ -7,6 +7,7 @@
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+import org.jboss.tools.smooks.ui.SmooksConstants;
/**
*
@@ -17,10 +18,10 @@
public SmooksConfigFileNewWizardPage(String pageName,
IStructuredSelection selection) {
super(pageName, selection);
- setFileExtension("smooks"); //$NON-NLS-1$
+ setFileExtension(SmooksConstants.SMOOKS_EXTENTION_NAME); //$NON-NLS-1$
super.setTitle(Messages.getString("SmooksConfigFileNewWizardPage.NewConfigFileWizardPageTitle")); //$NON-NLS-1$
super.setDescription(Messages.getString("SmooksConfigFileNewWizardPage.NewConfigFileWizardPageDescription")); //$NON-NLS-1$
- this.setFileName(Messages.getString("SmooksConfigFileNewWizardPage.NewConfigFileWizardPageDefaultFileName")); //$NON-NLS-1$
+ this.setFileName("smooks-config.xml"); //$NON-NLS-1$
}
@Override
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksNewWizardPage.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksNewWizardPage.java 2009-03-23 23:07:59 UTC (rev 14298)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksNewWizardPage.java 2009-03-23 23:43:00 UTC (rev 14299)
@@ -22,6 +22,7 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.ContainerSelectionDialog;
+import org.jboss.tools.smooks.ui.SmooksConstants;
/**
* @deprecated
@@ -148,7 +149,7 @@
containerText.setText(container.getFullPath().toString());
}
}
- fileText.setText("smooks-config.smooks");
+ fileText.setText("smooks-config" + SmooksConstants.SMOOKS_EXTENTION_NAME_WITHDOT);
}
/**
@@ -209,7 +210,7 @@
if (dotLoc != -1) {
String ext = fileName.substring(dotLoc + 1);
if (ext.equalsIgnoreCase("smooks") == false) {
- updateStatus("File extension must be \"smooks\"");
+ updateStatus("File extension must be \""+SmooksConstants.SMOOKS_EXTENTION_NAME+"\"");
return;
}
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/AbstractXMLModelAnalyzer.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/AbstractXMLModelAnalyzer.java 2009-03-23 23:07:59 UTC (rev 14298)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/AbstractXMLModelAnalyzer.java 2009-03-23 23:43:00 UTC (rev 14299)
@@ -190,7 +190,10 @@
private String processXSLFragmentString(String cdata) {
// cdata = cdata.replaceAll(":", "-");
int start_index = cdata.indexOf("<");
- int end_index = cdata.indexOf(">");
+ int end_index = cdata.indexOf("/>");
+ if (end_index == -1) {
+ end_index = cdata.indexOf(">");
+ }
if (start_index == -1 || end_index == -1)
return cdata;
String contents = cdata.substring(start_index, end_index);
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2xml/XML2XMLAnalyzer.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2xml/XML2XMLAnalyzer.java 2009-03-23 23:07:59 UTC (rev 14298)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2xml/XML2XMLAnalyzer.java 2009-03-23 23:43:00 UTC (rev 14299)
@@ -376,7 +376,10 @@
// cdata = cdata.replace(":", "-");
// return cdata;
int start_index = cdata.indexOf("<");
- int end_index = cdata.indexOf(">");
+ int end_index = cdata.indexOf("/>");
+ if(end_index == -1){
+ end_index = cdata.indexOf(">");
+ }
if (start_index == -1 || end_index == -1)
return cdata;
String contents = cdata.substring(start_index, end_index);
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2xml/XML2XMLConnectionSection.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2xml/XML2XMLConnectionSection.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2xml/XML2XMLConnectionSection.java 2009-03-23 23:43:00 UTC (rev 14299)
@@ -0,0 +1,128 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.xml2xml;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+import org.jboss.tools.smooks.ui.AbstractSmooksPropertySection;
+import org.jboss.tools.smooks.ui.gef.model.LineConnectionModel;
+import org.jboss.tools.smooks.ui.gef.model.PropertyModel;
+import org.jboss.tools.smooks.xml.model.TagObject;
+import org.jboss.tools.smooks.xml.model.TagPropertyObject;
+import org.jboss.tools.smooks.xml.ui.XMLPropertiesSection;
+
+/**
+ * @author DartPeng
+ *
+ */
+public class XML2XMLConnectionSection extends AbstractSmooksPropertySection {
+
+ private Button mappingButton;
+ private Button bindingButton;
+
+ public void createControls(Composite parent,
+ TabbedPropertySheetPage tabbedPropertySheetPage) {
+ super.createControls(parent, tabbedPropertySheetPage);
+ TabbedPropertySheetWidgetFactory factory = tabbedPropertySheetPage
+ .getWidgetFactory();
+
+ Section section = createRootSection(factory, parent);
+ section.setText("XML2XML Properties"); //$NON-NLS-1$
+ Composite controlComposite = factory.createComposite(section);
+ section.setClient(controlComposite);
+
+ GridLayout gl = new GridLayout();
+ gl.numColumns = 2;
+
+ controlComposite.setLayout(gl);
+
+ mappingButton = factory.createButton(controlComposite, "Mapping Type",
+ SWT.RADIO);
+ bindingButton = factory.createButton(controlComposite, "Binding Type",
+ SWT.RADIO);
+
+ hookButton();
+ }
+
+ private void hookButton() {
+ mappingButton.addSelectionListener(new SelectionAdapter(){
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if(isLock()) return;
+ if(mappingButton.getSelection()) return;
+ Object obj = getReferenceSourceModel();
+ if(obj instanceof TagPropertyObject){
+ return;
+ }
+ PropertyModel pro = new PropertyModel(XMLPropertiesSection.MAPPING_TYPE,XMLPropertiesSection.MAPPING);
+ LineConnectionModel line = getLineConnectionModel();
+ if(line != null){
+ line.addPropertyModel(pro);
+ fireDirty();
+ }
+ }
+
+ });
+ bindingButton.addSelectionListener(new SelectionAdapter(){
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if(isLock()) return;
+ if(bindingButton.getSelection()) return;
+ Object obj = getReferenceSourceModel();
+ if(obj instanceof TagObject){
+ return;
+ }
+ PropertyModel pro = new PropertyModel(XMLPropertiesSection.MAPPING_TYPE,XMLPropertiesSection.BINDING);
+ LineConnectionModel line = getLineConnectionModel();
+ if(line != null){
+ line.addPropertyModel(pro);
+ fireDirty();
+ }
+ }
+
+ });
+ }
+
+
+ @Override
+ public void refresh() {
+ lockEventFire();
+ LineConnectionModel line = getLineConnectionModel();
+ if (line != null) {
+ Object mapping = line
+ .getProperty(XMLPropertiesSection.MAPPING_TYPE);
+ Object sourceModel = getReferenceSourceModel();
+ Object targetModel = getReferenceTargetModel();
+ mappingButton.setEnabled(true);
+ bindingButton.setEnabled(true);
+ if(sourceModel instanceof TagObject){
+ mappingButton.setEnabled(true);
+ bindingButton.setEnabled(false);
+ }
+ if(sourceModel instanceof TagPropertyObject){
+ mappingButton.setEnabled(false);
+ bindingButton.setEnabled(true);
+ }
+ if (XMLPropertiesSection.MAPPING.equals(mapping)) {
+ mappingButton.setSelection(true);
+ bindingButton.setSelection(false);
+ }
+ if (XMLPropertiesSection.BINDING.equals(mapping)) {
+ mappingButton.setSelection(false);
+ bindingButton.setSelection(true);
+ }
+ }
+ unLockEventFire();
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2xml/XML2XMLConnectionSection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2xml/XML2XMLSectionFilter.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2xml/XML2XMLSectionFilter.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2xml/XML2XMLSectionFilter.java 2009-03-23 23:43:00 UTC (rev 14299)
@@ -0,0 +1,24 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.xml2xml;
+
+import org.jboss.tools.smooks.ui.AbstractConnectionModelSectionFilter;
+import org.jboss.tools.smooks.xml.model.AbstractXMLObject;
+
+/**
+ * @author DartPeng
+ *
+ */
+public class XML2XMLSectionFilter extends AbstractConnectionModelSectionFilter {
+
+ public boolean select(Object toTest) {
+ Object source = getReferenceSourceObject(toTest);
+ Object target = getReferenceTargetObject(toTest);
+ if (source instanceof AbstractXMLObject
+ && target instanceof AbstractXMLObject)
+ return true;
+ return false;
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2xml/XML2XMLSectionFilter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
[View Less]
15 years, 11 months
JBoss Tools SVN: r14298 - trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/META-INF.
by jbosstools-commits@lists.jboss.org
Author: Grid.Qian
Date: 2009-03-23 19:07:59 -0400 (Mon, 23 Mar 2009)
New Revision: 14298
Modified:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/META-INF/MANIFEST.MF
Log:
GPD290: export the jpdl editor for multipage editor
Modified: trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/META-INF/MANIFEST.MF
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/META-INF/MANIFEST.MF 2009-03-23 19:32:22 UTC (rev 14297)
+++ trunk/jbpm/…
[View More]plugins/org.jboss.tools.flow.jpdl4/META-INF/MANIFEST.MF 2009-03-23 23:07:59 UTC (rev 14298)
@@ -14,5 +14,6 @@
org.eclipse.ui.views.properties.tabbed;bundle-version="3.4.1"
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.jboss.tools.flow.jpdl4.Activator
-Export-Package: org.jboss.tools.flow.jpdl4.model
+Export-Package: org.jboss.tools.flow.jpdl4.editor,
+ org.jboss.tools.flow.jpdl4.model
Bundle-Localization: plugin
[View Less]
15 years, 11 months
JBoss Tools SVN: r14297 - branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common.
by jbosstools-commits@lists.jboss.org
Author: sdzmitrovich
Date: 2009-03-23 15:32:22 -0400 (Mon, 23 Mar 2009)
New Revision: 14297
Modified:
branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/CSSModel.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3920,https://jira.jboss.org/jira...
Modified: branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/CSSModel.java
===========================================…
[View More]========================
--- branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/CSSModel.java 2009-03-23 19:09:50 UTC (rev 14296)
+++ branches/jbosstools-3.0.x/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/CSSModel.java 2009-03-23 19:32:22 UTC (rev 14297)
@@ -1,430 +1,442 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and 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:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.jsp.outline.cssdialog.common;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
-
-import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.filebuffers.IFileBuffer;
-import org.eclipse.core.filebuffers.LocationKind;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension3;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.wst.css.core.internal.format.FormatProcessorCSS;
-import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument;
-import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
-import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
-import org.eclipse.wst.css.core.internal.provisional.document.ICSSRuleContainer;
-import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet;
-import org.eclipse.wst.css.core.internal.text.StructuredTextPartitionerForCSS;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.provisional.exceptions.ResourceInUse;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredPartitioning;
-import org.jboss.tools.jst.jsp.JspEditorPlugin;
-import org.jboss.tools.jst.jsp.outline.cssdialog.events.StyleAttributes;
-import org.w3c.dom.css.CSSRuleList;
-import org.w3c.dom.css.CSSStyleDeclaration;
-import org.w3c.dom.css.CSSStyleRule;
-import org.w3c.dom.css.CSSStyleSheet;
-
-/**
- * CSS class model.
- *
- *
- */
-public class CSSModel {
-
- private static String startBraces = "{"; //$NON-NLS-1$
- private static String endBraces = "}"; //$NON-NLS-1$
-
- private FormatProcessorCSS formatProcessorCSS = null;
- private IStructuredModel model = null;
- private IFile styleFile = null;
-
- private CSSStyleSheet styleSheet = null;
- private ICSSStyleSheet eclipseStyleSheet = null;
- private String COPY_SUFFIX = "_copy";
- private boolean copy = false;
-
-
- /**
- * Constructor.
- *
- * @param styleFile CSS style class that should initialize CSS model
- */
- public CSSModel(IFile styleFile) {
- init(styleFile);
- }
-
- public void init(IFile styleFile) {
- try {
- this.styleFile = styleFile;
- if (model != null) {
- releaseModel();
- }
- copy = false;
- formatProcessorCSS = new FormatProcessorCSS();
- IModelManager modelManager = StructuredModelManager.getModelManager();
- model = modelManager.getExistingModelForEdit(styleFile);
-
-
- if (model == null)
- model = modelManager.getModelForEdit(styleFile);
- else {
-
- copy = true;
- // copy the model
- model = modelManager.copyModelForEdit(model.getId(), model
- .getId()
- + COPY_SUFFIX);
-
- // set the correct location
- model.setBaseLocation(styleFile.getLocation().toString());
-
- // some steps to prepare document ( it is necessary to correct
- // work of highlight in preview tab )
- IDocumentPartitioner partitioner = new StructuredTextPartitionerForCSS();
- ((IDocumentExtension3) model.getStructuredDocument())
- .setDocumentPartitioner(
- IStructuredPartitioning.DEFAULT_STRUCTURED_PARTITIONING,
- partitioner);
- partitioner.connect(model.getStructuredDocument());
-
- }
- if (model instanceof ICSSModel) {
- ICSSModel cssModel = (ICSSModel) model;
- ICSSDocument document = cssModel.getDocument();
- if (document instanceof CSSStyleSheet) {
- styleSheet = (CSSStyleSheet) document;
- }
- if (document instanceof ICSSStyleSheet) {
- eclipseStyleSheet = (ICSSStyleSheet) document;
- }
-
-
- }
- } catch (IOException e) {
- JspEditorPlugin.getPluginLog().logError(e.getMessage());
- } catch (CoreException e) {
- JspEditorPlugin.getPluginLog().logError(e.getMessage());
- } catch (ResourceInUse e) {
- JspEditorPlugin.getPluginLog().logError(e.getMessage());
- }
- }
-
- /**
- * Method is used to select area that corresponds to specific selector.
- *
- * @param selector the selector that should be selected in editor area
- * @param index if CSS file contains more then one elements with the same selector name,
- * then index is serial number of this selector
- */
- public IndexedRegion getSelectorRegion(String selector, int index) {
- //FIXED by sdzmitrovich - JBIDE-3148
-// if (eclipseStyleSheet != null) {
-// if (selector != null && !selector.equals(Constants.EMPTY)) {
-// ICSSStyleRule styleRule = Util.getSelector(eclipseStyleSheet, selector, index);
-// if (styleRule != null) {
-// if (styleRule instanceof IndexedRegion) {
-// return (IndexedRegion) styleRule;
-// }
-// }
-// }
-// }
-
- if ( selector != null) {
- CSSStyleRule rule = getRulesMapping().get(selector);
- if (rule != null)
- if (rule instanceof IndexedRegion) {
- return (IndexedRegion) rule;
- }
-
- }
- return null;
- }
-
-
- public List<String> getSelectorLabels() {
-
- List<String> selectorLabels;
-
- selectorLabels = new ArrayList<String>(getRulesMapping().keySet());
-
- Collections.sort(selectorLabels);
-
- return selectorLabels;
- }
-
- /**
- * Gets CSS attributes for the given selector in string representation.
- *
- * @param selector CSS selector value
- * @return CSS attributes string representation
- */
- public String getCSSText(String selector) {
- //FIXED by sdzmitrovich - JBIDE-3148
-// if (styleSheet != null && selector != null) {
-// CSSRuleList list = styleSheet.getCssRules();
-//
-// if (list != null) {
-// for (int i = 0; i < list.getLength(); i++) {
-// if (list.item(i) instanceof CSSStyleRule &&
-// ((CSSStyleRule) list.item(i)).getSelectorText().equals(selector)) {
-// return ((CSSStyleRule) list.item(i)).getCssText();
-// }
-// }
-// }
-// }
- if ( selector != null) {
- CSSStyleRule rule = getRulesMapping().get(selector);
- if (rule != null)
- return rule.getCssText();
-
- }
-
- return null;
- }
-
- /**
- * Get style by selectorName
- *
- * @param selectorName
- * @return style
- */
- public String getStyle(String selectorName) {
- //FIXED by sdzmitrovich - JBIDE-3148
-// if (styleSheet != null) {
-// CSSRuleList list = styleSheet.getCssRules();
-//
-// if (list != null) {
-// for (int i = 0; i < list.getLength(); i++) {
-// if (list.item(i) instanceof CSSStyleRule &&
-// ((CSSStyleRule) list.item(i)).getSelectorText().equals(selectorName)) {
-// return ((CSSStyleRule) list.item(i)).getStyle().getCssText();
-// }
-// }
-// }
-// }
- if (selectorName != null) {
- CSSStyleRule rule = getRulesMapping().get(selectorName);
- if (rule != null)
- return rule.getStyle().getCssText();
-
- }
-
- return null;
- }
-
- /**
- * Sets CSS style for the given selector.
- *
- * @param selector CSS selector value
- * @param styleAttribute the style to be set
- */
- public void setCSS(String selector, StyleAttributes styleAttributes) {
- if (styleSheet != null && selector != null && !selector.equals(Constants.EMPTY)) {
- CSSRuleList list = styleSheet.getCssRules();
- //FIXED by sdzmitrovich - JBIDE-3148
-// if (list != null) {
-// // check if selector passed by parameter already exists in CSS
-// for (int i = 0; i < list.getLength(); i++) {
-// if (list.item(i) instanceof CSSStyleRule &&
-// ((CSSStyleRule) list.item(i)).getSelectorText().equals(selector)) {
-//
-// CSSStyleRule rule = (CSSStyleRule) list.item(i);
-// styleSheet.deleteRule(i);
-//
-// i = styleSheet.insertRule(selector + startBraces + styleAttributes.getStyle() + endBraces, i);
-// rule = (CSSStyleRule) list.item(i);
-// CSSStyleDeclaration declaration = rule.getStyle();
-// // set properties
-// Set<Entry<String, String>> set = styleAttributes.entrySet();
-// for (Map.Entry<String, String> me : set) {
-// declaration.setProperty(me.getKey(), me.getValue(), Constants.EMPTY);
-// }
-//
-// formatProcessorCSS.formatModel(model);
-// return;
-// }
-// }
-// // insert NEW selector to style sheet
-// styleSheet.insertRule(selector + startBraces + styleAttributes.getStyle() + endBraces, list.getLength());
-// formatProcessorCSS.formatModel(model);
- CSSStyleRule rule = getRulesMapping().get(selector);
- if (rule == null) {
- rule = (CSSStyleRule)((ICSSDocument)styleSheet).createCSSRule(
- selector + startBraces + styleAttributes.getStyle() + endBraces);
- ((ICSSStyleSheet)styleSheet).appendRule(rule);
- } else {
-
- CSSStyleDeclaration declaration = rule.getStyle();
- // set properties
- Set<Entry<String, String>> set = styleAttributes.entrySet();
-
- if ((set.size() == 0) && (declaration.getLength()>0))
- declaration.setCssText(Constants.EMPTY);
- else
- for (Map.Entry<String, String> me : set) {
- declaration.setProperty(me.getKey(), me.getValue(),
- Constants.EMPTY);
- }
- }
- }
- }
-
- /**
- * Gets file associated with current model.
- *
- * @return the styleFile
- */
- public IFile getStyleFile() {
- return this.styleFile;
- }
-
- /**
- * Release CSS model correctly from editing.
- */
- public void releaseModel() {
- IModelManager modelManager = StructuredModelManager.getModelManager();
- if (model != null && !modelManager.isShared(model.getId()))
- model.releaseFromEdit();
- model = null;
- }
-
- /**
- * Save model. Associate file will be saved automatically.
- */
- public void saveModel() {
- try {
-
- /*
- * it is necessary not to dialog appears when "dirty" css file is
- * being saved ( test case : 1) open css file 2) make same changes
- * 3) open css dialog 4) make some changes 5)press ok )
- *
- *
- * it is necessary to distinguish real model from copy. For real
- * model next step reject all changes
- */
- if (copy) {
- IFileBuffer buffer = FileBuffers.getTextFileBufferManager()
- .getFileBuffer(styleFile.getFullPath(),
- LocationKind.NORMALIZE);
- buffer.setDirty(false);
- }
-
- model.save();
- } catch (IOException e) {
- JspEditorPlugin.getPluginLog().logError(e.getMessage());
- } catch (CoreException e) {
- JspEditorPlugin.getPluginLog().logError(e.getMessage());
- }
- }
-
- /**
- * get mapping key is label ( label = class name + sequence number of such
- * css class ) value is CSSStyleRule
- *
- * now rule mapping is generated always ... keeping of ruleMapping is more
- * right but it demands more complex synchronization data
- *
- */
- private Map<String, CSSStyleRule> getRulesMapping() {
-
- Map<String, CSSStyleRule> rulesMapping = new HashMap<String, CSSStyleRule>();
- if (styleSheet != null) {
- CSSRuleList list = styleSheet.getCssRules();
-
- Map<String, Integer> frequencyMap = new HashMap<String, Integer>();
-
- if (list != null) {
- for (int i = 0; i < list.getLength(); i++) {
- if (list.item(i) instanceof CSSStyleRule) {
-
- CSSStyleRule rule = ((CSSStyleRule) list.item(i));
-
- Integer freq = frequencyMap.get(rule.getSelectorText());
-
- freq = freq == null ? 1 : freq + 1;
-
- frequencyMap.put(rule.getSelectorText(), freq);
-
- String ruleLabel = rule.getSelectorText()
- + (freq > 1 ? Constants.START_BRACKET + freq
- + Constants.END_BRACKET
- : Constants.EMPTY);
-
- rulesMapping.put(ruleLabel, rule);
-
- }
- }
- }
-
- }
-
- return rulesMapping;
- }
-
- public IDocument getStructuredDocument() {
- return model.getStructuredDocument();
- }
-
- public void reload() {
- try {
- if(model.isDirty()) {
- model.reload(new FileInputStream(styleFile.getLocation().toFile()));
- }
- } catch (Exception e) {
- JspEditorPlugin.getPluginLog().logError(e.getMessage());
- }
-
- }
-
- public String getSelectorByPosition(Point selectionInFile) {
-
- ICSSNode node = (ICSSNode) model.getIndexedRegion(selectionInFile.x);
-
- while (node != null) {
-
- if (node.getNodeType() == ICSSNode.STYLERULE_NODE) {
- break;
- } else if (node.getNodeType() == ICSSNode.STYLESHEET_NODE) {
- node = ((ICSSStyleSheet) node).getFirstChild();
- break;
- }
-
- node = node.getParentNode();
- }
-
- Object rules= getRulesMapping();
- if (node != null)
- for (Entry<String, CSSStyleRule> rule : getRulesMapping()
- .entrySet()) {
- if (node.equals(rule.getValue()))
- return rule.getKey();
- }
- return null;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.outline.cssdialog.common;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.core.filebuffers.IFileBuffer;
+import org.eclipse.core.filebuffers.LocationKind;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentExtension3;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.wst.css.core.internal.format.FormatProcessorCSS;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet;
+import org.eclipse.wst.css.core.internal.text.StructuredTextPartitionerForCSS;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.exceptions.ResourceInUse;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredPartitioning;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.jboss.tools.jst.jsp.outline.cssdialog.events.StyleAttributes;
+import org.w3c.dom.css.CSSRule;
+import org.w3c.dom.css.CSSRuleList;
+import org.w3c.dom.css.CSSStyleDeclaration;
+import org.w3c.dom.css.CSSStyleRule;
+import org.w3c.dom.css.CSSStyleSheet;
+
+/**
+ * CSS class model.
+ *
+ *
+ */
+public class CSSModel {
+
+ private static String startBraces = "{"; //$NON-NLS-1$
+ private static String endBraces = "}"; //$NON-NLS-1$
+
+ private FormatProcessorCSS formatProcessorCSS = null;
+ private IStructuredModel model = null;
+ private IFile styleFile = null;
+
+ private CSSStyleSheet styleSheet = null;
+ private ICSSStyleSheet eclipseStyleSheet = null;
+ private String COPY_SUFFIX = "_copy";
+ private boolean copy = false;
+
+
+ /**
+ * Constructor.
+ *
+ * @param styleFile CSS style class that should initialize CSS model
+ */
+ public CSSModel(IFile styleFile) {
+ init(styleFile);
+ }
+
+ public void init(IFile styleFile) {
+ try {
+ this.styleFile = styleFile;
+ if (model != null) {
+ releaseModel();
+ }
+ copy = false;
+ formatProcessorCSS = new FormatProcessorCSS();
+ IModelManager modelManager = StructuredModelManager.getModelManager();
+ model = modelManager.getExistingModelForEdit(styleFile);
+
+
+ if (model == null)
+ model = modelManager.getModelForEdit(styleFile);
+ else {
+
+ copy = true;
+ // copy the model
+ model = modelManager.copyModelForEdit(model.getId(), model
+ .getId()
+ + COPY_SUFFIX);
+
+ // set the correct location
+ model.setBaseLocation(styleFile.getLocation().toString());
+
+ // some steps to prepare document ( it is necessary to correct
+ // work of highlight in preview tab )
+ IDocumentPartitioner partitioner = new StructuredTextPartitionerForCSS();
+ ((IDocumentExtension3) model.getStructuredDocument())
+ .setDocumentPartitioner(
+ IStructuredPartitioning.DEFAULT_STRUCTURED_PARTITIONING,
+ partitioner);
+ partitioner.connect(model.getStructuredDocument());
+
+ }
+ if (model instanceof ICSSModel) {
+ ICSSModel cssModel = (ICSSModel) model;
+ ICSSDocument document = cssModel.getDocument();
+ if (document instanceof CSSStyleSheet) {
+ styleSheet = (CSSStyleSheet) document;
+ prepareModel(styleSheet);
+ }
+ if (document instanceof ICSSStyleSheet) {
+ eclipseStyleSheet = (ICSSStyleSheet) document;
+ }
+
+
+ }
+ } catch (IOException e) {
+ JspEditorPlugin.getPluginLog().logError(e.getMessage());
+ } catch (CoreException e) {
+ JspEditorPlugin.getPluginLog().logError(e.getMessage());
+ } catch (ResourceInUse e) {
+ JspEditorPlugin.getPluginLog().logError(e.getMessage());
+ }
+ }
+
+ /**
+ * Method is used to select area that corresponds to specific selector.
+ *
+ * @param selector the selector that should be selected in editor area
+ * @param index if CSS file contains more then one elements with the same selector name,
+ * then index is serial number of this selector
+ */
+ public IndexedRegion getSelectorRegion(String selector, int index) {
+ //FIXED by sdzmitrovich - JBIDE-3148
+// if (eclipseStyleSheet != null) {
+// if (selector != null && !selector.equals(Constants.EMPTY)) {
+// ICSSStyleRule styleRule = Util.getSelector(eclipseStyleSheet, selector, index);
+// if (styleRule != null) {
+// if (styleRule instanceof IndexedRegion) {
+// return (IndexedRegion) styleRule;
+// }
+// }
+// }
+// }
+
+ if ( selector != null) {
+ CSSStyleRule rule = getRulesMapping().get(selector);
+ if (rule != null)
+ if (rule instanceof IndexedRegion) {
+ return (IndexedRegion) rule;
+ }
+
+ }
+ return null;
+ }
+
+
+ public List<String> getSelectorLabels() {
+
+ List<String> selectorLabels;
+
+ selectorLabels = new ArrayList<String>(getRulesMapping().keySet());
+
+ Collections.sort(selectorLabels);
+
+ return selectorLabels;
+ }
+
+ /**
+ * Gets CSS attributes for the given selector in string representation.
+ *
+ * @param selector CSS selector value
+ * @return CSS attributes string representation
+ */
+ public String getCSSText(String selector) {
+ //FIXED by sdzmitrovich - JBIDE-3148
+// if (styleSheet != null && selector != null) {
+// CSSRuleList list = styleSheet.getCssRules();
+//
+// if (list != null) {
+// for (int i = 0; i < list.getLength(); i++) {
+// if (list.item(i) instanceof CSSStyleRule &&
+// ((CSSStyleRule) list.item(i)).getSelectorText().equals(selector)) {
+// return ((CSSStyleRule) list.item(i)).getCssText();
+// }
+// }
+// }
+// }
+ if ( selector != null) {
+ CSSStyleRule rule = getRulesMapping().get(selector);
+ if (rule != null)
+ return rule.getCssText();
+
+ }
+
+ return null;
+ }
+
+ /**
+ * Get style by selectorName
+ *
+ * @param selectorName
+ * @return style
+ */
+ public String getStyle(String selectorName) {
+ //FIXED by sdzmitrovich - JBIDE-3148
+// if (styleSheet != null) {
+// CSSRuleList list = styleSheet.getCssRules();
+//
+// if (list != null) {
+// for (int i = 0; i < list.getLength(); i++) {
+// if (list.item(i) instanceof CSSStyleRule &&
+// ((CSSStyleRule) list.item(i)).getSelectorText().equals(selectorName)) {
+// return ((CSSStyleRule) list.item(i)).getStyle().getCssText();
+// }
+// }
+// }
+// }
+ if (selectorName != null) {
+ CSSStyleRule rule = getRulesMapping().get(selectorName);
+ if (rule != null)
+ return rule.getStyle().getCssText();
+
+ }
+
+ return null;
+ }
+
+ /**
+ * Sets CSS style for the given selector.
+ *
+ * @param selector CSS selector value
+ * @param styleAttribute the style to be set
+ */
+ public void setCSS(String selector, StyleAttributes styleAttributes) {
+ if (styleSheet != null && selector != null && !selector.equals(Constants.EMPTY)) {
+ CSSRuleList list = styleSheet.getCssRules();
+ //FIXED by sdzmitrovich - JBIDE-3148
+// if (list != null) {
+// // check if selector passed by parameter already exists in CSS
+// for (int i = 0; i < list.getLength(); i++) {
+// if (list.item(i) instanceof CSSStyleRule &&
+// ((CSSStyleRule) list.item(i)).getSelectorText().equals(selector)) {
+//
+// CSSStyleRule rule = (CSSStyleRule) list.item(i);
+// styleSheet.deleteRule(i);
+//
+// i = styleSheet.insertRule(selector + startBraces + styleAttributes.getStyle() + endBraces, i);
+// rule = (CSSStyleRule) list.item(i);
+// CSSStyleDeclaration declaration = rule.getStyle();
+// // set properties
+// Set<Entry<String, String>> set = styleAttributes.entrySet();
+// for (Map.Entry<String, String> me : set) {
+// declaration.setProperty(me.getKey(), me.getValue(), Constants.EMPTY);
+// }
+//
+// formatProcessorCSS.formatModel(model);
+// return;
+// }
+// }
+// // insert NEW selector to style sheet
+// styleSheet.insertRule(selector + startBraces + styleAttributes.getStyle() + endBraces, list.getLength());
+// formatProcessorCSS.formatModel(model);
+ CSSStyleRule rule = getRulesMapping().get(selector);
+ if (rule == null) {
+ rule = (CSSStyleRule)((ICSSDocument)styleSheet).createCSSRule(
+ selector + startBraces + styleAttributes.getStyle() + endBraces);
+ ((ICSSStyleSheet)styleSheet).appendRule(rule);
+ } else {
+
+ CSSStyleDeclaration declaration = rule.getStyle();
+ // set properties
+ Set<Entry<String, String>> set = styleAttributes.entrySet();
+
+ if ((set.size() == 0) && (declaration.getLength()>0))
+ declaration.setCssText(Constants.EMPTY);
+ else
+ for (Map.Entry<String, String> me : set) {
+ declaration.setProperty(me.getKey(), me.getValue(),
+ Constants.EMPTY);
+ }
+ }
+ }
+ }
+
+ /**
+ * Gets file associated with current model.
+ *
+ * @return the styleFile
+ */
+ public IFile getStyleFile() {
+ return this.styleFile;
+ }
+
+ /**
+ * Release CSS model correctly from editing.
+ */
+ public void releaseModel() {
+ IModelManager modelManager = StructuredModelManager.getModelManager();
+ if (model != null && !modelManager.isShared(model.getId()))
+ model.releaseFromEdit();
+ model = null;
+ }
+
+ /**
+ * Save model. Associate file will be saved automatically.
+ */
+ public void saveModel() {
+ try {
+
+ /*
+ * it is necessary not to dialog appears when "dirty" css file is
+ * being saved ( test case : 1) open css file 2) make same changes
+ * 3) open css dialog 4) make some changes 5)press ok )
+ *
+ *
+ * it is necessary to distinguish real model from copy. For real
+ * model next step reject all changes
+ */
+ if (copy) {
+ IFileBuffer buffer = FileBuffers.getTextFileBufferManager()
+ .getFileBuffer(styleFile.getFullPath(),
+ LocationKind.NORMALIZE);
+ buffer.setDirty(false);
+ }
+
+ model.save();
+ } catch (IOException e) {
+ JspEditorPlugin.getPluginLog().logError(e.getMessage());
+ } catch (CoreException e) {
+ JspEditorPlugin.getPluginLog().logError(e.getMessage());
+ }
+ }
+
+ /**
+ * get mapping key is label ( label = class name + sequence number of such
+ * css class ) value is CSSStyleRule
+ *
+ * now rule mapping is generated always ... keeping of ruleMapping is more
+ * right but it demands more complex synchronization data
+ *
+ */
+ private Map<String, CSSStyleRule> getRulesMapping() {
+
+ Map<String, CSSStyleRule> rulesMapping = new HashMap<String, CSSStyleRule>();
+ if (styleSheet != null) {
+ CSSRuleList list = styleSheet.getCssRules();
+
+ Map<String, Integer> frequencyMap = new HashMap<String, Integer>();
+
+ if (list != null) {
+ for (int i = 0; i < list.getLength(); i++) {
+ if (list.item(i) instanceof CSSStyleRule) {
+
+ CSSStyleRule rule = ((CSSStyleRule) list.item(i));
+
+ Integer freq = frequencyMap.get(rule.getSelectorText());
+
+ freq = freq == null ? 1 : freq + 1;
+
+ frequencyMap.put(rule.getSelectorText(), freq);
+
+ String ruleLabel = rule.getSelectorText()
+ + (freq > 1 ? Constants.START_BRACKET + freq
+ + Constants.END_BRACKET
+ : Constants.EMPTY);
+
+ rulesMapping.put(ruleLabel, rule);
+
+ }
+ }
+ }
+
+ }
+
+ return rulesMapping;
+ }
+
+ public IDocument getStructuredDocument() {
+ return model.getStructuredDocument();
+ }
+
+ public void reload() {
+ try {
+ if(model.isDirty()) {
+ model.reload(new FileInputStream(styleFile.getLocation().toFile()));
+ }
+ } catch (Exception e) {
+ JspEditorPlugin.getPluginLog().logError(e.getMessage());
+ }
+
+ }
+
+ public String getSelectorByPosition(Point selectionInFile) {
+
+ ICSSNode node = (ICSSNode) model.getIndexedRegion(selectionInFile.x);
+
+ while (node != null) {
+
+ if (node.getNodeType() == ICSSNode.STYLERULE_NODE) {
+ break;
+ } else if (node.getNodeType() == ICSSNode.STYLESHEET_NODE) {
+ node = ((ICSSStyleSheet) node).getFirstChild();
+ break;
+ }
+
+ node = node.getParentNode();
+ }
+
+ if (node != null)
+ for (Entry<String, CSSStyleRule> rule : getRulesMapping()
+ .entrySet()) {
+ if (node.equals(rule.getValue()))
+ return rule.getKey();
+ }
+ return null;
+ }
+
+ private void prepareModel(CSSStyleSheet styleSheet) {
+
+ CSSRuleList rules = styleSheet.getCssRules();
+ if ((rules != null) && (rules.getLength() > 0)) {
+ CSSRule rule = rules.item(rules.getLength() - 1);
+ String text = rule.getCssText();
+ if ((text != null) && (!text.endsWith(endBraces))) {
+ rule.setCssText(text + "\n"+ endBraces); //$NON-NLS-1$
+ }
+ }
+ }
+}
[View Less]
15 years, 11 months
JBoss Tools SVN: r14296 - trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common.
by jbosstools-commits@lists.jboss.org
Author: sdzmitrovich
Date: 2009-03-23 15:09:50 -0400 (Mon, 23 Mar 2009)
New Revision: 14296
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/CSSModel.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3920,https://jira.jboss.org/jira...
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/CSSModel.java
===================================================================
--- trunk/jst/…
[View More]plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/CSSModel.java 2009-03-23 18:56:46 UTC (rev 14295)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/cssdialog/common/CSSModel.java 2009-03-23 19:09:50 UTC (rev 14296)
@@ -33,7 +33,6 @@
import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument;
import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
-import org.eclipse.wst.css.core.internal.provisional.document.ICSSRuleContainer;
import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet;
import org.eclipse.wst.css.core.internal.text.StructuredTextPartitionerForCSS;
import org.eclipse.wst.sse.core.StructuredModelManager;
@@ -44,6 +43,7 @@
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredPartitioning;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
import org.jboss.tools.jst.jsp.outline.cssdialog.events.StyleAttributes;
+import org.w3c.dom.css.CSSRule;
import org.w3c.dom.css.CSSRuleList;
import org.w3c.dom.css.CSSStyleDeclaration;
import org.w3c.dom.css.CSSStyleRule;
@@ -118,12 +118,13 @@
ICSSDocument document = cssModel.getDocument();
if (document instanceof CSSStyleSheet) {
styleSheet = (CSSStyleSheet) document;
+ prepareModel(styleSheet);
}
if (document instanceof ICSSStyleSheet) {
eclipseStyleSheet = (ICSSStyleSheet) document;
}
-
+
}
} catch (IOException e) {
JspEditorPlugin.getPluginLog().logError(e.getMessage());
@@ -418,7 +419,6 @@
node = node.getParentNode();
}
- Object rules= getRulesMapping();
if (node != null)
for (Entry<String, CSSStyleRule> rule : getRulesMapping()
.entrySet()) {
@@ -427,4 +427,16 @@
}
return null;
}
+
+ private void prepareModel(CSSStyleSheet styleSheet) {
+
+ CSSRuleList rules = styleSheet.getCssRules();
+ if ((rules != null) && (rules.getLength() > 0)) {
+ CSSRule rule = rules.item(rules.getLength() - 1);
+ String text = rule.getCssText();
+ if ((text != null) && (!text.endsWith(endBraces))) {
+ rule.setCssText(text + "\n"+ endBraces); //$NON-NLS-1$
+ }
+ }
+ }
}
[View Less]
15 years, 11 months
JBoss Tools SVN: r14295 - trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch.
by jbosstools-commits@lists.jboss.org
Author: vyemialyanchyk
Date: 2009-03-23 14:56:46 -0400 (Mon, 23 Mar 2009)
New Revision: 14295
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConsoleConfigurationOptionsTab.java
Log:
JBIDE-4014
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConsoleConfigurationOptionsTab.java
===================================================================
--- trunk/hibernatetools/plugins/org.…
[View More]hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConsoleConfigurationOptionsTab.java 2009-03-23 17:28:12 UTC (rev 14294)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConsoleConfigurationOptionsTab.java 2009-03-23 18:56:46 UTC (rev 14295)
@@ -54,6 +54,7 @@
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
dialectNameCombo.setLayoutData(gd);
dialectNameCombo.setFont(font);
+ dialectNameCombo.addModifyListener(getChangeListener());
}
private void createNamingStrategyClassNameEditor(Composite parent) {
@@ -87,10 +88,8 @@
public void initializeFrom(ILaunchConfiguration configuration) {
try {
- String dialect = configuration.getAttribute( IConsoleConfigurationLaunchConstants.DIALECT , (String)null );
- if (dialect != null){
- dialectNameCombo.setText( helper.getShortDialectName(dialect) );
- }
+ String dialect = configuration.getAttribute( IConsoleConfigurationLaunchConstants.DIALECT, "" ); //$NON-NLS-1$
+ dialectNameCombo.setText( helper.getShortDialectName(dialect) );
namingStrategyClassNameText.setText( configuration.getAttribute( IConsoleConfigurationLaunchConstants.NAMING_STRATEGY, "" ) ); //$NON-NLS-1$
entityResolverClassNameText.setText( configuration.getAttribute( IConsoleConfigurationLaunchConstants.ENTITY_RESOLVER, "" ) ); //$NON-NLS-1$
}
[View Less]
15 years, 12 months
JBoss Tools SVN: r14294 - in trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui: src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: vyemialyanchyk
Date: 2009-03-23 13:28:12 -0400 (Mon, 23 Mar 2009)
New Revision: 14294
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/plugin.xml
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/AllEntitiesInfoCollector.java
Log:
JBIDE-3999
Modified: trunk/…
[View More]hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/plugin.xml
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/plugin.xml 2009-03-23 15:31:42 UTC (rev 14293)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/plugin.xml 2009-03-23 17:28:12 UTC (rev 14294)
@@ -105,9 +105,27 @@
</action>
</viewerContribution>
<!-- java element context menu -->
- <objectContribution adaptable="false"
- id="org.hibernate.eclipse.jdt.ui.run_jpa.popupMenu.IJavaElementContribution"
+ <objectContribution adaptable="false"
+ id="org.hibernate.eclipse.jdt.ui.run_jpa.popupMenu.IJavaElementContribution"
objectClass="org.eclipse.jdt.core.IJavaElement">
+ <visibility>
+ <or>
+ <objectClass name="org.eclipse.jdt.core.ICompilationUnit"/>
+ <objectClass name="org.eclipse.jdt.internal.core.JavaProject"/>
+ <objectClass name="org.eclipse.jdt.internal.core.PackageFragment"/>
+ <and>
+ <objectClass name="org.eclipse.jdt.internal.core.JavaElement"/>
+ <not>
+ <or>
+ <objectClass name="org.eclipse.jdt.internal.core.ExternalPackageFragmentRoot"/>
+ <objectClass name="org.eclipse.jdt.internal.core.JarPackageFragmentRoot"/>
+ <objectClass name="org.eclipse.jdt.internal.core.ClassFile"/>
+ <objectClass name="org.eclipse.jdt.internal.core.ExternalJavaProject"/>
+ </or>
+ </not>
+ </and>
+ </or>
+ </visibility>
<menu label="%Menu_Source" path="edit" id="org.eclipse.jdt.ui.source.menu">
<separator name="commentGroup"/>
<separator name="editGroup"/>
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java 2009-03-23 15:31:42 UTC (rev 14293)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java 2009-03-23 17:28:12 UTC (rev 14294)
@@ -31,6 +31,9 @@
import org.eclipse.jdt.core.dom.ASTParser;
import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
import org.eclipse.jdt.core.dom.TypeDeclaration;
+import org.eclipse.jdt.internal.core.ClassFile;
+import org.eclipse.jdt.internal.core.ExternalPackageFragmentRoot;
+import org.eclipse.jdt.internal.core.JarPackageFragmentRoot;
import org.eclipse.jdt.internal.core.JavaElement;
import org.eclipse.jdt.internal.core.JavaElementInfo;
import org.eclipse.jdt.internal.core.JavaProject;
@@ -45,8 +48,8 @@
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.hibernate.eclipse.jdt.ui.Activator;
import org.hibernate.eclipse.jdt.ui.internal.JdtUiMessages;
@@ -59,7 +62,7 @@
* Actor to execute annotation generation.
* It is singleton.
*
- * @author Vitali
+ * @author Vitali Yemialyanchyk
*/
public class JPAMapToolActor {
@@ -101,10 +104,17 @@
return actor;
}
+ /**
+ * Cleanup collection of selected elements for processing
+ */
public void clearSelectionCU() {
selectionCU.clear();
}
+ /**
+ * Adds compilation unit into collection of selected elements for processing
+ * @param cu compilation unit
+ */
public void addCompilationUnit(ICompilationUnit cu) {
if (cu != null) {
IType[] types = null;
@@ -176,14 +186,30 @@
processor.saveAnnotationStylePreference();
}
+ private IWorkbenchWindow getActiveWorkbenchWindow() {
+ return Activator.getDefault().getWorkbench().getActiveWorkbenchWindow();
+ }
+
private Shell getShell() {
- return Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
+ IWorkbenchWindow activeWorkbenchWindow = getActiveWorkbenchWindow();
+ if (activeWorkbenchWindow != null) {
+ return activeWorkbenchWindow.getShell();
+ }
+ return null;
}
+ /**
+ * update compilation unit of currently opened editor
+ */
public void updateOpen() {
- IWorkbench workbench = Activator.getDefault().getWorkbench();
- IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
-
+ IWorkbenchWindow activeWorkbenchWindow = getActiveWorkbenchWindow();
+ if (activeWorkbenchWindow == null) {
+ return;
+ }
+ IWorkbenchPage page = activeWorkbenchWindow.getActivePage();
+ if (page == null) {
+ return;
+ }
IEditorPart editor = page.getActiveEditor();
if (editor instanceof CompilationUnitEditor) {
CompilationUnitEditor cue = (CompilationUnitEditor)editor;
@@ -209,6 +235,9 @@
collector.collect(cu);
}
+ /**
+ * @return probable number of available item to process
+ */
synchronized public int getSelectedSourceSize() {
int res = 0;
if (selection == null) {
@@ -221,10 +250,20 @@
else if (selection instanceof TreeSelection) {
TreeSelection treeSelection = (TreeSelection)selection;
res = treeSelection.size();
+ Iterator it = treeSelection.iterator();
+ while (it.hasNext()) {
+ Object obj = it.next();
+ if (excludeElement(obj)) {
+ res--;
+ }
+ }
}
return res;
}
+ /**
+ * @param sel - current selected workspace element for processing
+ */
synchronized private void updateSelectedItems(ISelection sel) {
//System.out.println("Blah! " + selection); //$NON-NLS-1$
if (sel instanceof TextSelection) {
@@ -296,7 +335,40 @@
sel = null;
}
}
+
+ /**
+ * Check is the object in set of excluded elements
+ * @param obj
+ * @return exclusion result
+ */
+ protected boolean excludeElement(Object obj) {
+ boolean res = false;
+ if (obj instanceof JarPackageFragmentRoot) {
+ res = true;
+ }
+ else if (obj instanceof ClassFile) {
+ res = true;
+ }
+ else if (obj instanceof PackageFragment) {
+ PackageFragment pf = (PackageFragment)obj;
+ try {
+ if (pf.getKind() == IPackageFragmentRoot.K_BINARY) {
+ res = true;
+ }
+ } catch (JavaModelException e) {
+ // ignore
+ }
+ }
+ else if (obj instanceof ExternalPackageFragmentRoot) {
+ res = true;
+ }
+ return res;
+ }
+ /**
+ * Process object - java element to collect all it's children CompilationUnits
+ * @param obj
+ */
protected void processJavaElements(Object obj) {
if (obj instanceof ICompilationUnit) {
ICompilationUnit cu = (ICompilationUnit)obj;
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/AllEntitiesInfoCollector.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/AllEntitiesInfoCollector.java 2009-03-23 15:31:42 UTC (rev 14293)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/AllEntitiesInfoCollector.java 2009-03-23 17:28:12 UTC (rev 14294)
@@ -10,7 +10,6 @@
******************************************************************************/
package org.hibernate.eclipse.jdt.ui.internal.jpa.collect;
-import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@@ -31,7 +30,7 @@
/**
* Collect information about JPA entity and it's dependences.
*
- * @author Vitali
+ * @author Vitali Yemialyanchyk
*/
public class AllEntitiesInfoCollector {
[View Less]
15 years, 12 months
JBoss Tools SVN: r14293 - in trunk/seam/plugins: org.jboss.tools.seam.text.ext and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2009-03-23 11:31:42 -0400 (Mon, 23 Mar 2009)
New Revision: 14293
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamProjectsSet.java
trunk/seam/plugins/org.jboss.tools.seam.text.ext/plugin.xml
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/ComponentsHyperlink.java
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/…
[View More]ComponentsHyperlinkPartitioner.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4002
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamProjectsSet.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamProjectsSet.java 2009-03-23 15:04:39 UTC (rev 14292)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamProjectsSet.java 2009-03-23 15:31:42 UTC (rev 14293)
@@ -208,6 +208,21 @@
}
return getWarProject();
}
+
+ /**
+ * Returns default ear contents folder.
+ * @return
+ */
+ public IContainer getDefaultEarViewsFolder() {
+ IVirtualComponent com = ComponentCore.createComponent(ear);
+ if(com!=null) {
+ IVirtualFolder webRootFolder = com.getRootFolder().getFolder(new Path("/")); //$NON-NLS-1$
+ if(webRootFolder!=null) {
+ return (IFolder)webRootFolder.getUnderlyingFolder();
+ }
+ }
+ return getWarProject();
+ }
/**
* Returns web contents folder.
Modified: trunk/seam/plugins/org.jboss.tools.seam.text.ext/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.text.ext/plugin.xml 2009-03-23 15:04:39 UTC (rev 14292)
+++ trunk/seam/plugins/org.jboss.tools.seam.text.ext/plugin.xml 2009-03-23 15:31:42 UTC (rev 14293)
@@ -214,6 +214,7 @@
<axis path="*/bpm:process-definitions/value/" />
<!-- TODO replace bpm with [http://jboss.com/products/seam/bpm] -->
<axis path="*/bpm:pageflow-definitions/value/" />
+ <axis path="*/component/property/value/" />
<!-- TODO replace drools with [http://http://jboss.com/products/seam/drools] -->
<axis path="*/drools:rule-files/value/" />
</partitionType>
Modified: trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/ComponentsHyperlink.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/ComponentsHyperlink.java 2009-03-23 15:04:39 UTC (rev 14292)
+++ trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/ComponentsHyperlink.java 2009-03-23 15:31:42 UTC (rev 14293)
@@ -11,9 +11,11 @@
package org.jboss.tools.seam.text.ext.hyperlink;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Path;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
@@ -27,7 +29,6 @@
public class ComponentsHyperlink extends AbstractHyperlink {
private String hyperlinkText = "";
- private static final String folder = "EarContent/";
private String partitionType = null;
@@ -84,19 +85,40 @@
}
private void doBpmDefinitionHyperlink(IRegion region) {
- IProject earProject = getEarProject();
- if (earProject == null)
- return;
-
- IFile file = earProject.getFile(folder + hyperlinkText);
+ IFile file = findDefinitionFile();
if (file != null)
openFileInEditor(file);
}
-
- private IProject getEarProject() {
+
+ private IFile findDefinitionFile(){
+ IFile file;
SeamProjectsSet projectsSet = SeamProjectsSet.create(getProject());
- return projectsSet.getEarProject();
+ IContainer webContent = projectsSet.getDefaultViewsFolder();
+
+ if(webContent != null){
+ file = webContent.getFile(new Path(hyperlinkText));
+ if(file != null && file.exists())
+ return file;
+ }
+
+ IContainer earContent = projectsSet.getDefaultEarViewsFolder();
+
+ if(earContent != null){
+ file = earContent.getFile(new Path(hyperlinkText));
+ if(file != null && file.exists())
+ return file;
+ }
+
+ IContainer ejbSource = projectsSet.getDefaultEjbSourceFolder();
+
+ if(ejbSource != null){
+ file = ejbSource.getFile(new Path(hyperlinkText));
+ if(file != null && file.exists())
+ return file;
+ }
+
+ return null;
}
private IProject getProject() {
Modified: trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/ComponentsHyperlinkPartitioner.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/ComponentsHyperlinkPartitioner.java 2009-03-23 15:04:39 UTC (rev 14292)
+++ trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/ComponentsHyperlinkPartitioner.java 2009-03-23 15:31:42 UTC (rev 14293)
@@ -32,6 +32,12 @@
static final String processDefinitionsNodeName = "bpm:process-definitions";
static final String pageflowDefinitionsNodeName = "bpm:pageflow-definitions";
+
+ static final String propertyNodeName = "property";
+ static final String propertyAttributeName = "name";
+
+ static final String propertyAtt1 = "processDefinitions";
+ static final String propertyAtt2 = "pageflowDefinitions";
static final String droolsRuleFileNodeName = "drools:rule-files";
@@ -43,8 +49,7 @@
if (xmlDocument == null)
return null;
- Node node = Utils.findNodeForOffset(xmlDocument, superOffset); // #
- // text
+ Node node = Utils.findNodeForOffset(xmlDocument, superOffset); // #text
return node;
} finally {
@@ -71,6 +76,15 @@
} else if (parentNode.getNodeName().equalsIgnoreCase(
droolsRuleFileNodeName)) {
return DROOLS_RULE_PARTITION;
+ } else if(parentNode.getNodeName().equalsIgnoreCase(
+ propertyNodeName)) {
+ Node attribute = parentNode.getAttributes().getNamedItem(propertyAttributeName);
+ if(attribute != null){
+ if(attribute.getNodeValue().equalsIgnoreCase(propertyAtt1)
+ || attribute.getNodeValue().equalsIgnoreCase(propertyAtt2)){
+ return BPM_DEFINITION_PARTITION;
+ }
+ }
}
}
[View Less]
15 years, 12 months
JBoss Tools SVN: r14292 - trunk/common/plugins/org.jboss.tools.common.resref.core/src/org/jboss/tools/common/resref/core.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2009-03-23 11:04:39 -0400 (Mon, 23 Mar 2009)
New Revision: 14292
Modified:
trunk/common/plugins/org.jboss.tools.common.resref.core/src/org/jboss/tools/common/resref/core/ResourceReferenceList.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3211, resource setting are saved to ProjectScope to .settings.
Modified: trunk/common/plugins/org.jboss.tools.common.resref.core/src/org/jboss/tools/common/resref/core/ResourceReferenceList.java
==============================…
[View More]=====================================
--- trunk/common/plugins/org.jboss.tools.common.resref.core/src/org/jboss/tools/common/resref/core/ResourceReferenceList.java 2009-03-23 15:02:03 UTC (rev 14291)
+++ trunk/common/plugins/org.jboss.tools.common.resref.core/src/org/jboss/tools/common/resref/core/ResourceReferenceList.java 2009-03-23 15:04:39 UTC (rev 14292)
@@ -17,8 +17,13 @@
import java.util.*;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.core.runtime.preferences.InstanceScope;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.util.XModelObjectUtil;
+import org.osgi.service.prefs.BackingStoreException;
+import org.osgi.service.prefs.Preferences;
public abstract class ResourceReferenceList {
@@ -53,11 +58,12 @@
}
return -1;
}
- /**
- * Returns all resources for current file
- * @param file
- * @return
- */
+
+ /**
+ * Returns all resources for current file
+ * @param file
+ * @return
+ */
public ResourceReference[] getAllResources(IFile file) {
Set<String> locations = new HashSet<String>();
List<ResourceReference> css = new ArrayList<ResourceReference>();
@@ -94,19 +100,34 @@
return css.toArray(new ResourceReference[0]);
}
- private String[] getDeclaredResources(IResource resource) {
- String s = null;
- try {
- s = resource.getPersistentProperty(getPropertyName());
- } catch (CoreException e) {
- //ignore
+ private String[] getDeclaredResources(IResource resource) {
+ String s = null;
+ /*
+ * https://jira.jboss.org/jira/browse/JBIDE-3211
+ * Storing project preferences to project scope in .settings
+ */
+ IScopeContext projectScope = new ProjectScope(resource.getProject());
+ IEclipsePreferences root = projectScope
+ .getNode(ResourceReferencePlugin.PLUGIN_ID);
+ if (root != null) {
+ /*
+ * Create subnode for file/folder/project
+ */
+ IPath path = resource.getProjectRelativePath();
+ String nodeString = path.toString();
+ Preferences node = root.node(nodeString);
+ if (null != node) {
+ String old = node.get(getPropertyName().getLocalName(), ""); //$NON-NLS-1$
+ s = old;
}
- if(s == null || s.length() == 0) {
- return new String[0];
- } else {
- return decodeResourceString(s);
- }
+ }
+ if (s == null || s.length() == 0) {
+ return new String[0];
+ } else {
+ return decodeResourceString(s);
+ }
}
+
//Fix for JBIDE-2979
private static String[] decodeResourceString(String resource) {
String[] results = XModelObjectUtil.asStringArray(resource);
@@ -125,14 +146,16 @@
public void setAllResources(IFile file, ResourceReference[] entries) {
- IResource changed = null;
+ IResource changed = null;
boolean b = setDeclaredResources(file, entries, ResourceReference.FILE_SCOPE, 0);
if(b) changed = file;
IResource parent = file.getParent();
int depth = 0;
while(parent instanceof IFolder) {
b = setDeclaredResources(parent, entries, ResourceReference.FOLDER_SCOPE, depth);
- if(b) changed = parent;
+ if(b) {
+ changed = parent;
+ }
parent = parent.getParent();
depth++;
}
@@ -140,22 +163,41 @@
int scope = ResourceReference.PROJECT_SCOPE;
if(file.getParent() == file.getProject()) scope = 10;
b = setDeclaredResources(file.getProject(), entries, scope, 0);
- if(b) changed = file.getProject();
+ if(b) {
+ changed = file.getProject();
+ }
}
if(changed != null) fire(changed.getFullPath());
}
private boolean setDeclaredResources(IResource resource, ResourceReference[] entries, int scope, int depth) {
+ /*
+ * https://jira.jboss.org/jira/browse/JBIDE-3211 Reading project
+ * Reading preferences from project scope from .settings
+ */
+ IScopeContext projectScope = new ProjectScope(resource.getProject());
+ IEclipsePreferences root = projectScope
+ .getNode(ResourceReferencePlugin.PLUGIN_ID);
+ if (root != null) {
+ /*
+ * Get subnode for file/folder/project
+ */
+ IPath path = resource.getProjectRelativePath();
+ String nodeString = path.toString();
+ Preferences node = root.node(nodeString);
+ String oldValue = node.get(getPropertyName().getLocalName(), ""); //$NON-NLS-1$
+ String newValue = encodeDeclaredResources(entries, scope, depth);
+ if (oldValue.equals(newValue)) {
+ return false;
+ }
+ node.put(getPropertyName().getLocalName(), newValue);
try {
- String oldValue = resource.getPersistentProperty(getPropertyName());
- if(oldValue == null) oldValue = "";
- String newValue = encodeDeclaredResources(entries, scope, depth);
- if(oldValue.equals(newValue)) return false;
- resource.setPersistentProperty(getPropertyName(), newValue);
- } catch (CoreException e) {
- return false;
+ root.flush();
+ } catch (BackingStoreException e) {
+ ResourceReferencePlugin.getPluginLog().logError(e);
}
- return true;
+ }
+ return true;
}
private String encodeDeclaredResources(ResourceReference[] entries, int scope, int depth) {
@@ -193,18 +235,28 @@
TreeMap allExternalResources = null;
private TreeMap getAllExternalResources() {
- if(allExternalResources == null) {
- allExternalResources = new TreeMap();
- String s = null;
- try {
- s = ModelPlugin.getWorkspace().getRoot().getPersistentProperty(getPropertyName());
- if(s != null) parseExternalResources(s);
- } catch (CoreException e) {
- //ignore
- }
+ if (allExternalResources == null) {
+ allExternalResources = new TreeMap();
+ String s = null;
+ /*
+ * https://jira.jboss.org/jira/browse/JBIDE-3211 Reading project
+ * Reading global preferences from instance scope.
+ */
+ IScopeContext instanceContext = new InstanceScope();
+ Preferences root = instanceContext.getNode(ModelPlugin.PLUGIN_ID);
+ if (null != root) {
+ Preferences node = root
+ .node(ResourceReferencePlugin.PLUGIN_ID);
+ s = node.get(getPropertyName().getLocalName(), ""); //$NON-NLS-1$
}
- return allExternalResources;
+
+ if (s != null) {
+ parseExternalResources(s);
+ }
+ }
+ return allExternalResources;
}
+
private void parseExternalResources(String s) {
StringTokenizer st = new StringTokenizer(s, "#"); //$NON-NLS-1$
while(st.hasMoreTokens()) {
@@ -212,26 +264,41 @@
int e = t.indexOf('=');
String path = t.substring(0, e);
String list = t.substring(e + 1);
- if(new File(path).exists()) allExternalResources.put(path, list);
+ if(new File(path).exists()) {
+ allExternalResources.put(path, list);
+ }
}
}
private void setAllExternalResources() {
- StringBuffer sb = new StringBuffer();
- Iterator it = allExternalResources.keySet().iterator();
- while(it.hasNext()) {
- String path = it.next().toString();
- String list = (String)allExternalResources.get(path);
- if(path != null && list != null && new File(path).exists()) {
- if(sb.length() > 0) sb.append('#');
- sb.append(path).append('=').append(list);
- }
+ StringBuffer sb = new StringBuffer();
+ Iterator it = allExternalResources.keySet().iterator();
+ while (it.hasNext()) {
+ String path = it.next().toString();
+ String list = (String) allExternalResources.get(path);
+ if (path != null && list != null && new File(path).exists()) {
+ if (sb.length() > 0)
+ sb.append('#');
+ sb.append(path).append('=').append(list);
}
+ }
+ /*
+ * https://jira.jboss.org/jira/browse/JBIDE-3211 Reading project
+ * Storing global preferences to instance scope to
+ * ${workspace}\.metadata\.plugins\org.eclipse.core.runtime\
+ * .settings\org.jboss.tools.common.model.prefs
+ */
+ IScopeContext instanceContext = new InstanceScope();
+ Preferences root = instanceContext.getNode(ModelPlugin.PLUGIN_ID);
+ if (null != root) {
+ Preferences node = root.node(ResourceReferencePlugin.PLUGIN_ID);
+ node.put(getPropertyName().getLocalName(), sb.toString());
try {
- ModelPlugin.getWorkspace().getRoot().setPersistentProperty(getPropertyName(), sb.toString());
- } catch (CoreException e) {
- //ignore
+ root.flush();
+ } catch (BackingStoreException e) {
+ ResourceReferencePlugin.getPluginLog().logError(e);
}
+ }
}
public ResourceReference[] getAllResources(IPath path) {
@@ -270,7 +337,7 @@
}
private String[] getDeclaredResources(IPath path) {
- String s = (String)getAllExternalResources().get(path.toString());
+ String s = (String)getAllExternalResources().get(path.toString());
if(s == null || s.length() == 0) {
return new String[0];
}else {
@@ -283,7 +350,7 @@
boolean b = false;
int checkScope = path.equals(Platform.getLocation()) ? ResourceReference.GLOBAL_SCOPE : ResourceReference.FILE_SCOPE;
- b = setDeclaredResources(path, entries, checkScope, 0);
+ b = setDeclaredResources(path, entries, checkScope, 0);
if(b) changed = path;
IPath parent = path.removeLastSegments(1);
int depth = 0;
@@ -300,8 +367,10 @@
}
private boolean setDeclaredResources(IPath path, ResourceReference[] entries, int scope, int depth) {
- String oldValue = (String)getAllExternalResources().get(path.toString());
- if(oldValue == null) oldValue = "";
+ String oldValue = (String)getAllExternalResources().get(path.toString());
+ if(oldValue == null) {
+ oldValue = ""; //$NON-NLS-1$
+ }
String newValue = encodeDeclaredResources(entries, scope, depth);
if(oldValue.equals(newValue)) return false;
if(newValue == null || newValue.length() == 0) {
[View Less]
15 years, 12 months