Merge commit 'origin/master'
authorMaxim Medvedev <maxim.medvedev@jetbrains.com>
Tue, 14 Sep 2010 08:03:40 +0000 (12:03 +0400)
committerMaxim Medvedev <maxim.medvedev@jetbrains.com>
Tue, 14 Sep 2010 08:03:40 +0000 (12:03 +0400)
Conflicts:
plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/move/MoveGroovyClassHandler.java
plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/move/MoveGroovyClassUtil.java

35 files changed:
java/debugger/impl/src/com/intellij/debugger/actions/JumpToObjectAction.java
java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessEvents.java
java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java
java/debugger/impl/src/com/intellij/debugger/ui/FramesPanel.java
java/debugger/impl/src/com/intellij/debugger/ui/PositionHighlighter.java
java/debugger/impl/src/com/intellij/debugger/ui/impl/DebuggerTreePanel.java
java/debugger/impl/src/com/intellij/debugger/ui/impl/InspectPanel.java
java/debugger/impl/src/com/intellij/debugger/ui/impl/UpdatableDebuggerView.java
java/debugger/impl/src/com/intellij/debugger/ui/impl/VariablesPanel.java
java/debugger/impl/src/com/intellij/debugger/ui/impl/WatchPanel.java
java/java-impl/src/com/intellij/ide/JavaLanguageCodeStyleSettingsProvider.java
platform/lang-api/src/com/intellij/psi/codeStyle/LanguageCodeStyleSettingsProvider.java
platform/lang-api/src/com/intellij/psi/util/PsiTreeUtil.java
platform/lang-impl/src/com/intellij/application/options/CodeStyleAbstractPanel.java
platform/lang-impl/src/com/intellij/application/options/GeneralCodeStylePanel.java
platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleBlankLinesPanel.java
platform/lang-impl/src/com/intellij/application/options/codeStyle/MultilanguageCodeStyleAbstractPanel.java
platform/lang-impl/src/com/intellij/application/options/codeStyle/OptionTreeWithPreviewPanel.java
platform/lang-impl/src/com/intellij/application/options/codeStyle/WrappingAndBracesPanel.java
platform/lang-impl/src/com/intellij/ide/actions/CreateDirectoryOrPackageAction.java
platform/lang-impl/src/com/intellij/ide/actions/CreateDirectoryOrPackageHandler.java [new file with mode: 0644]
platform/lang-impl/src/com/intellij/ide/util/DirectoryChooserUtil.java
platform/platform-api/src/com/intellij/patterns/StringPattern.java
platform/platform-impl/src/com/intellij/codeInsight/hint/CustomHrView.java [new file with mode: 0644]
platform/platform-impl/src/com/intellij/codeInsight/hint/LineTooltipRenderer.java
platform/platform-impl/src/com/intellij/ide/IdeTooltipManager.java
platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/CachingSoftWrapDataMapper.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java
platform/platform-impl/src/com/intellij/ui/HintHint.java
platform/platform-resources/src/META-INF/PlatformPlugin.xml
platform/platform-resources/src/idea/PlatformApplicationInfo.xml
platform/util/src/com/intellij/util/ui/UIUtil.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyFileImpl.java
plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/move/MoveGroovyScriptHandler.java

index b58eaa7ff08a4268395e1f5506333e3003c625a7..269d3eafa5bb792db013aab0b0a11a798b470cc2 100644 (file)
@@ -98,18 +98,21 @@ public class JumpToObjectAction extends DebuggerAction{
         type = ((ArrayType)type).componentType();
       }
       if(type instanceof ClassType) {
-        final List<Location> locations = ((ClassType)type).allLineLocations();
+        final ClassType clsType = (ClassType)type;
+        final List<Location> locations = clsType.allLineLocations();
         if(locations.size() > 0) {
           final Location location = locations.get(0);
           return ApplicationManager.getApplication().runReadAction(new Computable<SourcePosition>() {
             public SourcePosition compute() {
               SourcePosition position = debugProcess.getPositionManager().getSourcePosition(location);
-              // adjust position
-              final PsiClass classAt = JVMNameUtil.getClassAt(position);
-              if (classAt != null) {
-                final SourcePosition classPosition = SourcePosition.createFromElement(classAt);
-                if (classPosition != null) {
-                  position = classPosition;
+              // adjust position for non-anonymous classes
+              if (clsType.name().indexOf("$") < 0) {
+                final PsiClass classAt = JVMNameUtil.getClassAt(position);
+                if (classAt != null) {
+                  final SourcePosition classPosition = SourcePosition.createFromElement(classAt);
+                  if (classPosition != null) {
+                    position = classPosition;
+                  }
                 }
               }
               return position;
index 55c31d7c4dbefc18f37103c44841d1099f90954a..5d12ced336519eb541babd03abea6a9a117f9c83 100644 (file)
@@ -154,6 +154,7 @@ public class DebugProcessEvents extends DebugProcessImpl {
                 final ThreadReference thread = ((ThreadStartEvent)event).thread();
                 getManagerThread().schedule(new DebuggerCommandImpl() {
                   protected void action() throws Exception {
+                    getVirtualMachineProxy().threadStarted(thread);
                     myDebugProcessDispatcher.getMulticaster().threadStarted(DebugProcessEvents.this, thread);
                   }
                 });
@@ -163,6 +164,7 @@ public class DebugProcessEvents extends DebugProcessImpl {
                 final ThreadReference thread = ((ThreadDeathEvent)event).thread();
                 getManagerThread().schedule(new DebuggerCommandImpl() {
                   protected void action() throws Exception {
+                    getVirtualMachineProxy().threadStopped(thread);
                     myDebugProcessDispatcher.getMulticaster().threadStopped(DebugProcessEvents.this, thread);
                   }
                 });
index e993c5ad6479fd9bb0a424a0e9315af242cdc0de..b72c1f0809b17fec1432f9187e902eb2d88e7214 100644 (file)
@@ -26,7 +26,6 @@ import com.intellij.debugger.engine.events.SuspendContextCommandImpl;
 import com.intellij.debugger.engine.requests.RequestManagerImpl;
 import com.intellij.debugger.jdi.StackFrameProxyImpl;
 import com.intellij.debugger.jdi.ThreadReferenceProxyImpl;
-import com.intellij.debugger.jdi.VirtualMachineProxyImpl;
 import com.intellij.debugger.ui.breakpoints.Breakpoint;
 import com.intellij.debugger.ui.breakpoints.BreakpointWithHighlighter;
 import com.intellij.debugger.ui.breakpoints.LineBreakpoint;
@@ -41,18 +40,21 @@ import com.intellij.execution.process.ProcessOutputTypes;
 import com.intellij.execution.runners.ProgramRunner;
 import com.intellij.idea.ActionsBundle;
 import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ModalityState;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.Messages;
 import com.intellij.openapi.util.Computable;
+import com.intellij.openapi.util.Disposer;
 import com.intellij.openapi.util.Pair;
 import com.intellij.psi.PsiCompiledElement;
 import com.intellij.psi.PsiDocumentManager;
 import com.intellij.psi.PsiFile;
 import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.unscramble.ThreadState;
+import com.intellij.util.Alarm;
 import com.intellij.xdebugger.AbstractDebuggerSession;
 import com.sun.jdi.ObjectCollectedException;
 import com.sun.jdi.ThreadReference;
@@ -88,6 +90,7 @@ public class DebuggerSession implements AbstractDebuggerSession {
   public static final int EVENT_START_WAIT_ATTACH = 9;
   public static final int EVENT_DISPOSE = 10;
   public static final int EVENT_REFRESH_VIEWS_ONLY = 11;
+  public static final int EVENT_THREADS_REFRESH = 12;
 
   private volatile boolean myIsEvaluating;
   private volatile int myIgnoreFiltersFrameCountThreshold = 0;
@@ -101,6 +104,7 @@ public class DebuggerSession implements AbstractDebuggerSession {
   private final DebuggerContextImpl SESSION_EMPTY_CONTEXT;
   //Thread, user is currently stepping through
   private final Set<ThreadReferenceProxyImpl> mySteppingThroughThreads = new HashSet<ThreadReferenceProxyImpl>();
+  protected final Alarm myUpdateAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD);
 
   public boolean isSteppingThrough(ThreadReferenceProxyImpl threadProxy) {
     return mySteppingThroughThreads.contains(threadProxy);
@@ -307,6 +311,7 @@ public class DebuggerSession implements AbstractDebuggerSession {
     ApplicationManager.getApplication().assertIsDispatchThread();
     getProcess().dispose();
     getContextManager().setState(SESSION_EMPTY_CONTEXT, STATE_DISPOSED, EVENT_DISPOSE, null);
+    Disposer.dispose(myUpdateAlarm);
   }
 
   // ManagerCommands
@@ -567,23 +572,21 @@ public class DebuggerSession implements AbstractDebuggerSession {
     }
 
     public void threadStarted(DebugProcess proc, ThreadReference thread) {
-      ((VirtualMachineProxyImpl)proc.getVirtualMachineProxy()).threadStarted(thread);
-      DebuggerInvocationUtil.invokeLater(getProject(), new Runnable() {
-        public void run() {
-          final DebuggerStateManager contextManager = getContextManager();
-          contextManager.fireStateChanged(contextManager.getContext(), EVENT_REFRESH_VIEWS_ONLY);
-        }
-      });
+      notifyThreadsRefresh();
     }
 
     public void threadStopped(DebugProcess proc, ThreadReference thread) {
-      ((VirtualMachineProxyImpl)proc.getVirtualMachineProxy()).threadStopped(thread);
-      DebuggerInvocationUtil.invokeLater(getProject(), new Runnable() {
+      notifyThreadsRefresh();
+    }
+    
+    private void notifyThreadsRefresh() {
+      myUpdateAlarm.cancelAllRequests();
+      myUpdateAlarm.addRequest(new Runnable() {
         public void run() {
           final DebuggerStateManager contextManager = getContextManager();
-          contextManager.fireStateChanged(contextManager.getContext(), EVENT_REFRESH_VIEWS_ONLY);
+          contextManager.fireStateChanged(contextManager.getContext(), EVENT_THREADS_REFRESH);
         }
-      });
+      }, 100, ModalityState.NON_MODAL);
     }
   }
 
index 2f7164de9d10690994c909dff21f1f4fdc38f87a..b05540efb1d1f348aa3b98bc53e7a56b390c78d8 100644 (file)
@@ -29,6 +29,7 @@ import com.intellij.debugger.engine.events.SuspendContextCommandImpl;
 import com.intellij.debugger.engine.jdi.StackFrameProxy;
 import com.intellij.debugger.impl.DebuggerContextImpl;
 import com.intellij.debugger.impl.DebuggerContextUtil;
+import com.intellij.debugger.impl.DebuggerSession;
 import com.intellij.debugger.impl.DebuggerStateManager;
 import com.intellij.debugger.jdi.StackFrameProxyImpl;
 import com.intellij.debugger.jdi.ThreadReferenceProxyImpl;
@@ -161,11 +162,13 @@ public class FramesPanel extends UpdatableDebuggerView {
   }
 
   /*invoked in swing thread*/
-  protected void rebuild(final boolean updateOnly) {
+  protected void rebuild(int event) {
     final DebuggerContextImpl context = getContext();
     final boolean paused = context.getDebuggerSession().isPaused();
-    
-    if (!paused || !updateOnly) {
+    final boolean isRefresh = event == DebuggerSession.EVENT_REFRESH ||
+                              event == DebuggerSession.EVENT_REFRESH_VIEWS_ONLY ||
+                              event == DebuggerSession.EVENT_THREADS_REFRESH;
+    if (!paused || !isRefresh) {
       myThreadsCombo.removeAllItems();
       synchronized (myFramesList) {
         myFramesList.clear();
@@ -175,7 +178,7 @@ public class FramesPanel extends UpdatableDebuggerView {
     if (paused) {
       final DebugProcessImpl process = context.getDebugProcess();
       if (process != null) {
-        process.getManagerThread().schedule(new RefreshFramePanelCommand(updateOnly && myThreadsCombo.getItemCount() != 0));
+        process.getManagerThread().schedule(new RefreshFramePanelCommand(isRefresh && myThreadsCombo.getItemCount() != 0));
       }
     }
   }
index 9e56b2774962867e8ce79c509120a1845ae9115d..2f0203acb8b7f2b27dbda4789c56d72cdb369b1a 100644 (file)
@@ -77,7 +77,7 @@ public class PositionHighlighter {
     stateManager.addListener(new DebuggerContextListener() {
       public void changeEvent(DebuggerContextImpl newContext, int event) {
         myContext = newContext;
-        if (event != DebuggerSession.EVENT_REFRESH_VIEWS_ONLY) {
+        if (event != DebuggerSession.EVENT_REFRESH_VIEWS_ONLY && event != DebuggerSession.EVENT_THREADS_REFRESH) {
           refresh();
         }
       }
index 2e140372077cd5669dda0dec2a299d2ae7285376..fbbcad3b909c37fd01d3500fc21e1126a865b0a4 100644 (file)
@@ -74,7 +74,7 @@ public abstract class DebuggerTreePanel extends UpdatableDebuggerView implements
   protected abstract DebuggerTree createTreeView();
 
 
-  protected void rebuild(final boolean updateOnly) {
+  protected void rebuild(int event) {
     DebuggerSession debuggerSession = getContext().getDebuggerSession();
     if(debuggerSession == null) {
       return;
index 4fc5a4d924533320f5aa280ae706137b49258b9a..c5fe2e0a6c3f8b6a735ff06442359f9ca60524c8 100644 (file)
@@ -22,10 +22,11 @@ package com.intellij.debugger.ui.impl;
 
 import com.intellij.debugger.actions.DebuggerAction;
 import com.intellij.debugger.actions.DebuggerActions;
+import com.intellij.debugger.impl.DebuggerContextImpl;
+import com.intellij.debugger.impl.DebuggerSession;
 import com.intellij.debugger.impl.DebuggerStateManager;
 import com.intellij.debugger.ui.impl.watch.DebuggerTree;
 import com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl;
-import com.intellij.openapi.Disposable;
 import com.intellij.openapi.actionSystem.ActionPopupMenu;
 import com.intellij.openapi.actionSystem.CommonShortcuts;
 import com.intellij.openapi.project.Project;
@@ -47,6 +48,11 @@ public class InspectPanel extends DebuggerTreePanel {
     setUpdateEnabled(true);
   }
 
+  protected void changeEvent(DebuggerContextImpl newContext, int event) {
+    if (event != DebuggerSession.EVENT_THREADS_REFRESH) {
+      super.changeEvent(newContext, event);
+    }
+  }
 
   protected DebuggerTree createTreeView() {
     return new InspectDebuggerTree(getProject());
index f2abc68402f2af2967d456c11616a901f8ae8d8a..9863785dea78b102db169c982144bd101b987083 100644 (file)
@@ -17,7 +17,6 @@ package com.intellij.debugger.ui.impl;
 
 import com.intellij.debugger.impl.DebuggerContextImpl;
 import com.intellij.debugger.impl.DebuggerContextListener;
-import com.intellij.debugger.impl.DebuggerSession;
 import com.intellij.debugger.impl.DebuggerStateManager;
 import com.intellij.debugger.ui.DebuggerView;
 import com.intellij.openapi.Disposable;
@@ -86,7 +85,7 @@ public abstract class UpdatableDebuggerView extends JPanel implements DebuggerVi
       myRebuildAlarm.addRequest(new Runnable() {
         public void run() {
           try {
-            rebuild(event == DebuggerSession.EVENT_REFRESH || event == DebuggerSession.EVENT_REFRESH_VIEWS_ONLY);
+            rebuild(event);
           }
           catch (VMDisconnectedException e) {
             // ignored
@@ -99,7 +98,7 @@ public abstract class UpdatableDebuggerView extends JPanel implements DebuggerVi
     }
   }
 
-  protected abstract void rebuild(boolean updateOnly);
+  protected abstract void rebuild(int event);
 
   protected final void registerDisposable(Disposable disposable) {
     myDisposables.add(disposable);
index 7dd4cd58eda6fbee69daad5ba39f0a6922d7e983..0a4910f3a231397ac9d582769a1d4300d3358cd3 100644 (file)
@@ -17,6 +17,8 @@ package com.intellij.debugger.ui.impl;
 
 import com.intellij.debugger.actions.DebuggerAction;
 import com.intellij.debugger.actions.DebuggerActions;
+import com.intellij.debugger.impl.DebuggerContextImpl;
+import com.intellij.debugger.impl.DebuggerSession;
 import com.intellij.debugger.impl.DebuggerStateManager;
 import com.intellij.debugger.ui.impl.watch.DebuggerTree;
 import com.intellij.openapi.Disposable;
@@ -53,6 +55,11 @@ public class VariablesPanel extends DebuggerTreePanel implements DataProvider{
     return new FrameDebuggerTree(getProject());
   }
 
+  protected void changeEvent(DebuggerContextImpl newContext, int event) {
+    if (event != DebuggerSession.EVENT_THREADS_REFRESH) {
+      super.changeEvent(newContext, event);
+    }
+  }
 
   protected ActionPopupMenu createPopupMenu() {
     ActionGroup group = (ActionGroup)ActionManager.getInstance().getAction(DebuggerActions.FRAME_PANEL_POPUP);
index 2889e65f37df39eb237a8dff6eab0b31b931a578..3823e5d312fb2ba3b35351598b23495738f03af3 100644 (file)
@@ -28,7 +28,6 @@ import com.intellij.debugger.impl.DebuggerStateManager;
 import com.intellij.debugger.ui.impl.watch.DebuggerTree;
 import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl;
 import com.intellij.debugger.ui.impl.watch.WatchItemDescriptor;
-import com.intellij.openapi.Disposable;
 import com.intellij.openapi.actionSystem.ActionPopupMenu;
 import com.intellij.openapi.actionSystem.CommonShortcuts;
 import com.intellij.openapi.actionSystem.PlatformDataKeys;
@@ -54,6 +53,9 @@ public abstract class WatchPanel extends DebuggerTreePanel {
   }
 
   protected void changeEvent(DebuggerContextImpl newContext, int event) {
+    if (event == DebuggerSession.EVENT_THREADS_REFRESH) {
+      return;
+    }
     if(event == DebuggerSession.EVENT_ATTACHED) {
       DebuggerTreeNodeImpl root = (DebuggerTreeNodeImpl) getWatchTree().getModel().getRoot();
       if(root != null) {
index 20d5adb3aa7cce29990045e1aeafc3e6614bcdaa..87afe0d3a3901f41036352eb2e55f47fe5e8932c 100644 (file)
  */
 package com.intellij.ide;
 
-import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider;
 import com.intellij.lang.Language;
 import com.intellij.lang.StdLanguages;
 import com.intellij.psi.codeStyle.CodeStyleSettingsCustomizable;
+import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider;
 import org.jetbrains.annotations.NotNull;
 
 /**
@@ -40,6 +40,12 @@ public class JavaLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSett
     return GENERAL_CODE_SAMPLE;
   }
 
+  @Override
+  public int getRightMargin(@NotNull SettingsType settingsType) {
+    if (settingsType == SettingsType.WRAPPING_AND_BRACES_SETTINGS) return 37;
+    return super.getRightMargin(settingsType);
+  }
+
   @Override
   public void customizeSettings(@NotNull CodeStyleSettingsCustomizable consumer, @NotNull SettingsType settingsType) {
     consumer.showAllStandardOptions();
index e3da448ac825b5f68ba3a2107e662be04db8171e..d01859164a6bea06e208d35867c8cd2481575f82 100644 (file)
@@ -39,6 +39,10 @@ public abstract class LanguageCodeStyleSettingsProvider {
 
   public abstract String getCodeSample(@NotNull SettingsType settingsType);
 
+  public int getRightMargin(@NotNull SettingsType settingsType) {
+    return settingsType == SettingsType.WRAPPING_AND_BRACES_SETTINGS ? 30 : -1;
+  }
+
   public void customizeSettings(@NotNull CodeStyleSettingsCustomizable consumer, @NotNull SettingsType settingsType) {
   }
 
@@ -74,6 +78,15 @@ public abstract class LanguageCodeStyleSettingsProvider {
     return null;
   }
 
+  public static int getRightMargin(Language lang, @NotNull SettingsType settingsType) {
+    for (LanguageCodeStyleSettingsProvider provider : Extensions.getExtensions(EP_NAME)) {
+      if (provider.getLanguage().equals(lang)) {
+        return provider.getRightMargin(settingsType);
+      }
+    }
+    return -1;
+  }
+
   @Nullable
   public static Language getLanguage(String langName) {
     for (LanguageCodeStyleSettingsProvider provider : Extensions.getExtensions(EP_NAME)) {
index 35fa915d585ed727bcd3ace83692adb342aee577..01e6a35be7ebdb61093e47d5b3b2d90ecb983c5d 100644 (file)
@@ -24,6 +24,7 @@ import com.intellij.psi.*;
 import com.intellij.psi.scope.PsiScopeProcessor;
 import com.intellij.psi.search.PsiElementProcessor;
 import com.intellij.psi.stubs.StubBase;
+import com.intellij.psi.stubs.StubElement;
 import com.intellij.psi.templateLanguages.OuterLanguageElement;
 import com.intellij.util.ArrayUtil;
 import com.intellij.util.SmartList;
@@ -352,7 +353,16 @@ public class PsiTreeUtil {
 
   @Nullable
   public static PsiElement getStubOrPsiParent(@Nullable PsiElement element) {
-    return getStubOrPsiParentOfType(element, PsiElement.class);
+    if (element instanceof StubBasedPsiElement) {
+      StubBase stub = (StubBase)((StubBasedPsiElement)element).getStub();
+      if (stub != null) {
+        //noinspection unchecked
+        final StubElement parentStub = stub.getParentStub();
+        return parentStub != null ? parentStub.getPsi() : null;
+      }
+
+    }
+    return element != null ? element.getParent() : null;
   }
 
   @Nullable
index 4f308de9261d301cb9376db0e8253fa262f4380c..87c17486aa3eaa3f2f9a57c5704e369a8f0a2b09 100644 (file)
@@ -16,6 +16,7 @@
 package com.intellij.application.options;
 
 import com.intellij.application.options.codeStyle.CodeStyleSchemesModel;
+import com.intellij.codeStyle.CodeStyleFacade;
 import com.intellij.ide.DataManager;
 import com.intellij.openapi.Disposable;
 import com.intellij.openapi.actionSystem.PlatformDataKeys;
@@ -89,6 +90,8 @@ public abstract class CodeStyleAbstractPanel implements Disposable {
         somethingChanged();
       }
     });
+
+    updatePreview();
   }
 
   public void setModel(final CodeStyleSchemesModel model) {
@@ -107,35 +110,13 @@ public abstract class CodeStyleAbstractPanel implements Disposable {
 
   private Editor createEditor() {
     EditorFactory editorFactory = EditorFactory.getInstance();
-    myTextToReformat = getPreviewText();
-    Document editorDocument = editorFactory.createDocument(myTextToReformat);
+    Document editorDocument = editorFactory.createDocument("");
     EditorEx editor = (EditorEx)editorFactory.createViewer(editorDocument);
-
+    fillEditorSettings(editor.getSettings());
     myLastDocumentModificationStamp = editor.getDocument().getModificationStamp();
-
-    EditorSettings editorSettings = editor.getSettings();
-    fillEditorSettings(editorSettings);
-
-    updatePreviewHighlighter(editor);
-
     return editor;
   }
 
-  private void updatePreviewHighlighter(final EditorEx editor) {
-    EditorColorsScheme scheme = editor.getColorsScheme();
-    scheme.setColor(EditorColors.CARET_ROW_COLOR, null);
-
-    editor.setHighlighter(createHighlighter(scheme));
-  }
-
-  protected void updatePreviewEditor() {
-    myTextToReformat = getPreviewText();
-    updatePreview();
-    updatePreviewHighlighter((EditorEx)myEditor);
-  }
-
-  protected abstract EditorHighlighter createHighlighter(final EditorColorsScheme scheme);
-
   private void fillEditorSettings(final EditorSettings editorSettings) {
     editorSettings.setWhitespacesShown(true);
     editorSettings.setLineMarkerAreaShown(false);
@@ -144,21 +125,22 @@ public abstract class CodeStyleAbstractPanel implements Disposable {
     editorSettings.setFoldingOutlineShown(false);
     editorSettings.setAdditionalColumnsCount(0);
     editorSettings.setAdditionalLinesCount(1);
-    final int rightMargin = getRightMargin();
-    if (rightMargin > 0) {
-      editorSettings.setRightMargin(rightMargin);
-    }
   }
 
-  protected abstract int getRightMargin();
+  protected void updatePreview() {
+    updateEditor();
+    updatePreviewHighlighter((EditorEx)myEditor);
+  }
 
-  public final void updatePreview() {
+  private void updateEditor() {
     if (!myShouldUpdatePreview || !myEditor.getComponent().isShowing()) {
       return;
     }
 
     if (myLastDocumentModificationStamp != myEditor.getDocument().getModificationStamp()) {
       myTextToReformat = myEditor.getDocument().getText();
+    } else {
+      myTextToReformat = getPreviewText();
     }
 
     int currOffs = myEditor.getScrollingModel().getVerticalScrollOffset();
@@ -169,11 +151,19 @@ public abstract class CodeStyleAbstractPanel implements Disposable {
         replaceText(finalProject);
       }
     }, null, null);
-    myEditor.getSettings().setRightMargin(getRightMargin());
+
+    myEditor.getSettings().setRightMargin(getAdjustedRightMargin());
     myLastDocumentModificationStamp = myEditor.getDocument().getModificationStamp();
     myEditor.getScrollingModel().scrollVertically(currOffs);
   }
 
+  private int getAdjustedRightMargin() {
+    int result = getRightMargin();
+    return result > 0 ? result : CodeStyleFacade.getInstance(getCurrentProject()).getRightMargin();
+  }
+
+  protected abstract int getRightMargin();
+
   private void replaceText(final Project project) {
     ApplicationManager.getApplication().runWriteAction(new Runnable() {
       public void run() {
@@ -184,9 +174,7 @@ public abstract class CodeStyleAbstractPanel implements Disposable {
           prepareForReformat(psiFile);
           apply(mySettings);
           CodeStyleSettings clone = mySettings.clone();
-          if (getRightMargin() > 0) {
-            clone.RIGHT_MARGIN = getRightMargin();
-          }
+          clone.RIGHT_MARGIN = getAdjustedRightMargin();
 
 
           CodeStyleSettingsManager.getInstance(project).setTemporarySettings(clone);
@@ -226,6 +214,14 @@ public abstract class CodeStyleAbstractPanel implements Disposable {
     return project;
   }
 
+  private void updatePreviewHighlighter(final EditorEx editor) {
+    EditorColorsScheme scheme = editor.getColorsScheme();
+    scheme.setColor(EditorColors.CARET_ROW_COLOR, null);
+    editor.setHighlighter(createHighlighter(scheme));
+  }
+
+  protected abstract EditorHighlighter createHighlighter(final EditorColorsScheme scheme);
+
   @NotNull
   protected abstract FileType getFileType();
 
@@ -322,7 +318,7 @@ public abstract class CodeStyleAbstractPanel implements Disposable {
         try {
           myUpdateAlarm.cancelAllRequests();
           if (isSomethingChanged()) {
-            updatePreview();
+            updateEditor();
           }
         }
         finally {
index 90ef442f2faf39caea7a23cfbc40c1fcc2bb2f53..f227858fbecea7b4341a7a5da7dfa7287d247f47 100644 (file)
@@ -148,7 +148,7 @@ public class GeneralCodeStylePanel extends CodeStyleAbstractPanel {
         final int selIndex = myIndentOptionsTabs.getSelectedIndex();
         if (selIndex != myLastSelectedTab) {
           myLastSelectedTab = selIndex;
-          updatePreviewEditor();
+          updatePreview();
           somethingChanged();
         }
       }
index 5a08c679c8175ba37753ba6bbbd4a36f2ba254b5..2fe4ea1dafa6ef31693388f53bcc7b898bd39057 100644 (file)
@@ -155,10 +155,6 @@ public class CodeStyleBlankLinesPanel extends MultilanguageCodeStyleAbstractPane
 
   }
 
-  protected int getRightMargin() {
-    return -1;
-  }
-
   public JComponent getPanel() {
     return myPanel;
   }
index a83091633f28583bd602b6b7859f4deacba4b417..eedd6f5f01ecb560313852e06e422139ee73f530 100644 (file)
@@ -86,7 +86,7 @@ public abstract class MultilanguageCodeStyleAbstractPanel extends CodeStyleAbstr
       }
     }
     onLanguageChange(language);
-    updatePreviewEditor();
+    updatePreview();
   }
 
   public Language getSelectedLanguage() {
@@ -106,6 +106,12 @@ public abstract class MultilanguageCodeStyleAbstractPanel extends CodeStyleAbstr
     return sample;
   }
 
+  @Override
+  protected int getRightMargin() {
+    if (myLanguage == null) return -1;
+    return LanguageCodeStyleSettingsProvider.getRightMargin(myLanguage, getSettingsType());
+  }
+
   @NotNull
   @Override
   protected FileType getFileType() {
@@ -188,7 +194,7 @@ public abstract class MultilanguageCodeStyleAbstractPanel extends CodeStyleAbstr
         setPanelLanguage(langs[0]);
       }
       else {
-        updatePreviewEditor();
+        updatePreview();
       }
       tabbedPane.addChangeListener(new ChangeListener() {
         public void stateChanged(ChangeEvent e) {
@@ -213,7 +219,7 @@ public abstract class MultilanguageCodeStyleAbstractPanel extends CodeStyleAbstr
     else {
       // If settings are language-specific
       previewPanel.add(getEditor().getComponent(), BorderLayout.CENTER);
-      updatePreviewEditor();
+      updatePreview();
     }
   }
 
index 5b94deafdfd0918f84c05b5d9a61965a4bfa720e..ac5805f483cf5d21833477692e1aac867bc083e5 100644 (file)
@@ -223,10 +223,6 @@ public abstract class OptionTreeWithPreviewPanel extends MultilanguageCodeStyleA
 
   protected abstract void initTables();
 
-  protected int getRightMargin() {
-    return -1;
-  }
-
   protected void resetImpl(final CodeStyleSettings settings) {
     TreeModel treeModel = myOptionsTree.getModel();
     TreeNode root = (TreeNode)treeModel.getRoot();
index d715db1a4cf64335559c20886b3bf29ec484c581..6b7349a00d7f673db73d25d2d793188edccb25a7 100644 (file)
@@ -134,8 +134,4 @@ public class WrappingAndBracesPanel extends OptionTableWithPreviewPanel {
     addOption("VARIABLE_ANNOTATION_WRAP", ApplicationBundle.message("wrapping.local.variables.annotation"), WRAP_OPTIONS, WRAP_VALUES);
     addOption("ENUM_CONSTANTS_WRAP", ApplicationBundle.message("wrapping.enum.constants"), WRAP_OPTIONS, WRAP_VALUES);
   }
-
-  protected int getRightMargin() {
-    return 37;
-  }
 }
\ No newline at end of file
index 733c610cded82aa7607b9a2abf6767fe559a0ec2..a66f6de4a6c1ba699ba957d6be8e14b13fc4dc01 100644 (file)
 
 package com.intellij.ide.actions;
 
-import com.intellij.CommonBundle;
-import com.intellij.history.LocalHistory;
-import com.intellij.history.LocalHistoryAction;
 import com.intellij.ide.IdeBundle;
 import com.intellij.ide.IdeView;
 import com.intellij.ide.util.DirectoryChooserUtil;
-import com.intellij.ide.util.DirectoryUtil;
 import com.intellij.openapi.actionSystem.*;
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.command.CommandProcessor;
-import com.intellij.openapi.fileTypes.FileTypeManager;
 import com.intellij.openapi.project.DumbAware;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.InputValidatorEx;
 import com.intellij.openapi.ui.Messages;
 import com.intellij.psi.PsiDirectory;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.impl.file.PsiDirectoryFactory;
 import com.intellij.util.Icons;
-import com.intellij.util.IncorrectOperationException;
-
-import java.io.File;
 
 public class CreateDirectoryOrPackageAction extends AnAction implements DumbAware {
   public CreateDirectoryOrPackageAction() {
@@ -45,40 +34,39 @@ public class CreateDirectoryOrPackageAction extends AnAction implements DumbAwar
   }
 
   public void actionPerformed(AnActionEvent e) {
-    DataContext dataContext = e.getDataContext();
-
-    IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
-    Project project = PlatformDataKeys.PROJECT.getData(dataContext);
+    IdeView view = e.getData(LangDataKeys.IDE_VIEW);
+    Project project = e.getData(PlatformDataKeys.PROJECT);
 
     PsiDirectory directory = DirectoryChooserUtil.getOrChooseDirectory(view);
 
     if (directory == null) return;
     boolean isDirectory = !PsiDirectoryFactory.getInstance(project).isPackage(directory);
 
-    MyInputValidator validator = new MyInputValidator(project, directory, isDirectory);
+    CreateDirectoryOrPackageHandler validator = new CreateDirectoryOrPackageHandler(project, directory, isDirectory,
+                                                                                   isDirectory ? "\\/" : ".");
     Messages.showInputDialog(project, isDirectory
                                       ? IdeBundle.message("prompt.enter.new.directory.name")
                                       : IdeBundle.message("prompt.enter.new.package.name"),
                                       isDirectory ? IdeBundle.message("title.new.directory") : IdeBundle.message("title.new.package"),
                                       Messages.getQuestionIcon(), "", validator);
 
-    if (validator.myCreatedElement == null) return;
-
-    view.selectElement(validator.myCreatedElement);
+    final PsiElement result = validator.getCreatedElement();
+    if (result != null && view != null) {
+      view.selectElement(result);
+    }
   }
 
   public void update(AnActionEvent event) {
     Presentation presentation = event.getPresentation();
-    DataContext dataContext = event.getDataContext();
 
-    Project project = PlatformDataKeys.PROJECT.getData(dataContext);
+    Project project = event.getData(PlatformDataKeys.PROJECT);
     if (project == null) {
       presentation.setVisible(false);
       presentation.setEnabled(false);
       return;
     }
 
-    IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
+    IdeView view = event.getData(LangDataKeys.IDE_VIEW);
     if (view == null) {
       presentation.setVisible(false);
       presentation.setEnabled(false);
@@ -114,100 +102,4 @@ public class CreateDirectoryOrPackageAction extends AnAction implements DumbAwar
     }
   }
 
-  protected class MyInputValidator implements InputValidatorEx {
-    private final Project myProject;
-    private final PsiDirectory myDirectory;
-    private final boolean myIsDirectory;
-    private PsiElement myCreatedElement = null;
-
-    public MyInputValidator(Project project, PsiDirectory directory, boolean isDirectory) {
-      myProject = project;
-      myDirectory = directory;
-      myIsDirectory = isDirectory;
-    }
-
-    public boolean checkInput(String inputString) {
-      return true;
-    }
-
-    public String getErrorText(String inputString) {
-      if (FileTypeManager.getInstance().isFileIgnored(inputString)) {
-        return "Trying to create a " + (myIsDirectory ? "directory" : "package") + " with ignored name, result will not be visible";
-      }
-      if (!myIsDirectory && inputString.length() > 0 && !PsiDirectoryFactory.getInstance(myProject).isValidPackageName(inputString)) {
-        return "Not a valid package name";
-      }
-      return null;
-    }
-
-    public boolean canClose(String inputString) {
-      final String subDirName = inputString;
-
-      if (subDirName.length() == 0) {
-        Messages.showMessageDialog(myProject, IdeBundle.message("error.name.should.be.specified"), CommonBundle.getErrorTitle(),
-                                   Messages.getErrorIcon());
-        return false;
-      }
-
-      final boolean multiCreation = myIsDirectory
-                                    ? subDirName.indexOf('/') != -1 || subDirName.indexOf('\\') != -1
-                                    : subDirName.indexOf('.') != -1;
-
-      if (!multiCreation) {
-        try {
-          myDirectory.checkCreateSubdirectory(subDirName);
-        }
-        catch (IncorrectOperationException ex) {
-          Messages.showMessageDialog(myProject, CreateElementActionBase.filterMessage(ex.getMessage()), CommonBundle.getErrorTitle(),
-                                     Messages.getErrorIcon());
-          return false;
-        }
-      }
-
-      Runnable command = new Runnable() {
-        public void run() {
-          final Runnable run = new Runnable() {
-            public void run() {
-              LocalHistoryAction action = LocalHistoryAction.NULL;
-              try {
-                String actionName;
-                String dirPath = myDirectory.getVirtualFile().getPresentableUrl();
-                actionName = IdeBundle.message("progress.creating.directory", dirPath, File.separator, subDirName);
-                action = LocalHistory.getInstance().startAction(actionName);
-
-                final PsiDirectory createdDir;
-                if (myIsDirectory) {
-                  createdDir = DirectoryUtil.createSubdirectories(subDirName, myDirectory, "\\/");
-                }
-                else {
-                  createdDir = DirectoryUtil.createSubdirectories(subDirName, myDirectory, ".");
-                }
-
-
-                myCreatedElement = createdDir;
-
-              }
-              catch (final IncorrectOperationException ex) {
-                ApplicationManager.getApplication().invokeLater(new Runnable() {
-                  public void run() {
-                    Messages.showMessageDialog(myProject, CreateElementActionBase.filterMessage(ex.getMessage()),
-                                               CommonBundle.getErrorTitle(), Messages.getErrorIcon());
-                  }
-                });
-              }
-              finally {
-                action.finish();
-              }
-            }
-          };
-          ApplicationManager.getApplication().runWriteAction(run);
-        }
-      };
-      CommandProcessor.getInstance().executeCommand(myProject, command, myIsDirectory
-                                                                        ? IdeBundle.message("command.create.directory")
-                                                                        : IdeBundle.message("command.create.package"), null);
-
-      return myCreatedElement != null;
-    }
-  }
 }
diff --git a/platform/lang-impl/src/com/intellij/ide/actions/CreateDirectoryOrPackageHandler.java b/platform/lang-impl/src/com/intellij/ide/actions/CreateDirectoryOrPackageHandler.java
new file mode 100644 (file)
index 0000000..f820d62
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * Copyright 2000-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.ide.actions;
+
+import com.intellij.CommonBundle;
+import com.intellij.history.LocalHistory;
+import com.intellij.history.LocalHistoryAction;
+import com.intellij.ide.IdeBundle;
+import com.intellij.ide.util.DirectoryUtil;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.command.CommandProcessor;
+import com.intellij.openapi.fileTypes.FileTypeManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.InputValidatorEx;
+import com.intellij.openapi.ui.Messages;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.psi.PsiDirectory;
+import com.intellij.psi.impl.file.PsiDirectoryFactory;
+import com.intellij.util.IncorrectOperationException;
+
+import java.io.File;
+
+public class CreateDirectoryOrPackageHandler implements InputValidatorEx {
+  private final Project myProject;
+  private final PsiDirectory myDirectory;
+  private final boolean myIsDirectory;
+  private PsiDirectory myCreatedElement = null;
+  private String myDelimiters;
+
+  public CreateDirectoryOrPackageHandler(Project project, PsiDirectory directory, boolean isDirectory, final String delimiters) {
+    myProject = project;
+    myDirectory = directory;
+    myIsDirectory = isDirectory;
+    myDelimiters = delimiters;
+  }
+
+  public boolean checkInput(String inputString) {
+    return true;
+  }
+
+  public String getErrorText(String inputString) {
+    if (FileTypeManager.getInstance().isFileIgnored(inputString)) {
+      return "Trying to create a " + (myIsDirectory ? "directory" : "package") + " with ignored name, result will not be visible";
+    }
+    if (!myIsDirectory && inputString.length() > 0 && !PsiDirectoryFactory.getInstance(myProject).isValidPackageName(inputString)) {
+      return "Not a valid package name";
+    }
+    return null;
+  }
+
+  public boolean canClose(String inputString) {
+    final String subDirName = inputString;
+
+    if (subDirName.length() == 0) {
+      Messages.showMessageDialog(myProject, IdeBundle.message("error.name.should.be.specified"), CommonBundle.getErrorTitle(),
+                                 Messages.getErrorIcon());
+      return false;
+    }
+
+    final boolean multiCreation = StringUtil.containsAnyChar(subDirName, myDelimiters);
+    if (!multiCreation) {
+      try {
+        myDirectory.checkCreateSubdirectory(subDirName);
+      }
+      catch (IncorrectOperationException ex) {
+        Messages.showMessageDialog(myProject, CreateElementActionBase.filterMessage(ex.getMessage()), CommonBundle.getErrorTitle(),
+                                   Messages.getErrorIcon());
+        return false;
+      }
+    }
+
+    Runnable command = new Runnable() {
+      public void run() {
+        final Runnable run = new Runnable() {
+          public void run() {
+            LocalHistoryAction action = LocalHistoryAction.NULL;
+            try {
+              String actionName;
+              String dirPath = myDirectory.getVirtualFile().getPresentableUrl();
+              actionName = IdeBundle.message("progress.creating.directory", dirPath, File.separator, subDirName);
+              action = LocalHistory.getInstance().startAction(actionName);
+
+              myCreatedElement = DirectoryUtil.createSubdirectories(subDirName, myDirectory, myDelimiters);
+
+            }
+            catch (final IncorrectOperationException ex) {
+              ApplicationManager.getApplication().invokeLater(new Runnable() {
+                public void run() {
+                  Messages.showMessageDialog(myProject, CreateElementActionBase.filterMessage(ex.getMessage()),
+                                             CommonBundle.getErrorTitle(), Messages.getErrorIcon());
+                }
+              });
+            }
+            finally {
+              action.finish();
+            }
+          }
+        };
+        ApplicationManager.getApplication().runWriteAction(run);
+      }
+    };
+    CommandProcessor.getInstance().executeCommand(myProject, command, myIsDirectory
+                                                                      ? IdeBundle.message("command.create.directory")
+                                                                      : IdeBundle.message("command.create.package"), null);
+
+    return myCreatedElement != null;
+  }
+
+  public PsiDirectory getCreatedElement() {
+    return myCreatedElement;
+  }
+}
index 296679097d83a2e3bf2c340cc9c0b1b310c8aab1..cf8d9c23e6817efd0712a42ec0015bd9f61c7a49 100644 (file)
@@ -33,6 +33,7 @@ public class DirectoryChooserUtil {
   private DirectoryChooserUtil() {
   }
 
+  @Nullable
   public static PsiDirectory getOrChooseDirectory(IdeView view) {
     PsiDirectory[] dirs = view.getDirectories();
     if (dirs.length == 0) return null;
@@ -45,6 +46,7 @@ public class DirectoryChooserUtil {
     }
   }
 
+  @Nullable
   public static PsiDirectory selectDirectory(Project project,
                                              PsiDirectory[] packageDirectories,
                                              PsiDirectory defaultDirectory,
index fb00b2afd3a830fa90d5c9639d3c54b6c386f95a..43459f96a7f6b0b50866f67d03ac59fb141b7259 100644 (file)
@@ -122,6 +122,7 @@ public class StringPattern extends ObjectPattern<String, StringPattern> {
         sb.append("<whitespace>");
       }
       else
+      //This is really stupid and inconvinient builder - it breaks any normal pattern with uppercase
       if(Character.isUpperCase(c)) {
         sb.append('[').append(Character.toUpperCase(c)).append(Character.toLowerCase(c)).append(']');
       }
diff --git a/platform/platform-impl/src/com/intellij/codeInsight/hint/CustomHrView.java b/platform/platform-impl/src/com/intellij/codeInsight/hint/CustomHrView.java
new file mode 100644 (file)
index 0000000..2be2747
--- /dev/null
@@ -0,0 +1,238 @@
+/*
+ * @(#)HRuleView.java  1.33 05/11/17
+ *
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ */
+package com.intellij.codeInsight.hint;
+
+import java.awt.*;
+import javax.swing.event.DocumentEvent;
+import javax.swing.text.*;
+import javax.swing.text.html.CSS;
+import javax.swing.text.html.HTML;
+import javax.swing.text.html.HTMLDocument;
+import javax.swing.text.html.StyleSheet;
+import java.util.Enumeration;
+import java.lang.Integer;
+
+/**
+ * A view implementation to display an html horizontal
+ * rule.
+ *
+ * @author Timothy Prinzing
+ * @author Sara Swanson
+ * @version 1.33 11/17/05
+ */
+class CustomHrView extends View {
+
+  private Color myColor;
+
+  /**
+   * Creates a new view that represents an &lt;hr&gt; element.
+   *
+   * @param elem the element to create a view for
+   */
+  public CustomHrView(Element elem, Color color) {
+    super(elem);
+    myColor = color;
+  }
+
+
+  public void paint(Graphics g, Shape a) {
+    Rectangle alloc = (a instanceof Rectangle) ? (Rectangle)a : a.getBounds();
+    int x = 0;
+    int y = alloc.y + SPACE_ABOVE + (int)topMargin;
+    int width = alloc.width - (int)(leftMargin + rightMargin);
+    int height = 1;
+    if (size > 0) height = size;
+
+    // Align the rule horizontally.
+    switch (alignment) {
+      case StyleConstants.ALIGN_CENTER:
+        x = alloc.x + (alloc.width / 2) - (width / 2);
+        break;
+      case StyleConstants.ALIGN_RIGHT:
+        x = alloc.x + alloc.width - width - (int)rightMargin;
+        break;
+      case StyleConstants.ALIGN_LEFT:
+      default:
+        x = alloc.x + (int)leftMargin;
+        break;
+    }
+
+    // Paint either a shaded rule or a solid line.
+    if (noshade != null) {
+      g.setColor(myColor);
+      g.fillRect(x, y, width, height);
+    }
+    else {
+      Color bg = getContainer().getBackground();
+      Color bottom, top;
+      if (bg == null || bg.equals(Color.white)) {
+        top = Color.darkGray;
+        bottom = Color.lightGray;
+      }
+      else {
+        top = Color.darkGray;
+        bottom = Color.white;
+      }
+      g.setColor(bottom);
+      g.drawLine(x + width - 1, y, x + width - 1, y + height - 1);
+      g.drawLine(x, y + height - 1, x + width - 1, y + height - 1);
+      g.setColor(top);
+      g.drawLine(x, y, x + width - 1, y);
+      g.drawLine(x, y, x, y + height - 1);
+    }
+
+  }
+
+
+  /**
+   * Calculates the desired shape of the rule... this is
+   * basically the preferred size of the border.
+   *
+   * @param axis may be either X_AXIS or Y_AXIS
+   * @return the desired span
+   * @see View#getPreferredSpan
+   */
+  public float getPreferredSpan(int axis) {
+    switch (axis) {
+      case View.X_AXIS:
+        return 1;
+      case View.Y_AXIS:
+        if (size > 0) {
+          return size + SPACE_ABOVE + SPACE_BELOW + topMargin + bottomMargin;
+        }
+        else {
+          if (noshade != null) {
+            return 2 + SPACE_ABOVE + SPACE_BELOW + topMargin + bottomMargin;
+          }
+          else {
+            return SPACE_ABOVE + SPACE_BELOW + topMargin + bottomMargin;
+          }
+        }
+      default:
+        throw new IllegalArgumentException("Invalid axis: " + axis);
+    }
+  }
+
+  /**
+   * Gets the resize weight for the axis.
+   * The rule is: rigid vertically and flexible horizontally.
+   *
+   * @param axis may be either X_AXIS or Y_AXIS
+   * @return the weight
+   */
+  public int getResizeWeight(int axis) {
+    if (axis == View.X_AXIS) {
+      return 1;
+    }
+    else if (axis == View.Y_AXIS) {
+      return 0;
+    }
+    else {
+      return 0;
+    }
+  }
+
+  /**
+   * Determines how attractive a break opportunity in
+   * this view is.  This is implemented to request a forced break.
+   *
+   * @param axis may be either View.X_AXIS or View.Y_AXIS
+   * @param pos  the potential location of the start of the
+   *             broken view (greater than or equal to zero).
+   *             This may be useful for calculating tab
+   *             positions.
+   * @param len  specifies the relative length from <em>pos</em>
+   *             where a potential break is desired. The value must be greater
+   *             than or equal to zero.
+   * @return the weight, which should be a value between
+   *         ForcedBreakWeight and BadBreakWeight.
+   */
+  public int getBreakWeight(int axis, float pos, float len) {
+    if (axis == X_AXIS) {
+      return ForcedBreakWeight;
+    }
+    return BadBreakWeight;
+  }
+
+  public View breakView(int axis, int offset, float pos, float len) {
+    return null;
+  }
+
+  /**
+   * Provides a mapping from the document model coordinate space
+   * to the coordinate space of the view mapped to it.
+   *
+   * @param pos the position to convert
+   * @param a   the allocated region to render into
+   * @return the bounding box of the given position
+   * @throws BadLocationException if the given position does not
+   *                              represent a valid location in the associated document
+   * @see View#modelToView
+   */
+  public Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException {
+    int p0 = getStartOffset();
+    int p1 = getEndOffset();
+    if ((pos >= p0) && (pos <= p1)) {
+      Rectangle r = a.getBounds();
+      if (pos == p1) {
+        r.x += r.width;
+      }
+      r.width = 0;
+      return r;
+    }
+    return null;
+  }
+
+  /**
+   * Provides a mapping from the view coordinate space to the logical
+   * coordinate space of the model.
+   *
+   * @param x the X coordinate
+   * @param y the Y coordinate
+   * @param a the allocated region to render into
+   * @return the location within the model that best represents the
+   *         given point of view
+   * @see View#viewToModel
+   */
+  public int viewToModel(float x, float y, Shape a, Position.Bias[] bias) {
+    Rectangle alloc = (Rectangle)a;
+    if (x < alloc.x + (alloc.width / 2)) {
+      bias[0] = Position.Bias.Forward;
+      return getStartOffset();
+    }
+    bias[0] = Position.Bias.Backward;
+    return getEndOffset();
+  }
+
+  /**
+   * Fetches the attributes to use when rendering.  This is
+   * implemented to multiplex the attributes specified in the
+   * model with a StyleSheet.
+   */
+  public AttributeSet getAttributes() {
+    return attr;
+  }
+
+  // --- variables ------------------------------------------------
+
+  private float topMargin;
+  private float bottomMargin;
+  private float leftMargin;
+  private float rightMargin;
+  private int alignment = StyleConstants.ALIGN_CENTER;
+  private String noshade = "true";
+  private int size = 0;
+
+  private static final int SPACE_ABOVE = 3;
+  private static final int SPACE_BELOW = 3;
+
+  /**
+   * View Attributes.
+   */
+  private AttributeSet attr;
+}
+
index 0f5f233cba571f5f1f6bb49397952d6e20bef0cd..a7826c77d08747f588e7888beba74bd3251c0abc 100644 (file)
@@ -35,6 +35,9 @@ import org.jetbrains.annotations.NonNls;
 import javax.swing.*;
 import javax.swing.event.HyperlinkEvent;
 import javax.swing.event.HyperlinkListener;
+import javax.swing.text.*;
+import javax.swing.text.html.HTML;
+import javax.swing.text.html.HTMLEditorKit;
 import java.awt.*;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
@@ -285,20 +288,46 @@ public class LineTooltipRenderer implements TooltipRenderer {
   protected void stripDescription() {
   }
 
-  static JEditorPane initPane(@NonNls String text, HintHint hintHint, JLayeredPane layeredPane) {
+  static JEditorPane initPane(@NonNls String text, final HintHint hintHint, JLayeredPane layeredPane) {
     final Ref<Dimension> prefSize = new Ref<Dimension>(null);
     text = "<html><head>" +
-           UIUtil.getCssFontDeclaration(hintHint.getTextFont(), hintHint.getTextForeground()) +
+           UIUtil.getCssFontDeclaration(hintHint.getTextFont(), hintHint.getTextForeground(), hintHint.getLinkForeground()) +
            "</head><body>" +
            getHtmlBody(text) +
            "</body></html>";
-    final JEditorPane pane = new JEditorPane(UIUtil.HTML_MIME, text) {
+
+    final JEditorPane pane = new JEditorPane() {
       @Override
       public Dimension getPreferredSize() {
         return prefSize.get() != null ? prefSize.get() : super.getPreferredSize();
       }
     };
 
+    final HTMLEditorKit.HTMLFactory factory = new HTMLEditorKit.HTMLFactory() {
+      @Override
+      public View create(Element elem) {
+        AttributeSet attrs = elem.getAttributes();
+        Object elementName = attrs.getAttribute(AbstractDocument.ElementNameAttribute);
+        Object o = (elementName != null) ? null : attrs.getAttribute(StyleConstants.NameAttribute);
+        if (o instanceof HTML.Tag) {
+          HTML.Tag kind = (HTML.Tag)o;
+          if (kind == HTML.Tag.HR) {
+            return new CustomHrView(elem, hintHint.getTextForeground());
+          }
+        }
+        return super.create(elem);
+      }
+    };
+
+    HTMLEditorKit kit = new HTMLEditorKit() {
+      @Override
+      public ViewFactory getViewFactory() {
+        return factory;
+      }
+    };
+    pane.setEditorKit(kit);
+    pane.setText(text);
+
     pane.setCaretPosition(0);
     pane.setEditable(false);
 
@@ -330,6 +359,7 @@ public class LineTooltipRenderer implements TooltipRenderer {
     return pane;
   }
 
+
   public static void setColors(JComponent pane) {
     pane.setForeground(Color.black);
     pane.setBackground(HintUtil.INFORMATION_COLOR);
@@ -355,19 +385,26 @@ public class LineTooltipRenderer implements TooltipRenderer {
   }
 
   protected static String getHtmlBody(@NonNls String text) {
+    String result = text;
     if (!text.startsWith("<html>")) {
-      return text.replaceAll("\n", "<br>");
+      result = text.replaceAll("\n", "<br>");
     }
-    final int bodyIdx = text.indexOf("<body>");
-    final int closedBodyIdx = text.indexOf("</body>");
-    if (bodyIdx != -1 && closedBodyIdx != -1) {
-      return text.substring(bodyIdx + "<body>".length(), closedBodyIdx);
+    else {
+      final int bodyIdx = text.indexOf("<body>");
+      final int closedBodyIdx = text.indexOf("</body>");
+      if (bodyIdx != -1 && closedBodyIdx != -1) {
+        result = text.substring(bodyIdx + "<body>".length(), closedBodyIdx);
+      }
+      else {
+        text = StringUtil.trimStart(text, "<html>").trim();
+        text = StringUtil.trimEnd(text, "</html>").trim();
+        text = StringUtil.trimStart(text, "<body>").trim();
+        text = StringUtil.trimEnd(text, "</body>").trim();
+        result = text;
+      }
     }
-    text = StringUtil.trimStart(text, "<html>").trim();
-    text = StringUtil.trimEnd(text, "</html>").trim();
-    text = StringUtil.trimStart(text, "<body>").trim();
-    text = StringUtil.trimEnd(text, "</body>").trim();
-    return text;
+
+    return result;
   }
 
   public boolean equals(Object o) {
index 1165235e1371fc6f74e28b024c9262040f0f31b3..26fbc2396c05c57ed133b684e2b16ad0bf87f407 100644 (file)
@@ -246,6 +246,10 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener
     return useGraphite(awtTooltip) ? Color.white : UIManager.getColor("ToolTip.foreground");
   }
 
+  public Color getLinkForeground(boolean awtTooltip) {
+    return useGraphite(awtTooltip) ? new Color(209, 209, 255) : Color.blue;
+  }
+
   public Color getTextBackground(boolean awtTooltip) {
     return useGraphite(awtTooltip) ? new Color(100, 100, 100, 230) : UIManager.getColor("ToolTip.background");
   }
@@ -332,4 +336,5 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener
       hideCurrent(null);
     }
   }
+
 }
index 248e6f87adcfeb034c8d0d9f9ffe6b45b6dee94d..0d66b46bb2afdf82723568027e7975b3d87ff31f 100644 (file)
@@ -105,7 +105,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
   private ActionToolbarImpl.MyTimerListener myTimerListener;
 
   public ActionToolbarImpl(final String place,
-                           final ActionGroup actionGroup,
+                           @NotNull final ActionGroup actionGroup,
                            final boolean horizontal,
                            DataManager dataManager,
                            ActionManagerEx actionManager,
@@ -114,7 +114,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
   }
 
   public ActionToolbarImpl(final String place,
-                           final ActionGroup actionGroup,
+                           @NotNull final ActionGroup actionGroup,
                            final boolean horizontal,
                            DataManager dataManager,
                            ActionManagerEx actionManager,
index c10250901f7a971d194cc9d2d629f8352f55ea7a..426e433beccbde914539f8ec1a4b4fe59f1becc3 100644 (file)
@@ -392,10 +392,21 @@ public class CachingSoftWrapDataMapper implements SoftWrapDataMapper, SoftWrapAw
     //System.out.println("text length: " + text.length() + ", soft wraps: " + myStorage.getSoftWraps());
     //for (int i = 0; i < myCache.size(); i++) {
     //  CacheEntry entry = myCache.get(i);
-    //  System.out.printf("line %d. %d-%d: '%s'%n", i, entry.startOffset, entry.endOffset,
-    //                    text.subSequence(entry.startOffset,Math.min(entry.endOffset, text.length())));
+    //  // TODO den unwrap
+    //  try {
+    //    System.out.printf("line %d. %d-%d: '%s'%n", i, entry.startOffset, entry.endOffset,
+    //                      text.subSequence(entry.startOffset,Math.min(entry.endOffset, text.length())));
+    //  }
+    //  catch (Throwable e) {
+    //    e.printStackTrace();
+    //  }
+    //}
+    //if (!myCache.isEmpty() && myCache.get(myCache.size() - 1).endOffset < text.length() - 1) {
+    //  System.out.printf("Incomplete re-parsing detected! Document length is %d but last processed offset is %s%n", text.length(),
+    //                    myCache.get(myCache.size() - 1).endOffset);
     //}
-    //
+
+
     //for (CacheEntry cacheEntry : myCache) {
     //  if (cacheEntry.startOffset > 0) {
     //    if (text.charAt(cacheEntry.startOffset - 1) != '\n' && myStorage.getSoftWrap(cacheEntry.startOffset) == null) {
index 81fd7b128d554c1f05f6340acb8725a6e40b9fdb..bc0f06886de6202f5ea59ae351dc54568a0b74fd 100644 (file)
@@ -128,7 +128,9 @@ public class SoftWrapApplianceManager implements FoldingListener, DocumentListen
   }
 
   private void recalculateSoftWraps(DirtyRegion region) {
-    notifyListenersOnRangeRecalculation(region, true);
+    if (region.notifyAboutRecalculationStart) {
+      notifyListenersOnRangeRecalculation(region, true);
+    }
     myStorage.removeInRange(region.startRange.getStartOffset(), region.startRange.getEndOffset());
     try {
       region.beforeRecalculation();
@@ -516,6 +518,7 @@ public class SoftWrapApplianceManager implements FoldingListener, DocumentListen
 
   @Override
   public void onFoldRegionStateChange(@NotNull FoldRegion region) {
+    /*
     assert ApplicationManagerEx.getApplicationEx().isDispatchThread();
 
     Document document = myEditor.getDocument();
@@ -526,6 +529,7 @@ public class SoftWrapApplianceManager implements FoldingListener, DocumentListen
     int endOffset = document.getLineEndOffset(endLine);
 
     myDirtyRegions.add(new DirtyRegion(startOffset, endOffset));
+    */
   }
 
   @Override
@@ -535,7 +539,9 @@ public class SoftWrapApplianceManager implements FoldingListener, DocumentListen
 
   @Override
   public void beforeDocumentChange(DocumentEvent event) {
-    myDirtyRegions.add(new DirtyRegion(event));
+    DirtyRegion region = new DirtyRegion(event);
+    myDirtyRegions.add(region);
+    notifyListenersOnRangeRecalculation(region, true);
   }
 
   @Override
@@ -548,11 +554,13 @@ public class SoftWrapApplianceManager implements FoldingListener, DocumentListen
 
     public TextRange startRange;
     public TextRange endRange;
+    public boolean notifyAboutRecalculationStart;
     private boolean myRecalculateEnd;
 
     DirtyRegion(int startOffset, int endOffset) {
       startRange = new TextRange(startOffset, endOffset);
       endRange = new TextRange(startOffset, endOffset);
+      notifyAboutRecalculationStart = true;
     }
 
     DirtyRegion(DocumentEvent event) {
@@ -596,7 +604,7 @@ public class SoftWrapApplianceManager implements FoldingListener, DocumentListen
           case ' ': indentInColumns += 1; indentInPixels += spaceWidth; break;
           case '\t':
             int x = EditorUtil.nextTabStop(indentInPixels, editor);
-            indentInColumns = calculateWidthInColumns(x - indentInPixels, spaceWidth);
+            indentInColumns += calculateWidthInColumns(x - indentInPixels, spaceWidth);
             indentInPixels = x;
             break;
           default: myNonWhiteSpaceSymbolOffset = i; return;
index 41e2ba487b149f2534ed22aeef7a1085bd7f194c..b7d746abad51caa07e3e391efa2ae8c0fac58cb6 100644 (file)
@@ -84,6 +84,10 @@ public class HintHint {
     return getTooltipManager().getTextBackground(myAwtTooltip);
   }
 
+  public Color getLinkForeground() {
+    return getTooltipManager().getLinkForeground(myAwtTooltip);
+  }
+
   public boolean isOwnBorderAllowed() {
     return getTooltipManager().isOwnBorderAllowed(myAwtTooltip);
   }
index 4efe9e8ea8b45cad12e3ba61daac62b5d0e46a1f..3fa88fb6e9142081e05fbc6f373960a872a81236 100644 (file)
@@ -3,6 +3,7 @@
   <name>IDEA CORE</name>
 
   <xi:include href="/componentSets/PlatformComponents.xml" xpointer="xpointer(/components/*)"/>
+  <xi:include href="/idea/PlatformActionManager.xml" xpointer="xpointer(/component/*)"/>
 
   <extensionPoints>
     <xi:include href="/META-INF/PlatformExtensionPoints.xml" xpointer="xpointer(/extensionPoints/*)"/>
index 52644661154da5fa1a76dd70bd2dace2dc4ef1c5..c456511ffb10699fdd34d13de15919e6adb9bb9a 100644 (file)
@@ -2,7 +2,7 @@
   <!-- <version name="IntelliJ IDEA" major="6" minor="0.2 Beta"/> -->
   <version codename="Diana" major="8" minor="0M1" eap="true"/>
   <build number="__BUILD_NUMBER__" date="__BUILD_DATE__"/>
-  <logo url="/idea_logo.png"/>
+  <logo url="/idea_logo.png" textcolor="FFFFFF"/>
   <about url="/idea_about.png"/>
   <package code="__PACKAGE_CODE__"/>
   <names product="IDEA" fullname="IntelliJ IDEA"/>
index 026bcdb58dfd64fbfd8dfa8de19b32a2f280255b..86340e8bc831d496dd0ecdb848488b7ac4d33733 100644 (file)
@@ -1006,12 +1006,15 @@ public class UIUtil {
 
   @NonNls
   public static String getCssFontDeclaration(final Font font) {
-    return getCssFontDeclaration(font, null);
+    return getCssFontDeclaration(font, null, null);
   }
 
   @NonNls
-  public static String getCssFontDeclaration(final Font font, @Nullable Color fgColor) {
-    return "<style> body, div, td { font-family: " + font.getFamily() + "; font-size: " + font.getSize() + "; " + (fgColor != null ? "color:" + ColorUtil.toHex(fgColor) : "") + " } </style>";
+  public static String getCssFontDeclaration(final Font font, @Nullable Color fgColor, @Nullable Color linkColor) {
+    String fontFamilyAndSize = "font-family:" + font.getFamily() + "; font-size:" + font.getSize() + ";";
+    String body = "body, div, td {" + fontFamilyAndSize + " " + (fgColor != null ? "color:" + ColorUtil.toHex(fgColor) : "") + "}";
+    String link = (linkColor != null ? ("a {" + fontFamilyAndSize + " color:" + ColorUtil.toHex(linkColor) + "") : "") + "}";
+    return "<style> " + body + " " + link + "</style>";
   }
 
   public static boolean isWinLafOnVista() {
index 8ca4752426869b2e3d28f11c354cf690205a1b00..5e297a3cc60e102b5fd5f05ce28ab4aca6f92c56 100644 (file)
@@ -323,20 +323,22 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile {
       return ((GrFileStub)stub).isScript();
     }
 
-    Boolean isScript = myScript;
-    if (isScript == null) {
+    if (myScript == null) {
       final GrTopStatement[] topStatements = findChildrenByClass(GrTopStatement.class);
-      isScript = Boolean.FALSE;
+      boolean hasClassDefinitions = false;
+      boolean hasTopStatements = false;
       for (GrTopStatement st : topStatements) {
-        if (!(st instanceof GrTypeDefinition || st instanceof GrImportStatement || st instanceof GrPackageDefinition)) {
-          isScript = Boolean.TRUE;
+        if (st instanceof GrTypeDefinition) {
+          hasClassDefinitions = true;
+        }
+        else if (!(st instanceof GrImportStatement || st instanceof GrPackageDefinition)) {
+          hasTopStatements = true;
           break;
         }
       }
-      myScript = isScript;
+      myScript = hasTopStatements || !hasClassDefinitions;
     }
-
-    return isScript;
+    return myScript;
   }
 
   @Override
index b5c3bd95bf2c62a29d81b0ba752af593ede41f7a..0a811b780bbefb0c7dcccf7f7f119e4354a4f597 100644 (file)
@@ -29,6 +29,7 @@ import com.intellij.psi.PsiReference;
 import com.intellij.refactoring.HelpID;
 import com.intellij.refactoring.JavaRefactoringSettings;
 import com.intellij.refactoring.move.MoveCallback;
+import com.intellij.refactoring.move.moveClassesOrPackages.MoveClassesOrPackagesDialog;
 import com.intellij.refactoring.move.moveClassesOrPackages.MoveClassesOrPackagesHandlerBase;
 import com.intellij.refactoring.move.moveClassesOrPackages.MoveClassesOrPackagesImpl;
 import com.intellij.refactoring.util.CommonRefactoringUtil;