JBoss Tools SVN: r29117 - trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2011-02-11 10:32:58 -0500 (Fri, 11 Feb 2011)
New Revision: 29117
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/Flasher.java
Log:
https://issues.jboss.org/browse/JBIDE-8364
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/Flasher.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/Flasher.java 2011-02-11 15:29:36 UTC (rev 29116)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/Flasher.java 2011-02-11 15:32:58 UTC (rev 29117)
@@ -18,7 +18,7 @@
private inIFlasher iFlasher;
private static final boolean IS_OPEN_JDK = (System.getProperty("java.runtime.name")!=null&&System.getProperty("java.runtime.name").contains("OpenJDK")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//fix for JBIDE-7957
- private static final boolean IS_LINUX_X86_64=Platform.OS_LINUX.equals(Platform.getOS())&&Platform.ARCH_X86_64.equals(Platform.getOSArch());
+ private static final boolean IS_LINUX=Platform.OS_LINUX.equals(Platform.getOS());
// added by Maksim Areshkau as element for which we
// have drowed border. When we draw new border,
// we should remove old one;
@@ -34,7 +34,7 @@
//fix for JBIDE-7295, added by Maksim Areshkau
if (Platform.OS_MACOSX.equals(Platform.getOS())
||IS_OPEN_JDK
- ||IS_LINUX_X86_64) {
+ ||IS_LINUX) {
drawOutline = new DrawOutlineInterface() {
private nsIDOMElement lastBorderedElement = null;
public void drawElementOutline(nsIDOMElement domElement) {
13 years, 11 months
JBoss Tools SVN: r29116 - in branches/jbosstools-3.2.x: vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2011-02-11 10:29:36 -0500 (Fri, 11 Feb 2011)
New Revision: 29116
Modified:
branches/jbosstools-3.2.x/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3473Test.java
branches/jbosstools-3.2.x/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/Flasher.java
Log:
https://issues.jboss.org/browse/JBIDE-8364
Modified: branches/jbosstools-3.2.x/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3473Test.java
===================================================================
--- branches/jbosstools-3.2.x/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3473Test.java 2011-02-11 13:52:11 UTC (rev 29115)
+++ branches/jbosstools-3.2.x/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3473Test.java 2011-02-11 15:29:36 UTC (rev 29116)
@@ -81,8 +81,8 @@
Rectangle boundsAfterInsert = getBoundsOfElementById(vpeController.getXulRunnerEditor().getDOMDocument(), TABLE_ID);
assertNotNull("boundsAfterInsert should be not null.", boundsAfterInsert); //$NON-NLS-1$
- assertEquals("Width of the table has been changed.", boundsBeforeInsert.width, boundsAfterInsert.width); //$NON-NLS-1$
- assertEquals("Height of the table has been changed.", boundsBeforeInsert.height, boundsAfterInsert.height); //$NON-NLS-1$
+ assertEquals("Width of the table has been changed.", boundsBeforeInsert.width, boundsAfterInsert.width-4); //$NON-NLS-1$
+ assertEquals("Height of the table has been changed.", boundsBeforeInsert.height, boundsAfterInsert.height-4); //$NON-NLS-1$
if(getException()!=null) {
throw getException();
Modified: branches/jbosstools-3.2.x/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/Flasher.java
===================================================================
--- branches/jbosstools-3.2.x/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/Flasher.java 2011-02-11 13:52:11 UTC (rev 29115)
+++ branches/jbosstools-3.2.x/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/editor/Flasher.java 2011-02-11 15:29:36 UTC (rev 29116)
@@ -18,7 +18,7 @@
private inIFlasher iFlasher;
private static final boolean IS_OPEN_JDK = (System.getProperty("java.runtime.name")!=null&&System.getProperty("java.runtime.name").contains("OpenJDK")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//fix for JBIDE-7957
- private static final boolean IS_LINUX_X86_64=Platform.OS_LINUX.equals(Platform.getOS())&&Platform.ARCH_X86_64.equals(Platform.getOSArch());
+ private static final boolean IS_LINUX=Platform.OS_LINUX.equals(Platform.getOS());
// added by Maksim Areshkau as element for which we
// have drowed border. When we draw new border,
// we should remove old one;
@@ -34,7 +34,7 @@
//fix for JBIDE-7295, added by Maksim Areshkau
if (Platform.OS_MACOSX.equals(Platform.getOS())
||IS_OPEN_JDK
- ||IS_LINUX_X86_64) {
+ ||IS_LINUX) {
drawOutline = new DrawOutlineInterface() {
private nsIDOMElement lastBorderedElement = null;
public void drawElementOutline(nsIDOMElement domElement) {
13 years, 11 months
JBoss Tools SVN: r29115 - trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/wizard.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-02-11 08:52:11 -0500 (Fri, 11 Feb 2011)
New Revision: 29115
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/wizard/NewCDIWizardTest.java
Log:
JBIDE-8264
https://issues.jboss.org/browse/JBIDE-8264
Modified: trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/wizard/NewCDIWizardTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/wizard/NewCDIWizardTest.java 2011-02-11 13:51:11 UTC (rev 29114)
+++ trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/wizard/NewCDIWizardTest.java 2011-02-11 13:52:11 UTC (rev 29115)
@@ -52,6 +52,8 @@
import org.jboss.tools.cdi.ui.wizard.NewScopeWizardPage;
import org.jboss.tools.cdi.ui.wizard.NewStereotypeWizardPage;
import org.jboss.tools.common.EclipseUtil;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.util.FileUtil;
import org.jboss.tools.test.util.JUnitUtils;
import org.jboss.tools.test.util.JobUtils;
@@ -189,7 +191,11 @@
page.setInherited(true);
page.setTarget("METHOD,FIELD");
page.setNamed(true);
+ page.setAlternative(true);
+ page.setToBeRegisteredInBeansXML(true);
+ assertTrue(page.isToBeRegisteredInBeansXML());
+
context.wizard.performFinish();
String text = context.getNewTypeContent();
@@ -199,6 +205,12 @@
assertTrue(text.contains("@Named"));
assertTrue(text.contains("@Target({ METHOD, FIELD })"));
assertTrue(text.contains("@Retention(RUNTIME)"));
+
+ IProject tck = ResourcesPlugin.getWorkspace().getRoot().getProject("tck");
+ IFile f = tck.getFile("WebContent/WEB-INF/beans.xml");
+ XModelObject o = EclipseResourceUtil.createObjectForResource(f);
+ XModelObject c = o.getChildByPath("Alternatives/" + PACK_NAME + "." + STEREOTYPE_NAME);
+ assertNotNull(c);
} finally {
context.close();
@@ -342,6 +354,12 @@
assertTrue(text.contains("@Interceptor"));
assertTrue(text.contains("@" + INTERCEPTOR_BINDING_NAME));
+
+ IProject tck = ResourcesPlugin.getWorkspace().getRoot().getProject("tck");
+ IFile f = tck.getFile("WebContent/WEB-INF/beans.xml");
+ XModelObject o = EclipseResourceUtil.createObjectForResource(f);
+ XModelObject c = o.getChildByPath("Interceptors/" + PACK_NAME + "." + INTERCEPTOR_NAME);
+ assertNotNull(c);
} finally {
context.close();
}
13 years, 11 months
JBoss Tools SVN: r29114 - trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-02-11 08:51:11 -0500 (Fri, 11 Feb 2011)
New Revision: 29114
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeanCreationWizard.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeanWizardPage.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeansXMLCreationWizard.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewDecoratorCreationWizard.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewDecoratorWizardPage.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorCreationWizard.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorWizardPage.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewStereotypeCreationWizard.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewStereotypeWizardPage.java
Log:
JBIDE-8264
https://issues.jboss.org/browse/JBIDE-8264
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeanCreationWizard.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeanCreationWizard.java 2011-02-11 13:41:22 UTC (rev 29113)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeanCreationWizard.java 2011-02-11 13:51:11 UTC (rev 29114)
@@ -11,8 +11,25 @@
package org.jboss.tools.cdi.ui.wizard;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.ui.wizards.NewClassWizardPage;
import org.jboss.tools.cdi.ui.CDIUIMessages;
+import org.jboss.tools.cdi.ui.CDIUIPlugin;
+import org.jboss.tools.common.meta.action.XActionInvoker;
+import org.jboss.tools.common.meta.action.impl.handlers.DefaultCreateHandler;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.filesystems.impl.FileAnyImpl;
+import org.jboss.tools.common.model.options.PreferenceModelUtilities;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
/**
*
@@ -29,6 +46,7 @@
super.initPageFromAdapter();
if(adapter != null) {
((NewBeanWizardPage)fPage).setAlternative(true);
+ ((NewBeanWizardPage)fPage).setMayBeRegisteredInBeansXML(false);
}
}
/*
@@ -50,5 +68,58 @@
protected boolean canRunForked() {
return !fPage.isEnclosingTypeSelected();
}
+
+ public boolean performFinish() {
+ boolean res = super.performFinish();
+ if(res && ((NewBeanWizardPage)fPage).isToBeRegisteredInBeansXML()) {
+ IProject project = fPage.getCreatedType().getResource().getProject();
+ registerInBeansXML(project, fPage.getCreatedType().getFullyQualifiedName(), "Alternatives", "CDIClass", "class");
+ }
+ return res;
+ }
+ public static void registerInBeansXML(IProject project, String typeName, String folderName, String entity, String attribute) {
+ IPath path = NewBeansXMLCreationWizard.getContainerForBeansXML(project);
+ if(path != null) {
+ path = path.append("beans.xml").removeFirstSegments(1);
+ IFile beansxml = project.getFile(path);
+ if(!beansxml.exists()) {
+ try {
+ createBeansXML(beansxml);
+ } catch (CoreException e) {
+ CDIUIPlugin.getDefault().logError(e);
+ }
+ }
+ if(beansxml.exists()) {
+ XModelObject o = EclipseResourceUtil.createObjectForResource(beansxml);
+ if(o != null) {
+ XModelObject as = o.getChildByPath(folderName);
+ XModelObject c = as.getModel().createModelObject(entity, new Properties());
+ c.setAttributeValue(attribute, typeName);
+ try {
+ DefaultCreateHandler.addCreatedObject(as, c, 0);
+ XActionInvoker.invoke("SaveActions.Save", o, new Properties());
+ } catch (CoreException e) {
+ CDIUIPlugin.getDefault().logError(e);
+ }
+ }
+ }
+ }
+ }
+
+ public static void createBeansXML(IFile f) throws CoreException {
+ if(f.exists()) return;
+ IFolder folder = (IFolder)f.getParent();
+ if(!folder.exists()) {
+ folder.create(true, true, new NullProgressMonitor());
+ }
+ f.create(getBeansXMLInitialContents(), true, new NullProgressMonitor());
+ }
+
+ public static InputStream getBeansXMLInitialContents() {
+ FileAnyImpl file = (FileAnyImpl)PreferenceModelUtilities.getPreferenceModel().createModelObject("FileCDIBeans", new Properties());
+ return new ByteArrayInputStream(file.getAsText().getBytes());
+ }
+
+
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeanWizardPage.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeanWizardPage.java 2011-02-11 13:41:22 UTC (rev 29113)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeanWizardPage.java 2011-02-11 13:51:11 UTC (rev 29114)
@@ -76,6 +76,8 @@
*/
public class NewBeanWizardPage extends NewClassWizardPage {
protected CheckBoxEditorWrapper alternative = null;
+ protected boolean mayBeRegisteredInBeansXML = true;
+ protected CheckBoxEditorWrapper registerInBeansXML = null;
protected CheckBoxEditorWrapper isNamed;
protected BeanNameEditorWrapper beanName;
@@ -96,6 +98,10 @@
setImageDescriptor(CDIUiImages.getImageDescriptor(CDIUiImages.WELD_WIZARD_IMAGE_PATH));
}
+ public void setMayBeRegisteredInBeansXML(boolean b) {
+ mayBeRegisteredInBeansXML = b;
+ }
+
public void init(IStructuredSelection selection) {
super.init(selection);
if (selection != null && !selection.isEmpty()) {
@@ -256,6 +262,7 @@
protected void createCustomFields(Composite composite) {
createBeanNameField(composite);
createAlternativeField(composite);
+ createRegisterInBeansXML(composite);
createScopeField(composite);
createQualifiersField(composite);
}
@@ -378,13 +385,28 @@
beanName.composite.setEnabled(named);
}});
}
-
protected void createAlternativeField(Composite composite) {
String label = "Add @Alternative";
alternative = createCheckBoxField(composite, "isAlternative", label, isAlternativeInitialValue);
+ if(mayBeRegisteredInBeansXML) {
+ alternative.checkBox.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ boolean isAlternative = "true".equals(alternative.checkBox.getValueAsString());
+ if(registerInBeansXML != null) {
+ registerInBeansXML.composite.setEnabled(isAlternative);
+ }
+ }});
+ }
}
- protected CheckBoxEditorWrapper createCheckBoxField(Composite composite, String name, String label, boolean defaultValue) {
+ protected void createRegisterInBeansXML(Composite composite) {
+ if(!mayBeRegisteredInBeansXML) return;
+ String label = "Register in beans.xml";
+ registerInBeansXML = createCheckBoxField(composite, "register", label, isAlternativeInitialValue);
+ registerInBeansXML.composite.setEnabled(isAlternativeInitialValue);
+ }
+
+ protected static CheckBoxEditorWrapper createCheckBoxField(Composite composite, String name, String label, boolean defaultValue) {
CheckBoxEditorWrapper wrapper = new CheckBoxEditorWrapper();
wrapper.checkBox = new CheckBoxFieldEditor(name,"",Boolean.valueOf(defaultValue));
CompositeEditor editor = new CompositeEditor(name,"", defaultValue);
@@ -433,4 +455,11 @@
}
}
+ public boolean isToBeRegisteredInBeansXML() {
+ if(registerInBeansXML != null && alternative != null ) {
+ return alternative.composite.getValue() == Boolean.TRUE && registerInBeansXML.composite.getValue() == Boolean.TRUE;
+ }
+ return false;
+ }
+
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeansXMLCreationWizard.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeansXMLCreationWizard.java 2011-02-11 13:41:22 UTC (rev 29113)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewBeansXMLCreationWizard.java 2011-02-11 13:51:11 UTC (rev 29114)
@@ -196,4 +196,24 @@
}
+ public static IPath getContainerForBeansXML(IProject p) {
+ IPath path = ProjectHome.getWebInfPath(p);
+ if(path == null) {
+ boolean needMetaInf = false;
+ Set<IFolder> fs = EclipseResourceUtil.getSourceFolders(p);
+ if(fs != null) for (IFolder f: fs) {
+ IFolder fm = f.getFolder("META-INF");
+ IPath pth = fm.getFullPath();
+ if(path == null) {
+ path = pth;
+ needMetaInf = !fm.exists();
+ } else if(needMetaInf && fm.exists()) {
+ path = pth;
+ needMetaInf = false;
+ }
+ }
+ }
+ return path;
+ }
+
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewDecoratorCreationWizard.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewDecoratorCreationWizard.java 2011-02-11 13:41:22 UTC (rev 29113)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewDecoratorCreationWizard.java 2011-02-11 13:51:11 UTC (rev 29114)
@@ -11,6 +11,7 @@
package org.jboss.tools.cdi.ui.wizard;
+import org.eclipse.core.resources.IProject;
import org.eclipse.jdt.ui.wizards.NewClassWizardPage;
import org.jboss.tools.cdi.ui.CDIUIMessages;
@@ -34,6 +35,9 @@
fPage = new NewDecoratorWizardPage();
((NewClassWizardPage)fPage).init(getSelection());
initPageFromAdapter();
+ if(adapter != null) {
+ ((NewDecoratorWizardPage)fPage).setMayBeRegisteredInBeansXML(false);
+ }
}
addPage(fPage);
}
@@ -45,4 +49,13 @@
return !fPage.isEnclosingTypeSelected();
}
+ public boolean performFinish() {
+ boolean res = super.performFinish();
+ if(res && ((NewDecoratorWizardPage)fPage).isToBeRegisteredInBeansXML()) {
+ IProject project = fPage.getCreatedType().getResource().getProject();
+ NewBeanCreationWizard.registerInBeansXML(project, fPage.getCreatedType().getFullyQualifiedName(), "Decorators", "CDIClass", "class");
+ }
+ return res;
+ }
+
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewDecoratorWizardPage.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewDecoratorWizardPage.java 2011-02-11 13:41:22 UTC (rev 29113)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewDecoratorWizardPage.java 2011-02-11 13:51:11 UTC (rev 29114)
@@ -51,6 +51,7 @@
import org.jboss.tools.cdi.core.CDICorePlugin;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUiImages;
+import org.jboss.tools.cdi.ui.wizard.NewBeanWizardPage.CheckBoxEditorWrapper;
import org.jboss.tools.common.java.generation.JavaBeanGenerator;
import org.jboss.tools.common.ui.widget.editor.CompositeEditor;
import org.jboss.tools.common.ui.widget.editor.IFieldEditor;
@@ -70,12 +71,19 @@
protected StatusInfo fieldNameStatus = new StatusInfo();
+ protected boolean mayBeRegisteredInBeansXML = true;
+ protected CheckBoxEditorWrapper registerInBeansXML = null;
+
public NewDecoratorWizardPage() {
setTitle(CDIUIMessages.NEW_DECORATOR_WIZARD_PAGE_NAME);
setDescription(CDIUIMessages.NEW_DECORATOR_WIZARD_DESCRIPTION);
setImageDescriptor(CDIUiImages.getImageDescriptor(CDIUiImages.WELD_WIZARD_IMAGE_PATH));
}
+ public void setMayBeRegisteredInBeansXML(boolean b) {
+ mayBeRegisteredInBeansXML = b;
+ }
+
public void init(IStructuredSelection selection) {
super.init(selection);
defaultTypeName = null;
@@ -227,6 +235,7 @@
protected void createCustomFields(Composite composite) {
createFieldNameField(composite);
+ createRegisterInBeansXML(composite);
}
protected void createFieldNameField(Composite composite) {
@@ -277,6 +286,12 @@
}
+ protected void createRegisterInBeansXML(Composite composite) {
+ if(!mayBeRegisteredInBeansXML) return;
+ String label = "Register in beans.xml";
+ registerInBeansXML = NewBeanWizardPage.createCheckBoxField(composite, "register", label, true);
+ }
+
protected IField createDelegateField(IType type, ImportsManager imports,
IProgressMonitor monitor, String lineDelimiter)
throws CoreException {
@@ -417,4 +432,11 @@
}
+ public boolean isToBeRegisteredInBeansXML() {
+ if(registerInBeansXML != null) {
+ return registerInBeansXML.composite.getValue() == Boolean.TRUE;
+ }
+ return false;
+ }
+
}
\ No newline at end of file
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorCreationWizard.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorCreationWizard.java 2011-02-11 13:41:22 UTC (rev 29113)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorCreationWizard.java 2011-02-11 13:51:11 UTC (rev 29114)
@@ -11,6 +11,7 @@
package org.jboss.tools.cdi.ui.wizard;
+import org.eclipse.core.resources.IProject;
import org.jboss.tools.cdi.ui.CDIUIMessages;
/**
@@ -33,6 +34,9 @@
fPage = new NewInterceptorWizardPage();
((NewInterceptorWizardPage)fPage).init(getSelection());
initPageFromAdapter();
+ if(adapter != null) {
+ ((NewInterceptorWizardPage)fPage).setMayBeRegisteredInBeansXML(false);
+ }
}
addPage(fPage);
}
@@ -44,4 +48,13 @@
return !fPage.isEnclosingTypeSelected();
}
+ public boolean performFinish() {
+ boolean res = super.performFinish();
+ if(res && ((NewInterceptorWizardPage)fPage).isToBeRegisteredInBeansXML()) {
+ IProject project = fPage.getCreatedType().getResource().getProject();
+ NewBeanCreationWizard.registerInBeansXML(project, fPage.getCreatedType().getFullyQualifiedName(), "Interceptors", "CDIClass", "class");
+ }
+ return res;
+ }
+
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorWizardPage.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorWizardPage.java 2011-02-11 13:41:22 UTC (rev 29113)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewInterceptorWizardPage.java 2011-02-11 13:51:11 UTC (rev 29114)
@@ -63,6 +63,7 @@
import org.jboss.tools.cdi.core.ICDIProject;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUiImages;
+import org.jboss.tools.cdi.ui.wizard.NewBeanWizardPage.CheckBoxEditorWrapper;
import org.jboss.tools.common.java.generation.JavaBeanGenerator;
import org.jboss.tools.common.ui.widget.editor.CompositeEditor;
import org.jboss.tools.common.ui.widget.editor.IFieldEditor;
@@ -83,6 +84,13 @@
protected StatusInfo methodNameStatus = new StatusInfo();
protected StatusInfo interceptorBindingsStatus = new StatusInfo();
+ protected boolean mayBeRegisteredInBeansXML = true;
+ protected CheckBoxEditorWrapper registerInBeansXML = null;
+
+ public void setMayBeRegisteredInBeansXML(boolean b) {
+ mayBeRegisteredInBeansXML = b;
+ }
+
public NewInterceptorWizardPage() {
setTitle(CDIUIMessages.NEW_INTERCEPTOR_WIZARD_PAGE_NAME);
setDescription(CDIUIMessages.NEW_INTERCEPTOR_WIZARD_DESCRIPTION);
@@ -181,6 +189,7 @@
protected void createCustomFields(Composite composite) {
createInterceptorBindingField(composite);
createMethodNameField(composite);
+ createRegisterInBeansXML(composite);
}
protected void createInterceptorBindingField(Composite composite) {
@@ -217,6 +226,12 @@
});
}
+ protected void createRegisterInBeansXML(Composite composite) {
+ if(!mayBeRegisteredInBeansXML) return;
+ String label = "Register in beans.xml";
+ registerInBeansXML = NewBeanWizardPage.createCheckBoxField(composite, "register", label, true);
+ }
+
void setInterceptorBindings(IPackageFragmentRoot root) {
interceptorBindingsProvider.setProject(null);
if(root != null) {
@@ -326,4 +341,11 @@
return result;
}
+ public boolean isToBeRegisteredInBeansXML() {
+ if(registerInBeansXML != null) {
+ return registerInBeansXML.composite.getValue() == Boolean.TRUE;
+ }
+ return false;
+ }
+
}
\ No newline at end of file
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewStereotypeCreationWizard.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewStereotypeCreationWizard.java 2011-02-11 13:41:22 UTC (rev 29113)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewStereotypeCreationWizard.java 2011-02-11 13:51:11 UTC (rev 29114)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.cdi.ui.wizard;
+import org.eclipse.core.resources.IProject;
import org.eclipse.jdt.ui.wizards.NewAnnotationWizardPage;
import org.jboss.tools.cdi.ui.CDIUIMessages;
@@ -32,7 +33,17 @@
super.initPageFromAdapter();
if(adapter != null) {
((NewStereotypeWizardPage)fPage).setAlternative(true);
+ ((NewStereotypeWizardPage)fPage).setMayBeRegisteredInBeansXML(false);
}
}
+ public boolean performFinish() {
+ boolean res = super.performFinish();
+ if(res && ((NewStereotypeWizardPage)fPage).isToBeRegisteredInBeansXML()) {
+ IProject project = fPage.getCreatedType().getResource().getProject();
+ NewBeanCreationWizard.registerInBeansXML(project, fPage.getCreatedType().getFullyQualifiedName(), "Alternatives", "CDIStereotype", "stereotype");
+ }
+ return res;
+ }
+
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewStereotypeWizardPage.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewStereotypeWizardPage.java 2011-02-11 13:41:22 UTC (rev 29113)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/wizard/NewStereotypeWizardPage.java 2011-02-11 13:51:11 UTC (rev 29114)
@@ -36,6 +36,7 @@
import org.jboss.tools.cdi.internal.core.validation.AnnotationValidationDelegate;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
+import org.jboss.tools.cdi.ui.wizard.NewBeanWizardPage.CheckBoxEditorWrapper;
import org.jboss.tools.common.ui.widget.editor.ITaggedFieldEditor;
import org.jboss.tools.common.ui.widget.editor.ListFieldEditor;
@@ -46,6 +47,9 @@
*/
public class NewStereotypeWizardPage extends NewCDIAnnotationWizardPage {
protected CheckBoxEditorWrapper alternative = null;
+ protected boolean mayBeRegisteredInBeansXML = true;
+ protected CheckBoxEditorWrapper registerInBeansXML = null;
+
protected CheckBoxEditorWrapper named = null;
protected ITaggedFieldEditor scope = null;
protected Map<String, String> scopes = new TreeMap<String, String>();
@@ -62,6 +66,10 @@
setTitle(CDIUIMessages.NEW_STEREOTYPE_WIZARD_PAGE_NAME);
}
+ public void setMayBeRegisteredInBeansXML(boolean b) {
+ mayBeRegisteredInBeansXML = b;
+ }
+
protected void addAnnotations(ImportsManager imports, StringBuffer sb, String lineDelimiter) {
addStereotypeAnnotation(imports, sb, lineDelimiter);
addInheritedAnnotation(imports, sb, lineDelimiter);
@@ -131,6 +139,7 @@
protected void createCustomFields(Composite composite) {
createInheritedField(composite, false);
createAlternativeField(composite);
+ createRegisterInBeansXML(composite);
createNamedField(composite);
createScopeField(composite);
createTargetField(composite);
@@ -141,8 +150,24 @@
protected void createAlternativeField(Composite composite) {
String label = "Add @Alternative";
alternative = createCheckBoxField(composite, "isAlternative", label, isAlternativeInitialValue);
+ if(mayBeRegisteredInBeansXML) {
+ alternative.checkBox.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ boolean isAlternative = "true".equals(alternative.checkBox.getValueAsString());
+ if(registerInBeansXML != null) {
+ registerInBeansXML.composite.setEnabled(isAlternative);
+ }
+ }});
+ }
}
+ protected void createRegisterInBeansXML(Composite composite) {
+ if(!mayBeRegisteredInBeansXML) return;
+ String label = "Register in beans.xml";
+ registerInBeansXML = createCheckBoxField(composite, "register", label, isAlternativeInitialValue);
+ registerInBeansXML.composite.setEnabled(isAlternativeInitialValue);
+ }
+
protected void createNamedField(Composite composite) {
String label = "Add @Named";
named = createCheckBoxField(composite, "isNamed", label, false);
@@ -335,4 +360,17 @@
}
}
+ public void setToBeRegisteredInBeansXML(boolean value) {
+ if(registerInBeansXML != null) {
+ registerInBeansXML.composite.setValue(Boolean.valueOf(value));
+ }
+ }
+
+ public boolean isToBeRegisteredInBeansXML() {
+ if(registerInBeansXML != null && alternative != null ) {
+ return alternative.composite.getValue() == Boolean.TRUE && registerInBeansXML.composite.getValue() == Boolean.TRUE;
+ }
+ return false;
+ }
+
}
13 years, 11 months
JBoss Tools SVN: r29113 - trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2011-02-11 08:41:22 -0500 (Fri, 11 Feb 2011)
New Revision: 29113
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationSettingsTab.java
Log:
https://issues.jboss.org/browse/JBIDE-8233
Validate the name of reveng.strategy
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationSettingsTab.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationSettingsTab.java 2011-02-11 12:54:26 UTC (rev 29112)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationSettingsTab.java 2011-02-11 13:41:22 UTC (rev 29113)
@@ -33,6 +33,7 @@
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
import org.eclipse.jdt.core.JavaConventions;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.ComboDialogField;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
@@ -328,6 +329,16 @@
return;
}
}
+
+ if(reverseEngineeringStrategy.isEnabled() && reverseEngineeringStrategy.getText().trim().length()>0) {
+ IStatus val= JavaConventions.validateJavaTypeName(getReverseEngineeringStrategy(),JavaCore.VERSION_1_5, JavaCore.VERSION_1_5 );
+ if (val.getSeverity() == IStatus.ERROR ) {
+ updateStatus(val.getMessage() );
+ return;
+ } else if (val.getSeverity() == IStatus.WARNING){
+ warning = val.getMessage();
+ }
+ }
if(useOwnTemplates.isSelected() ) {
msg = PathHelper.checkDirectory(templatedir.getText(), HibernateConsoleMessages.CodeGenerationSettingsTab_template_dir, true);
13 years, 11 months
JBoss Tools SVN: r29112 - in trunk/hibernatetools/plugins/org.hibernate.eclipse.console: src/org/hibernate/eclipse/console and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2011-02-11 07:54:26 -0500 (Fri, 11 Feb 2011)
New Revision: 29112
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/CodeGenerationConsoleNameChange.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/ConsoleConfigurationRenameParticipant.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/ConsoleConfigurationRenameProcessor.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/Messages.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/ProjectDefaultConfigurationChange.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/messages.properties
Removed:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/CodeGenerationReseourceNameChange.java
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsolePlugin.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/ConnectionProfileRenameParticipant.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/ConsoleConfigurationITypeRenameParticipant.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/HibernateRefactoringUtil.java
Log:
https://issues.jboss.org/browse/JBIDE-8236
Refactoring: rename console configuration as refactoring change
Update console configuration associated with a project and code generation configuration.
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml 2011-02-11 12:30:01 UTC (rev 29111)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml 2011-02-11 12:54:26 UTC (rev 29112)
@@ -714,6 +714,21 @@
</with>
</enablement>
</renameParticipant>
+ <renameParticipant
+ class="org.hibernate.eclipse.launch.core.refactoring.ConsoleConfigurationRenameParticipant"
+ id="org.hibernate.eclipse.console.renameParticipant1"
+ name="ConsoleConfigurationRenameParticipant">
+ <enablement>
+ <with
+ variable="element">
+ <and>
+ <instanceof
+ value="org.eclipse.debug.internal.core.LaunchConfiguration">
+ </instanceof>
+ </and>
+ </with>
+ </enablement>
+ </renameParticipant>
</extension>
<extension
point="org.eclipse.ltk.core.refactoring.moveParticipants">
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java 2011-02-11 12:30:01 UTC (rev 29111)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java 2011-02-11 12:54:26 UTC (rev 29112)
@@ -485,6 +485,8 @@
public static String PathHelper_has_to_be_folder_or_project;
public static String PathHelper_has_to_be_file;
public static String PathHelper_project_for_is_closed;
+
+ public static String EditConsoleConfiguration_rename_refactoring_error_totle;
//
public static String HibernateRefactoringUtil_error_during_refactoring;
public static String HibernateRefactoringUtil_error_occured_while_updating_classpath;
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties 2011-02-11 12:30:01 UTC (rev 29111)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties 2011-02-11 12:54:26 UTC (rev 29112)
@@ -492,6 +492,8 @@
PathHelper_has_to_be_file={0} has to be a file [{1}]
PathHelper_project_for_is_closed=Project for {0} is closed [{1}]
+EditConsoleConfiguration_rename_refactoring_error_totle = Refactoring Error
+
HibernateRefactoringUtil_error_during_refactoring=Error during refactoring
HibernateRefactoringUtil_error_occured_while_updating_classpath=Error occured while updating classpath.
LaunchConfigurationResourceNameChange_update_resource_path_in_launch_cfg=Update resource path in launch configuration ''{0}''
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsolePlugin.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsolePlugin.java 2011-02-11 12:30:01 UTC (rev 29111)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsolePlugin.java 2011-02-11 12:54:26 UTC (rev 29112)
@@ -28,10 +28,12 @@
import java.util.MissingResourceException;
import java.util.ResourceBundle;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugPlugin;
@@ -47,6 +49,9 @@
import org.eclipse.jface.text.IDocumentExtension3;
import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jpt.core.JptCorePlugin;
+import org.eclipse.ltk.core.refactoring.CheckConditionsOperation;
+import org.eclipse.ltk.core.refactoring.PerformRefactoringOperation;
+import org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
@@ -69,6 +74,7 @@
import org.hibernate.eclipse.hqleditor.HQLEditorInput;
import org.hibernate.eclipse.hqleditor.HQLEditorStorage;
import org.hibernate.eclipse.launch.ICodeGenerationLaunchConstants;
+import org.hibernate.eclipse.launch.core.refactoring.ConsoleConfigurationRenameProcessor;
import org.hibernate.eclipse.logging.PluginLogger;
import org.hibernate.eclipse.logging.xpl.EclipseLogger;
import org.osgi.framework.BundleContext;
@@ -196,6 +202,7 @@
KnownConfigurations instance = KnownConfigurations.getInstance();
ConsoleConfiguration oldcfg = instance.find( movedFrom.getName() );
if(oldcfg!=null) {
+ refactor(movedFrom, configuration);//call this before we remove old configuration
oldcfg.reset(); // reset it no matter what.
instance.removeConfiguration(oldcfg, false);
}
@@ -209,9 +216,34 @@
instance.addConfiguration(new ConsoleConfiguration(adapter), true);
}
- }
}
+ }
+
+ private void refactor (ILaunchConfiguration oldConfiguration, ILaunchConfiguration newConfiguration) {
+ if (!oldConfiguration.getName().equals(newConfiguration.getName())){
+ //only rename of console configuration refactoring is supported.
+ ConsoleConfigurationRenameProcessor proc = new ConsoleConfigurationRenameProcessor(oldConfiguration, newConfiguration.getName());
+ // Refactor for rename
+ PerformRefactoringOperation refOperation = new PerformRefactoringOperation(
+ new ProcessorBasedRefactoring(proc),
+ CheckConditionsOperation.ALL_CONDITIONS);
+ try
+ {
+ ResourcesPlugin.getWorkspace().run(refOperation, null);
+ }
+ catch (OperationCanceledException oce)
+ {
+ throw new OperationCanceledException();
+ }
+ catch (CoreException ce)
+ {
+ HibernateConsolePlugin.openError(new Shell(), HibernateConsoleMessages.EditConsoleConfiguration_rename_refactoring_error_totle,
+ ce.getLocalizedMessage(), ce, HibernateConsolePlugin.PERFORM_SYNC_EXEC);
+ }
+ }
+ }
+
private boolean isTemporary(ILaunchConfiguration configuration) {
boolean temporary = true;
try {
Added: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/CodeGenerationConsoleNameChange.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/CodeGenerationConsoleNameChange.java (rev 0)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/CodeGenerationConsoleNameChange.java 2011-02-11 12:54:26 UTC (rev 29112)
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.eclipse.launch.core.refactoring;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.osgi.util.NLS;
+import org.hibernate.console.KnownConfigurations;
+import org.hibernate.eclipse.launch.HibernateLaunchConstants;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class CodeGenerationConsoleNameChange extends Change {
+
+ private ILaunchConfiguration fLaunchConfiguration;
+
+ private String newCCName;
+
+ public CodeGenerationConsoleNameChange(ILaunchConfiguration launchConfiguration, String newCCName){
+ assert KnownConfigurations.getInstance().isKnownConfiguration(launchConfiguration.getName());
+ this.fLaunchConfiguration = launchConfiguration;
+ this.newCCName = newCCName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.Change#getName()
+ */
+ @Override
+ public String getName() {
+ return NLS.bind(Messages.CodeGenerationConsoleNameChange_update, fLaunchConfiguration.getName());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.Change#initializeValidationData(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void initializeValidationData(IProgressMonitor pm) {}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.Change#isValid(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException,
+ OperationCanceledException {
+ if (fLaunchConfiguration.getAttribute(HibernateLaunchConstants.ATTR_CONSOLE_CONFIGURATION_NAME, (String)null) == null){
+ return RefactoringStatus.createFatalErrorStatus(Messages.CodeGenerationConsoleNameChange_error_null_confi);
+ } else if (newCCName == null || newCCName.trim().length() == 0){
+ return RefactoringStatus.createFatalErrorStatus(Messages.CodeGenerationConsoleNameChange_error_empty_name);
+ }
+ return new RefactoringStatus();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.Change#perform(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public Change perform(IProgressMonitor pm) throws CoreException {
+ String oldName = fLaunchConfiguration.getAttribute(HibernateLaunchConstants.ATTR_CONSOLE_CONFIGURATION_NAME, new String());
+ ILaunchConfigurationWorkingCopy wc = fLaunchConfiguration.getWorkingCopy();
+ wc.setAttribute(HibernateLaunchConstants.ATTR_CONSOLE_CONFIGURATION_NAME, newCCName);
+ ILaunchConfiguration newLaunchConfig = wc.doSave();
+ return new CodeGenerationConsoleNameChange(newLaunchConfig, oldName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.Change#getModifiedElement()
+ */
+ @Override
+ public Object getModifiedElement() {
+ return fLaunchConfiguration;
+ }
+
+}
Deleted: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/CodeGenerationReseourceNameChange.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/CodeGenerationReseourceNameChange.java 2011-02-11 12:30:01 UTC (rev 29111)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/CodeGenerationReseourceNameChange.java 2011-02-11 12:54:26 UTC (rev 29112)
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.hibernate.eclipse.launch.core.refactoring;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.ltk.core.refactoring.Change;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.osgi.util.NLS;
-import org.hibernate.eclipse.console.HibernateConsoleMessages;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public class CodeGenerationReseourceNameChange extends Change {
-
- private ILaunchConfiguration fLaunchConfiguration;
- private IPath fOldPath;
- private IPath fNewPath;
-
- CodeGenerationReseourceNameChange(ILaunchConfiguration launchConfiguration, IPath oldPath, IPath newPath){
- fLaunchConfiguration = launchConfiguration;
- fOldPath = oldPath;
- fNewPath = newPath;
- }
-
- @Override
- public Object getModifiedElement() {
- return fLaunchConfiguration;
- }
-
- @Override
- public String getName() {
- return NLS.bind(HibernateConsoleMessages.LaunchConfigurationResourceNameChange_update_resource_path_in_launch_cfg, fLaunchConfiguration.getName());
- }
-
- @Override
- public void initializeValidationData(IProgressMonitor pm) { }
-
- @Override
- public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException,
- OperationCanceledException {
- return new RefactoringStatus();
- }
-
- @Override
- public Change perform(IProgressMonitor pm) throws CoreException {
- fLaunchConfiguration = HibernateRefactoringUtil.updateCodeGenerationConfig(fLaunchConfiguration, fOldPath, fNewPath);
- return new CodeGenerationReseourceNameChange(fLaunchConfiguration, fNewPath, fOldPath);
- }
-
-}
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/ConnectionProfileRenameParticipant.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/ConnectionProfileRenameParticipant.java 2011-02-11 12:30:01 UTC (rev 29111)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/ConnectionProfileRenameParticipant.java 2011-02-11 12:54:26 UTC (rev 29112)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2011 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.hibernate.eclipse.launch.core.refactoring;
import java.util.ArrayList;
@@ -14,6 +24,10 @@
import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
import org.hibernate.eclipse.console.HibernateConsoleMessages;
+/**
+ * @author Dmitry Geraskov
+ *
+ */
public class ConnectionProfileRenameParticipant extends RenameParticipant {
IConnectionProfile profile;
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/ConsoleConfigurationITypeRenameParticipant.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/ConsoleConfigurationITypeRenameParticipant.java 2011-02-11 12:30:01 UTC (rev 29111)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/ConsoleConfigurationITypeRenameParticipant.java 2011-02-11 12:54:26 UTC (rev 29112)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2009-2011 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.hibernate.eclipse.launch.core.refactoring;
import org.eclipse.core.runtime.CoreException;
@@ -9,6 +19,10 @@
import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
import org.hibernate.eclipse.console.HibernateConsoleMessages;
+/**
+ * @author Dmitry Geraskov
+ *
+ */
public class ConsoleConfigurationITypeRenameParticipant extends
RenameParticipant {
Added: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/ConsoleConfigurationRenameParticipant.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/ConsoleConfigurationRenameParticipant.java (rev 0)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/ConsoleConfigurationRenameParticipant.java 2011-02-11 12:54:26 UTC (rev 29112)
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.eclipse.launch.core.refactoring;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
+import org.hibernate.console.KnownConfigurations;
+
+/**
+ *
+ * @author Dmitry Geraskov
+ *
+ */
+public class ConsoleConfigurationRenameParticipant extends RenameParticipant {
+
+ private String oldName;
+
+ @Override
+ protected boolean initialize(Object element) {
+ if (element instanceof ILaunchConfiguration) {
+ oldName = ((ILaunchConfiguration) element).getName();
+ return KnownConfigurations.getInstance().isKnownConfiguration(oldName);
+ }
+ return false;
+ }
+
+ @Override
+ public String getName() {
+ return Messages.ConsoleConfigurationRenameParticipant_name;
+ }
+
+ @Override
+ public RefactoringStatus checkConditions(IProgressMonitor pm,
+ CheckConditionsContext context) throws OperationCanceledException {
+ return new RefactoringStatus();
+ }
+
+ @Override
+ public Change createChange(IProgressMonitor pm) throws CoreException,
+ OperationCanceledException {
+ CompositeChange change = new CompositeChange(Messages.ConsoleConfigurationRenameParticipant_change_name);
+ change.markAsSynthetic();
+ CompositeChange change1 = new CompositeChange(Messages.ConsoleConfigurationRenameParticipant_update_code_generations);
+ change1.addAll(getCodeGenerationConsoleNameChanges());
+ CompositeChange change2 = new CompositeChange(Messages.ConsoleConfigurationRenameParticipant_update_project_config);
+ change2.addAll(getProjectDefaultConfigurationChanges());
+ change.add(change1);
+ change.add(change2);
+ return change;
+ }
+
+ /**
+ * @return CodeGenerationConsoleNameChanges
+ */
+ private Change[] getCodeGenerationConsoleNameChanges() {
+ ILaunchConfiguration[] affectedConfigurations = HibernateRefactoringUtil.getAffectedCodeGenerationConfigs(oldName);
+ Change[] changes = new Change[affectedConfigurations.length];
+ for (int i = 0; i < affectedConfigurations.length; i++) {
+ changes[i] = new CodeGenerationConsoleNameChange(affectedConfigurations[i], getArguments().getNewName());
+ }
+ return changes;
+ }
+
+ /**
+ * @return
+ */
+ private Change[] getProjectDefaultConfigurationChanges() {
+ IProject[] affectedProjects = HibernateRefactoringUtil.getAffectedProjects(oldName);
+ Change[] changes = new Change[affectedProjects.length];
+ for (int i = 0; i < affectedProjects.length; i++) {
+ changes[i] = new ProjectDefaultConfigurationChange(affectedProjects[i], getArguments().getNewName());
+ }
+ return changes;
+ }
+
+}
Added: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/ConsoleConfigurationRenameProcessor.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/ConsoleConfigurationRenameProcessor.java (rev 0)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/ConsoleConfigurationRenameProcessor.java 2011-02-11 12:54:26 UTC (rev 29112)
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.eclipse.launch.core.refactoring;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.NullChange;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+import org.eclipse.ltk.core.refactoring.participants.ParticipantManager;
+import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant;
+import org.eclipse.ltk.core.refactoring.participants.RenameArguments;
+import org.eclipse.ltk.core.refactoring.participants.RenameProcessor;
+import org.eclipse.ltk.core.refactoring.participants.SharableParticipants;
+import org.hibernate.console.KnownConfigurations;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class ConsoleConfigurationRenameProcessor extends RenameProcessor {
+
+ public static final String PROCESSOR_ID = "org.hibernate.eclipse.console.renameProcessor"; //$NON-NLS-1$
+
+ private ILaunchConfiguration config;
+
+ private String newName;
+
+ public ConsoleConfigurationRenameProcessor(ILaunchConfiguration config, String newName){
+ assert KnownConfigurations.getInstance().isKnownConfiguration(config.getName());
+ this.config = config;
+ this.newName = newName;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#createChange(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException
+ {
+ // actual renaming processed in DebugPlugin.
+ return new NullChange();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#getElements()
+ */
+ @Override
+ public Object[] getElements() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#getIdentifier()
+ */
+ @Override
+ public String getIdentifier() {
+ return PROCESSOR_ID;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#getProcessorName()
+ */
+ @Override
+ public String getProcessorName() {
+ return Messages.ConsoleConfigurationRenameProcessor_name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#isApplicable()
+ */
+ @Override
+ public boolean isApplicable() throws CoreException {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#checkInitialConditions(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
+ throws CoreException, OperationCanceledException {
+ return new RefactoringStatus();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#checkFinalConditions(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext)
+ */
+ @Override
+ public RefactoringStatus checkFinalConditions(IProgressMonitor pm,
+ CheckConditionsContext context) throws CoreException,
+ OperationCanceledException {
+ return new RefactoringStatus();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#loadParticipants(org.eclipse.ltk.core.refactoring.RefactoringStatus, org.eclipse.ltk.core.refactoring.participants.SharableParticipants)
+ */
+ @Override
+ public RefactoringParticipant[] loadParticipants(RefactoringStatus status,
+ SharableParticipants sharedParticipants) throws CoreException {
+ List<RefactoringParticipant> participants = new ArrayList<RefactoringParticipant>();
+ participants.addAll(Arrays.asList(ParticipantManager.loadRenameParticipants(status, this, config,
+ new RenameArguments(newName, true), new String[0], sharedParticipants)));
+ return (RefactoringParticipant[]) participants.toArray(new RefactoringParticipant[participants.size()]);
+ }
+
+}
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/HibernateRefactoringUtil.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/HibernateRefactoringUtil.java 2011-02-11 12:30:01 UTC (rev 29111)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/HibernateRefactoringUtil.java 2011-02-11 12:54:26 UTC (rev 29112)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Copyright (c) 2007-2011 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,
@@ -30,12 +30,15 @@
import javax.xml.transform.stream.StreamResult;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.datatools.connectivity.IConnectionProfile;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
@@ -43,6 +46,7 @@
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
import org.eclipse.jdt.launching.JavaRuntime;
@@ -51,9 +55,12 @@
import org.hibernate.eclipse.console.HibernateConsoleMessages;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.hibernate.eclipse.console.model.impl.ExporterFactoryStrings;
+import org.hibernate.eclipse.console.properties.HibernatePropertiesConstants;
import org.hibernate.eclipse.console.utils.LaunchHelper;
import org.hibernate.eclipse.launch.HibernateLaunchConstants;
import org.hibernate.eclipse.launch.IConsoleConfigurationLaunchConstants;
+import org.hibernate.eclipse.nature.HibernateNature;
+import org.osgi.service.prefs.Preferences;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
@@ -96,6 +103,10 @@
public static boolean isCodeGenerationConfigAffected(ILaunchConfiguration config, IPath oldPath) throws CoreException{
return isAttributesAffected(config, oldPath, cgKeys) || isExportersAffected(config, oldPath);
}
+
+ public static boolean isCodeGenerationConfigAffected(ILaunchConfiguration config, String oldCCName) throws CoreException{
+ return isAttributesAffected(config, oldCCName, HibernateLaunchConstants.ATTR_CONSOLE_CONFIGURATION_NAME);
+ }
private static boolean isAttributesAffected(ILaunchConfiguration config, IPath oldPath, String[] paths) throws CoreException{
String attrib = null;
@@ -107,6 +118,22 @@
return false;
}
+ private static boolean isAttributesAffected(ILaunchConfiguration config, String oldValue, String attribute) throws CoreException{
+ String value = config.getAttribute(attribute, (String)null);
+ return value == null ? (oldValue == null) : value.equals(oldValue);
+ }
+
+ private static boolean isProjectAffected(IProject project, String oldCCName) throws CoreException {
+ if (project.isOpen() && project.hasNature(HibernateNature.ID)){
+ IScopeContext scope = new ProjectScope(project);
+
+ Preferences node = scope.getNode(HibernatePropertiesConstants.HIBERNATE_CONSOLE_NODE);
+ String defaultConfiguration = node.get(HibernatePropertiesConstants.DEFAULT_CONFIGURATION, "");
+ return defaultConfiguration.equals(oldCCName);
+ }
+ return false;
+ }
+
@SuppressWarnings("unchecked")
private static boolean isListAttributesAffected(ILaunchConfiguration config, IPath oldPath, String[] listPaths) throws CoreException{
for (int i = 0; i < listPaths.length; i++) {
@@ -448,6 +475,38 @@
return configs;
}
+ public static IProject[] getAffectedProjects(String oldConsoleConfigurationName){
+ List<IProject> affectedProjects = new ArrayList<IProject>();
+ for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
+ try {
+ if (isProjectAffected(project, oldConsoleConfigurationName)){
+ affectedProjects.add(project);
+ }
+ } catch (CoreException e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage( ERROR_MESS, e );
+ }
+ }
+ return affectedProjects.toArray(new IProject[affectedProjects.size()]);
+ }
+
+ public static ILaunchConfiguration[] getAffectedCodeGenerationConfigs(String oldCCName){
+ ILaunchConfiguration[] configs = null;
+ try {
+ configs = LaunchHelper.findCodeGenerationConfigs();
+ List<ILaunchConfiguration> list = new ArrayList<ILaunchConfiguration>();
+ for(int i = 0; i < configs.length && configs[i].exists(); i++) {
+ if (HibernateRefactoringUtil.isCodeGenerationConfigAffected(configs[i], oldCCName)) list.add(configs[i]);
+ }
+ configs = list.toArray(new ILaunchConfiguration[list.size()]);
+ }
+ catch(CoreException e) {
+ configs = new ILaunchConfiguration[0];
+ HibernateConsolePlugin.getDefault().logErrorMessage( ERROR_MESS, e );
+ }
+
+ return configs;
+ }
+
public static ILaunchConfiguration[] getAffectedLaunchConfigurations(IProject project){
ILaunchConfiguration[] configs = null;
try {
Added: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/Messages.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/Messages.java (rev 0)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/Messages.java 2011-02-11 12:54:26 UTC (rev 29112)
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.eclipse.launch.core.refactoring;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.hibernate.eclipse.launch.core.refactoring.messages"; //$NON-NLS-1$
+ public static String CodeGenerationConsoleNameChange_error_empty_name;
+ public static String CodeGenerationConsoleNameChange_error_null_confi;
+ public static String CodeGenerationConsoleNameChange_update;
+ public static String ConsoleConfigurationRenameParticipant_change_name;
+ public static String ConsoleConfigurationRenameParticipant_name;
+ public static String ConsoleConfigurationRenameParticipant_update_code_generations;
+ public static String ConsoleConfigurationRenameParticipant_update_project_config;
+ public static String ConsoleConfigurationRenameProcessor_name;
+ public static String ProjectDefaultConfigurationChange_error_title;
+ public static String ProjectDefaultConfigurationChange_name;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
Added: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/ProjectDefaultConfigurationChange.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/ProjectDefaultConfigurationChange.java (rev 0)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/ProjectDefaultConfigurationChange.java 2011-02-11 12:54:26 UTC (rev 29112)
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.eclipse.launch.core.refactoring;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.NullChange;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.swt.widgets.Shell;
+import org.hibernate.eclipse.console.HibernateConsolePlugin;
+import org.hibernate.eclipse.console.properties.HibernatePropertiesConstants;
+import org.osgi.service.prefs.BackingStoreException;
+import org.osgi.service.prefs.Preferences;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class ProjectDefaultConfigurationChange extends Change {
+
+ private IProject project;
+
+ private String newConsoleName;
+
+ public ProjectDefaultConfigurationChange(IProject project, String newCCName){
+ this.project = project;
+ this.newConsoleName = newCCName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.Change#getName()
+ */
+ @Override
+ public String getName() {
+ return Messages.ProjectDefaultConfigurationChange_name + project.getName();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.Change#initializeValidationData(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void initializeValidationData(IProgressMonitor pm) {}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.Change#isValid(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException,
+ OperationCanceledException {
+ return new RefactoringStatus();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.Change#perform(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public Change perform(IProgressMonitor pm) throws CoreException {
+ try {
+ IScopeContext scope = new ProjectScope(project);
+
+ Preferences node = scope.getNode(HibernatePropertiesConstants.HIBERNATE_CONSOLE_NODE);
+ String oldName = node.get(HibernatePropertiesConstants.DEFAULT_CONFIGURATION, null);
+
+ node.putBoolean(HibernatePropertiesConstants.HIBERNATE3_ENABLED, true );
+ node.put(HibernatePropertiesConstants.DEFAULT_CONFIGURATION, newConsoleName );
+ node.flush();
+ return new ProjectDefaultConfigurationChange(project, oldName);
+ } catch (BackingStoreException e) {
+ HibernateConsolePlugin.openError(new Shell(), Messages.ProjectDefaultConfigurationChange_error_title , e.getLocalizedMessage(), e, HibernateConsolePlugin.PERFORM_SYNC_EXEC);
+ return new NullChange();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.Change#getModifiedElement()
+ */
+ @Override
+ public Object getModifiedElement() {
+ return project;
+ }
+
+}
Added: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/messages.properties
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/messages.properties (rev 0)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/messages.properties 2011-02-11 12:54:26 UTC (rev 29112)
@@ -0,0 +1,10 @@
+CodeGenerationConsoleNameChange_error_empty_name=Console Configuration name can't be empty
+CodeGenerationConsoleNameChange_error_null_confi=Error while try to rename null Console Configuration
+CodeGenerationConsoleNameChange_update=Update {0} Code Generation Configuration
+ConsoleConfigurationRenameParticipant_change_name=Console Configuration Rename Change
+ConsoleConfigurationRenameParticipant_name=Console Configuration Rename Participant
+ConsoleConfigurationRenameParticipant_update_code_generations=Update Code Generation Configurations
+ConsoleConfigurationRenameParticipant_update_project_config=Update Default Project Console Configurations
+ConsoleConfigurationRenameProcessor_name=Console Configuration Rename Processor
+ProjectDefaultConfigurationChange_error_title=Error
+ProjectDefaultConfigurationChange_name=Change associated Console Configuration in project
13 years, 11 months
JBoss Tools SVN: r29111 - trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2011-02-11 07:30:01 -0500 (Fri, 11 Feb 2011)
New Revision: 29111
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/MoveResourceParticipant.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/RenameResourceParticipant.java
Log:
Misprint fix.
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/MoveResourceParticipant.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/MoveResourceParticipant.java 2011-02-11 12:27:58 UTC (rev 29110)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/MoveResourceParticipant.java 2011-02-11 12:30:01 UTC (rev 29111)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2011 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.hibernate.eclipse.launch.core.refactoring;
import java.util.ArrayList;
@@ -14,6 +24,10 @@
import org.eclipse.ltk.core.refactoring.participants.MoveParticipant;
import org.hibernate.eclipse.console.HibernateConsoleMessages;
+/**
+ * @author Dmitry Geraskov
+ *
+ */
public class MoveResourceParticipant extends MoveParticipant {
private IResource fResource;
@@ -36,7 +50,7 @@
configs = HibernateRefactoringUtil.getAffectedCodeGenerationConfigs(fResource.getFullPath());
for (int i= 0; i < configs.length; i++) {
- change = new CodeGenerationReseourceNameChange(configs[i], fResource.getFullPath(), ((IResource)getArguments().getDestination()).getFullPath().append(fResource.getName()));
+ change = new CodeGenerationResourceNameChange(configs[i], fResource.getFullPath(), ((IResource)getArguments().getDestination()).getFullPath().append(fResource.getName()));
changes.add(change);
}
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/RenameResourceParticipant.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/RenameResourceParticipant.java 2011-02-11 12:27:58 UTC (rev 29110)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/RenameResourceParticipant.java 2011-02-11 12:30:01 UTC (rev 29111)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Copyright (c) 2007-2011 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,
@@ -63,7 +63,7 @@
configs = HibernateRefactoringUtil.getAffectedCodeGenerationConfigs(fResource.getFullPath());
for (int i= 0; i < configs.length; i++) {
- change = new CodeGenerationReseourceNameChange(configs[i], fResource.getFullPath(),
+ change = new CodeGenerationResourceNameChange(configs[i], fResource.getFullPath(),
fResource.getParent().getFullPath().append(getArguments().getNewName()));
changes.add(change);
}
13 years, 11 months
JBoss Tools SVN: r29110 - trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2011-02-11 07:27:58 -0500 (Fri, 11 Feb 2011)
New Revision: 29110
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/CodeGenerationResourceNameChange.java
Log:
Misprint fix.
Copied: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/CodeGenerationResourceNameChange.java (from rev 29061, trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/CodeGenerationReseourceNameChange.java)
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/CodeGenerationResourceNameChange.java (rev 0)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/CodeGenerationResourceNameChange.java 2011-02-11 12:27:58 UTC (rev 29110)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2009 - 2011 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.hibernate.eclipse.launch.core.refactoring;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.osgi.util.NLS;
+import org.hibernate.eclipse.console.HibernateConsoleMessages;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class CodeGenerationResourceNameChange extends Change {
+
+ private ILaunchConfiguration fLaunchConfiguration;
+ private IPath fOldPath;
+ private IPath fNewPath;
+
+ CodeGenerationResourceNameChange(ILaunchConfiguration launchConfiguration, IPath oldPath, IPath newPath){
+ fLaunchConfiguration = launchConfiguration;
+ fOldPath = oldPath;
+ fNewPath = newPath;
+ }
+
+ @Override
+ public Object getModifiedElement() {
+ return fLaunchConfiguration;
+ }
+
+ @Override
+ public String getName() {
+ return NLS.bind(HibernateConsoleMessages.LaunchConfigurationResourceNameChange_update_resource_path_in_launch_cfg, fLaunchConfiguration.getName());
+ }
+
+ @Override
+ public void initializeValidationData(IProgressMonitor pm) { }
+
+ @Override
+ public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException,
+ OperationCanceledException {
+ return new RefactoringStatus();
+ }
+
+ @Override
+ public Change perform(IProgressMonitor pm) throws CoreException {
+ fLaunchConfiguration = HibernateRefactoringUtil.updateCodeGenerationConfig(fLaunchConfiguration, fOldPath, fNewPath);
+ return new CodeGenerationResourceNameChange(fLaunchConfiguration, fNewPath, fOldPath);
+ }
+
+}
13 years, 11 months