Permalink
Browse files

IDE-872

  • Loading branch information...
cinnndy9 authored and gamerson committed Mar 25, 2013
1 parent 7e06a5d commit 3a640d66384510fb41b91952e15b9d5463b173aa
@@ -25,8 +25,9 @@
import java.util.EventObject;
-import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.gef.ContextMenuProvider;
import org.eclipse.gef.DefaultEditDomain;
import org.eclipse.gef.GraphicalViewer;
@@ -48,6 +49,7 @@
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.ide.FileStoreEditorInput;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import org.eclipse.wst.sse.core.StructuredModelManager;
@@ -57,6 +59,7 @@
/**
* @author Greg Amerson
+ * @author Cindy Li
*/
@SuppressWarnings( "restriction" )
public class LayoutTplEditor extends GraphicalEditorWithFlyoutPalette
@@ -142,7 +145,7 @@ public void refreshSourceModel()
{
IDOMModel domModel = getSourceModel();
domModel.aboutToChangeModel();
- String name = getSourceFile().getFullPath().removeFileExtension().lastSegment();
+ String name = getSourceFileName();
String templateSource = diagram.getTemplateSource( name );
domModel.getStructuredDocument().setText( this, templateSource );
domModel.changedModel();
@@ -180,7 +183,7 @@ public void updateActions()
private void refreshViewer( final GraphicalViewer viewer )
{
viewer.getControl().addPaintListener
- (
+ (
new PaintListener()
{
public void paintControl( PaintEvent e )
@@ -246,7 +249,7 @@ protected void configurePaletteViewer( PaletteViewer viewer )
/**
* Create a transfer drop target listener. When using a CombinedTemplateCreationEntry tool in the palette, this will
* enable model element creation by dragging from the palette.
- *
+ *
* @see #createPaletteViewerProvider()
*/
protected TransferDropTargetListener createTransferDropTargetListener()
@@ -278,9 +281,27 @@ protected PaletteRoot getPaletteRoot()
return PALETTE_MODEL;
}
- protected IFile getSourceFile()
+ protected String getSourceFileName()
{
- return ( (IFileEditorInput) getEditorInput() ).getFile();
+ IEditorInput editorInput = getEditorInput();
+
+ IPath path = null;
+
+ if( editorInput instanceof IFileEditorInput )
+ {
+ path = ( (IFileEditorInput) editorInput ).getFile().getFullPath();
+ }
+ else if( editorInput instanceof FileStoreEditorInput )
+ {
+ path = new Path( ( (FileStoreEditorInput) editorInput ).getURI().getPath() );
+ }
+
+ if( path == null )
+ {
+ return editorInput.getName();
+ }
+
+ return path.removeFileExtension().lastSegment();
}
protected IDOMModel getSourceModel()
@@ -333,8 +354,7 @@ protected void setInput( IEditorInput input )
refreshVisualModel();
- IFile file = ( (IFileEditorInput) input ).getFile();
- setPartName( file.getName() );
+ setPartName( input.getName() );
// try {
// IFile file = ((IFileEditorInput) input).getFile();
@@ -19,7 +19,6 @@
import com.liferay.ide.layouttpl.ui.ILayoutTplUIPreferenceNames;
import com.liferay.ide.layouttpl.ui.LayoutTplUI;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.preference.IPreferenceStore;
@@ -31,7 +30,6 @@
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IPropertyListener;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchPart;
@@ -386,8 +384,7 @@ protected void setInput( IEditorInput input )
{
super.setInput( input );
- IFile file = ( (IFileEditorInput) input ).getFile();
- setPartName( file.getName() );
+ setPartName( input.getName() );
}
void gotoMarker( IMarker marker )

0 comments on commit 3a640d6

Please sign in to comment.