Skip to content

Commit

Permalink
Refactorings and some find improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
kkckkc authored and kkckkc@gmail.com committed Aug 16, 2011
1 parent 97e6a63 commit 3ff3e10
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
Expand Up @@ -10,6 +10,7 @@
import org.springframework.beans.factory.annotation.Autowired;

import javax.annotation.PostConstruct;
import javax.swing.*;
import java.awt.Dialog.ModalityType;
import java.awt.*;
import java.awt.event.ActionEvent;
Expand Down Expand Up @@ -112,6 +113,10 @@ private void next() {

view.getReplace().setEnabled(findCommand.isFound());
updateHistory(findCommand, true, false);

if (! findCommand.isFound()) {
JOptionPane.showMessageDialog(view.getJDialog(), "No more found");
}
}

private void previous() {
Expand All @@ -123,6 +128,10 @@ private void previous() {

view.getReplace().setEnabled(findCommand.isFound());
updateHistory(findCommand, true, false);

if (! findCommand.isFound()) {
JOptionPane.showMessageDialog(view.getJDialog(), "No more found");
}
}

private void replace() {
Expand Down
5 changes: 0 additions & 5 deletions editor/src/main/java/kkckkc/jsourcepad/model/Application.java
Expand Up @@ -20,7 +20,6 @@
import kkckkc.syntaxpane.parse.grammar.textmate.ColorUtils;
import kkckkc.syntaxpane.style.*;
import kkckkc.utils.io.FileUtils;
import org.mortbay.jetty.servlet.Context;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;

Expand Down Expand Up @@ -102,10 +101,6 @@ public SettingsManager getSettingsManager() {
return settingsManager;
}

public Context getHttpServer() {
return beanFactory.getBean(Context.class);
}

public ExecutorService getThreadPool() {
return threadPool;
}
Expand Down
5 changes: 2 additions & 3 deletions editor/src/main/java/kkckkc/jsourcepad/model/Buffer.java
Expand Up @@ -12,7 +12,6 @@
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.text.JTextComponent;
import javax.swing.text.Keymap;
import java.io.BufferedReader;
import java.io.IOException;

Expand Down Expand Up @@ -65,7 +64,7 @@ public enum ScrollAlignment { TOP, MIDDLE }
// Text manipulation
public String getText(Interval interval);
public void insertText(int position, String content, @Nullable Anchor[] anchors);
public void replaceText(Interval interval, String content, Anchor[] anchors);
public void replaceText(Interval interval, String content, @Nullable Anchor[] anchors);

public void remove(Interval interval);

Expand Down Expand Up @@ -104,7 +103,7 @@ public enum Direction { Forward, Backward }
public ActionMap getActionMap();

public Finder getFinder();
public Finder newFinder(Interval scope, String searchFor, Finder.Options options);
public Finder newFinder(@Nullable Interval scope, String searchFor, Finder.Options options);


public void undo();
Expand Down
Expand Up @@ -582,7 +582,7 @@ public void scrollTo(int position, ScrollAlignment scrollAlignment) {
try {
Rectangle re = this.textComponent.modelToView(position);
if (scrollAlignment == ScrollAlignment.MIDDLE)
re.translate(0, this.textComponent.getVisibleRect().height / 2);
re.translate(0, - this.textComponent.getVisibleRect().height / 2);
JViewport jvp = (JViewport) this.textComponent.getParent();
jvp.setViewPosition(re.getLocation());
} catch (BadLocationException e) {
Expand Down
2 changes: 2 additions & 0 deletions editor/src/main/java/kkckkc/jsourcepad/model/Finder.java
Expand Up @@ -46,6 +46,7 @@ public Interval forward(int position) {
Interval interval = findForward(position);
if (interval != null) {
buffer.setSelection(interval);
buffer.scrollTo(interval.getStart(), Buffer.ScrollAlignment.MIDDLE);
}

return interval;
Expand All @@ -55,6 +56,7 @@ public Interval backward(int position) {
Interval interval = findBackward(position);
if (interval != null) {
buffer.setSelection(interval);
buffer.scrollTo(interval.getStart(), Buffer.ScrollAlignment.MIDDLE);
}

return interval;
Expand Down

0 comments on commit 3ff3e10

Please sign in to comment.