|
From: <caw...@us...> - 2007-03-16 14:02:31
|
Revision: 2194
http://svn.sourceforge.net/rubyeclipse/?rev=2194&view=rev
Author: cawilliams
Date: 2007-03-16 07:02:27 -0700 (Fri, 16 Mar 2007)
Log Message:
-----------
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/RefactoringCoreMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/RefactoringCoreMessages.properties
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/RubyScriptChange.java
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/RefactoringCoreMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/RefactoringCoreMessages.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/RefactoringCoreMessages.java 2007-03-16 14:02:27 UTC (rev 2194)
@@ -0,0 +1,15 @@
+package org.rubypeople.rdt.internal.corext.refactoring.changes;
+
+import org.eclipse.osgi.util.NLS;
+
+public class RefactoringCoreMessages extends NLS {
+
+ private static final String BUNDLE_NAME = RefactoringCoreMessages.class.getName();
+
+ public static String UndoRubyScriptChange_no_resource;
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, RefactoringCoreMessages.class);
+ }
+
+}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/RefactoringCoreMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/RefactoringCoreMessages.properties (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/RefactoringCoreMessages.properties 2007-03-16 14:02:27 UTC (rev 2194)
@@ -0,0 +1 @@
+UndoRubyScriptChange_no_resource= Ruby Script ''{0}'' does not have an underlying file.
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/RubyScriptChange.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/RubyScriptChange.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/RubyScriptChange.java 2007-03-16 14:02:27 UTC (rev 2194)
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.corext.refactoring.changes;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.ContentStamp;
+import org.eclipse.ltk.core.refactoring.TextFileChange;
+import org.eclipse.text.edits.UndoEdit;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.internal.corext.util.RubyModelUtil;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+
+public class RubyScriptChange extends TextFileChange {
+
+ private IRubyScript fCUnit;
+
+ /**
+ * Creates a new <code>RubyScriptChange</code>.
+ *
+ * @param name the change's name mainly used to render the change in the UI
+ * @param cunit the compilation unit this text change works on
+ */
+ public RubyScriptChange(String name, IRubyScript cunit) {
+ super(name, getFile(cunit));
+ Assert.isNotNull(cunit);
+ fCUnit= cunit;
+ setTextType("ruby"); //$NON-NLS-1$
+ }
+
+ private static IFile getFile(IRubyScript cunit) {
+ return (IFile) cunit.getResource();
+ }
+
+ /* non java-doc
+ * Method declared in IChange.
+ */
+ public Object getModifiedElement(){
+ return fCUnit;
+ }
+
+ /**
+ * Returns the compilation unit this change works on.
+ *
+ * @return the compilation unit this change works on
+ */
+ public IRubyScript getRubyScript() {
+ return fCUnit;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected IDocument acquireDocument(IProgressMonitor pm) throws CoreException {
+ pm.beginTask("", 2); //$NON-NLS-1$
+ fCUnit.becomeWorkingCopy(null, new SubProgressMonitor(pm, 1));
+ return super.acquireDocument(new SubProgressMonitor(pm, 1));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void releaseDocument(IDocument document, IProgressMonitor pm) throws CoreException {
+ super.releaseDocument(document, pm);
+ try {
+ fCUnit.discardWorkingCopy();
+ } finally {
+ if (!isDocumentAcquired()) {
+ if (fCUnit.isWorkingCopy())
+ RubyModelUtil.reconcile(fCUnit);
+ else
+ fCUnit.makeConsistent(pm);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Change createUndoChange(UndoEdit edit, ContentStamp stampToRestore) {
+ try {
+ return new UndoRubyScriptChange(getName(), fCUnit, edit, stampToRestore, getSaveMode());
+ } catch (CoreException e) {
+ RubyPlugin.log(e);
+ return null;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object getAdapter(Class adapter) {
+ if (IRubyScript.class.equals(adapter))
+ return fCUnit;
+ return super.getAdapter(adapter);
+ }
+}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|