Author: DartPeng
Date: 2010-11-01 06:49:11 -0400 (Mon, 01 Nov 2010)
New Revision: 26153
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksXMLEditor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/AbstractSmooksFormEditor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/FigureHighlightEditPolicy.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/FigureSelectEditPolicy.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/TreeNodeGraphicalNodeEditPolicy.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/TreeNodeSelectEditPolicy.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/figures/TreeContainerFigure.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/figures/TreeNodeFigure.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/InputDataContainerEditPart.java
Log:
JBIDE-7328
When user rename the file , if the new extension name is not "XML" , open an
dailog to ask user is they want to close the current editor and reopen it
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksXMLEditor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksXMLEditor.java 2010-10-30
00:09:30 UTC (rev 26152)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksXMLEditor.java 2010-11-01
10:49:11 UTC (rev 26153)
@@ -10,22 +10,88 @@
******************************************************************************/
package org.jboss.tools.smooks.configuration.editors;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.jboss.tools.smooks.editor.AbstractSmooksFormEditor;
/**
- * @author Dart Peng (dpeng(a)redhat.com)
- * Date Apr 1, 2009
+ * @author Dart Peng (dpeng(a)redhat.com) Date Apr 1, 2009
*/
public class SmooksXMLEditor extends StructuredTextEditor {
- /* (non-Javadoc)
- * @see
org.eclipse.wst.sse.ui.StructuredTextEditor#doSetInput(org.eclipse.ui.IEditorInput)
+ private IEditorPart parentEditorPart;
+
+ public IEditorPart getParentEditorPart() {
+ return parentEditorPart;
+ }
+
+ public void setParentEditorPart(IEditorPart parentEditorPart) {
+ this.parentEditorPart = parentEditorPart;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.wst.sse.ui.StructuredTextEditor#doSetInput(org.eclipse.ui
+ * .IEditorInput)
*/
@Override
public void doSetInput(IEditorInput input) throws CoreException {
- // TODO Auto-generated method stub
+
+ System.out.println(((IFileEditorInput) input).getFile()
+ .getFileExtension());
+
+ final IFile newFile = ((IFileEditorInput) input).getFile();
+ if ("xml".equals(newFile.getFileExtension())) {
+ // try {
+ // ((SmooksXMLEditor) textEditor).doSetInput(new
+ // FileEditorInput(newFile));
+ // } catch (CoreException e) {
+ // e.printStackTrace();
+ // }
+
+ } else {
+ boolean yes = MessageDialog
+ .openQuestion(
+ getSite().getShell(),
+ "Incorrect Extension Name",
+ "The extension name of this smooks configuration file isn't correct , it
will occur some exception , do you want to close this editor and re-open the
file?");
+ if (yes) {
+ if (parentEditorPart != null) {
+ ((AbstractSmooksFormEditor)
+ parentEditorPart).close(true);
+ }
+ Display.getDefault().asyncExec(new Runnable() {
+
+ public void run() {
+ try {
+ IWorkbenchPage page = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage();
+ FileEditorInput editorInput = new FileEditorInput(newFile);
+ page.openEditor(editorInput, "org.eclipse.ui.DefaultTextEditor", true);
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+
+ });
+ return;
+ } else {
+// setInput(new FileEditorInput(newFile));
+ }
+ }
+
super.doSetInput(input);
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/AbstractSmooksFormEditor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/AbstractSmooksFormEditor.java 2010-10-30
00:09:30 UTC (rev 26152)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/AbstractSmooksFormEditor.java 2010-11-01
10:49:11 UTC (rev 26153)
@@ -429,6 +429,7 @@
try {
int index = this.addPage(textEditor, getEditorInput());
setPageText(index, Messages.AbstractSmooksFormEditor_Source_Page_Title);
+ ((SmooksXMLEditor)textEditor).setParentEditorPart(this);
} catch (PartInitException e) {
e.printStackTrace();
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/FigureHighlightEditPolicy.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/FigureHighlightEditPolicy.java 2010-10-30
00:09:30 UTC (rev 26152)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/FigureHighlightEditPolicy.java 2010-11-01
10:49:11 UTC (rev 26153)
@@ -76,7 +76,7 @@
* @see org.eclipse.gef.EditPolicy#showTargetFeedback(org.eclipse.gef.Request)
*/
public void showTargetFeedback(Request request) {
- if (request.getType().equals(RequestConstants.REQ_CREATE) ||
request.getType().equals(RequestConstants.REQ_ADD))
+ if (request.getType().equals(RequestConstants.REQ_CONNECTION_END) ||
request.getType().equals(RequestConstants.REQ_ADD))
showHighlight();
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/FigureSelectEditPolicy.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/FigureSelectEditPolicy.java 2010-10-30
00:09:30 UTC (rev 26152)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/FigureSelectEditPolicy.java 2010-11-01
10:49:11 UTC (rev 26153)
@@ -50,6 +50,10 @@
* @see org.eclipse.gef.editpolicies.NonResizableEditPolicy#hideFocus()
*/
protected void hideFocus() {
+ if(true){
+ super.hideFocus();
+ return;
+ }
if (getSelectableFigure() != null) {
getSelectableFigure().setFocus(false);
}
@@ -59,6 +63,10 @@
* @see org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy#hideSelection()
*/
protected void hideSelection() {
+ if(true){
+ super.hideSelection();
+ return;
+ }
if (getSelectableFigure() != null) {
getSelectableFigure().setSelected(false);
getSelectableFigure().setFocus(false);
@@ -69,6 +77,10 @@
* @see org.eclipse.gef.editpolicies.NonResizableEditPolicy#showFocus()
*/
protected void showFocus() {
+ if(true){
+ super.showFocus();
+ return;
+ }
if (getSelectableFigure() != null) {
getSelectableFigure().setFocus(true);
}
@@ -78,6 +90,10 @@
* @see org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy#showSelection()
*/
protected void showPrimarySelection() {
+ if(true){
+ super.showPrimarySelection();
+ return;
+ }
if (getSelectableFigure() != null) {
getSelectableFigure().setSelected(true);
getSelectableFigure().setFocus(true);
@@ -88,6 +104,10 @@
* @see org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy#showSelection()
*/
protected void showSelection() {
+ if(true){
+ super.showSelection();
+ return;
+ }
if (getSelectableFigure() != null) {
getSelectableFigure().setSelected(true);
getSelectableFigure().setFocus(false);
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/TreeNodeGraphicalNodeEditPolicy.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/TreeNodeGraphicalNodeEditPolicy.java 2010-10-30
00:09:30 UTC (rev 26152)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/TreeNodeGraphicalNodeEditPolicy.java 2010-11-01
10:49:11 UTC (rev 26153)
@@ -127,10 +127,10 @@
*/
public void eraseTargetFeedback(Request request) {
super.eraseTargetFeedback(request);
- if (revertColor != null) {
- unsetContainerBackgroud(revertColor);
- revertColor = null;
- }
+// if (revertColor != null) {
+// unsetContainerBackgroud(revertColor);
+// revertColor = null;
+// }
}
private void unsetContainerBackgroud(Color c) {
@@ -183,10 +183,10 @@
*/
public void showTargetFeedback(Request request) {
super.showTargetFeedback(request);
- if (REQ_CONNECTION_START.equals(request.getType()) ||
REQ_CONNECTION_END.equals(request.getType())
- || REQ_RECONNECT_SOURCE.equals(request.getType()) ||
REQ_RECONNECT_TARGET.equals(request.getType())) {
- showHighlight();
- }
+// if (REQ_CONNECTION_START.equals(request.getType()) ||
REQ_CONNECTION_END.equals(request.getType())
+// || REQ_RECONNECT_SOURCE.equals(request.getType()) ||
REQ_RECONNECT_TARGET.equals(request.getType())) {
+// showHighlight();
+// }
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/TreeNodeSelectEditPolicy.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/TreeNodeSelectEditPolicy.java 2010-10-30
00:09:30 UTC (rev 26152)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editpolicy/TreeNodeSelectEditPolicy.java 2010-11-01
10:49:11 UTC (rev 26153)
@@ -50,6 +50,10 @@
* @see org.eclipse.gef.editpolicies.NonResizableEditPolicy#hideFocus()
*/
protected void hideFocus() {
+ if(true){
+ super.hideFocus();
+ return;
+ }
if (getTreeNodeFigure() != null) {
getTreeNodeFigure().setFocus(false);
}
@@ -59,6 +63,10 @@
* @see org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy#hideSelection()
*/
protected void hideSelection() {
+ if(true){
+ super.hideSelection();
+ return;
+ }
if (getTreeNodeFigure() != null) {
getTreeNodeFigure().setSelected(false);
getTreeNodeFigure().setFocus(false);
@@ -70,6 +78,10 @@
* @see org.eclipse.gef.editpolicies.NonResizableEditPolicy#showFocus()
*/
protected void showFocus() {
+ if(true){
+ super.showFocus();
+ return;
+ }
if (getTreeNodeFigure() != null) {
getTreeNodeFigure().setFocus(true);
}
@@ -79,6 +91,10 @@
* @see org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy#showSelection()
*/
protected void showPrimarySelection() {
+ if(true){
+ super.showPrimarySelection();
+ return;
+ }
if (getTreeNodeFigure() != null) {
getTreeNodeFigure().setSelected(true);
getTreeNodeFigure().setFocus(true);
@@ -89,6 +105,10 @@
* @see org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy#showSelection()
*/
protected void showSelection() {
+ if(true){
+ super.showSelection();
+ return;
+ }
if (getTreeNodeFigure() != null) {
getTreeNodeFigure().setSelected(true);
getTreeNodeFigure().setFocus(false);
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/figures/TreeContainerFigure.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/figures/TreeContainerFigure.java 2010-10-30
00:09:30 UTC (rev 26152)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/figures/TreeContainerFigure.java 2010-11-01
10:49:11 UTC (rev 26153)
@@ -16,7 +16,9 @@
import org.eclipse.draw2d.ToolbarLayout;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
import org.jboss.tools.smooks.configuration.editors.GraphicsConstants;
@@ -27,7 +29,8 @@
* @author DartPeng
*
*/
-public class TreeContainerFigure extends Figure implements ISelectableFigure,
IShowHighlighFigure {
+public class TreeContainerFigure extends Figure implements ISelectableFigure,
+ IShowHighlighFigure {
private IFigure headerFigure;
@@ -41,9 +44,10 @@
private Color sourceHeaderColor = ColorConstants.orange;
- protected Color targetHeaderSelectedColor = FigureUtilities.lighter(targetHeaderColor);
+ protected Color targetHeaderSelectedColor = GraphicsConstants.BORDER_CORLOR;//
FigureUtilities.lighter(targetHeaderColor);
- protected Color sourceHeaderSelectedColor = FigureUtilities.lighter(sourceHeaderColor);
+ protected Color sourceHeaderSelectedColor = FigureUtilities
+ .lighter(sourceHeaderColor);
private boolean focus;
@@ -59,6 +63,8 @@
private boolean isSource = true;
+ private Font oldLabelFont;
+
public TreeContainerFigure(TreeContainerModel model) {
super();
this.model = model;
@@ -194,8 +200,9 @@
return;
}
}
- Image img = SmooksConfigurationActivator.getDefault().getImageRegistry().get(
- GraphicsConstants.IMAGE_DRAG_LINK);
+ Image img = SmooksConfigurationActivator.getDefault()
+ .getImageRegistry()
+ .get(GraphicsConstants.IMAGE_DRAG_LINK);
if (img != null) {
graphics.drawImage(img, getLocation());
}
@@ -285,9 +292,11 @@
try {
graphics.pushState();
Color currentColor = sourceHeaderColor;
+// label.getFont().getFontData()[0].setStyle(SWT.NORMAL);
if (!isSource)
currentColor = targetHeaderColor;
- if (isSelected() || isFocus()) {
+ if (isSelected() || isFocus() || showHightlight) {
+// label.getFont().getFontData()[0].setStyle(SWT.BOLD);
currentColor = sourceHeaderSelectedColor;
if (!isSource)
currentColor = targetHeaderSelectedColor;
@@ -299,8 +308,8 @@
graphics.setBackgroundColor(ColorConstants.white);
graphics.fillGradient(headerFigure.getBounds().expand(30, 0), true);
graphics.setForegroundColor(currentColor);
- graphics.drawLine(getBounds().getBottomLeft().translate(0, -1),
getBounds().getBottomRight().translate(0,
- -1));
+ graphics.drawLine(getBounds().getBottomLeft().translate(0, -1),
+ getBounds().getBottomRight().translate(0, -1));
graphics.popState();
} catch (Exception e) {
e.printStackTrace();
@@ -345,16 +354,25 @@
@Override
protected void paintBorder(Graphics graphics) {
+// if(true){
+// super.paintBorder(graphics);
+// return;
+// }
try {
+ graphics.setLineStyle(SWT.LINE_SOLID);
graphics.setForegroundColor(ColorConstants.buttonDarkest);
if (isSelected() || isFocus()) {
- graphics.setForegroundColor(GraphicsConstants.BORDER_CORLOR);
+ graphics.setForegroundColor(ColorConstants.blue);
+ graphics.setLineStyle(SWT.LINE_DOT);
}
if (showHightlight && highlightColor != null) {
- graphics.setForegroundColor(FigureUtilities.darker(highlightColor));
+ graphics.setForegroundColor(FigureUtilities
+ .darker(highlightColor));
+ graphics.setLineStyle(SWT.LINE_DOT);
}
- Rectangle drawnRectangle = new Rectangle(getBounds().x, getBounds().y,
getBounds().width - 1,
+ Rectangle drawnRectangle = new Rectangle(getBounds().x,
+ getBounds().y, getBounds().width - 1,
getBounds().height - 1);
graphics.drawRoundRectangle(drawnRectangle, 5, 5);
} catch (Exception e) {
@@ -444,7 +462,7 @@
*/
public void setContentFigure(IFigure contentFigure) {
this.contentFigure = contentFigure;
-// this.repaint(0,0,0,0);
+ // this.repaint(0,0,0,0);
repaint();
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/figures/TreeNodeFigure.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/figures/TreeNodeFigure.java 2010-10-30
00:09:30 UTC (rev 26152)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/figures/TreeNodeFigure.java 2010-11-01
10:49:11 UTC (rev 26153)
@@ -349,9 +349,12 @@
if (oldLabelColor == null){
oldLabelColor = label.getForegroundColor();
}
+ label.setOpaque(false);
label.setForegroundColor(oldLabelColor);
if (isFocus() || isSelected() || showHighlight) {
- label.setForegroundColor(GraphicsConstants.FONT_COLOR);
+ label.setOpaque(true);
+ label.setBackgroundColor(GraphicsConstants.FONT_COLOR);
+ label.setForegroundColor(ColorConstants.white);
}
super.paint(graphics);
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/InputDataContainerEditPart.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/InputDataContainerEditPart.java 2010-10-30
00:09:30 UTC (rev 26152)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/InputDataContainerEditPart.java 2010-11-01
10:49:11 UTC (rev 26153)
@@ -20,6 +20,7 @@
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.jboss.tools.smooks.SmooksModelUtils;
import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
@@ -111,9 +112,11 @@
protected void paintBorder(Graphics graphics) {
// super.paintBorder(graphics);
if (isSelected() || isFocus()) {
- graphics.setForegroundColor(ColorConstants.orange);
+ graphics.setForegroundColor(ColorConstants.blue);
+ graphics.setLineStyle(SWT.LINE_DOT);
} else {
graphics.setForegroundColor(FigureUtilities.darker(ColorConstants.orange));
+ graphics.setLineStyle(SWT.LINE_SOLID);
}
Point p2 = new Point();