Browse Source

格式化代码

master
XiaXiang 7 years ago
parent
commit
5e59503884
  1. 1
      designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java
  2. 11
      designer/src/com/fr/design/mainframe/alphafine/cell/model/ActionModel.java
  3. 76
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  4. 3
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFinePane.java
  5. 7
      designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java
  6. 29
      designer/src/com/fr/design/mainframe/alphafine/search/manager/RecentSearchManager.java
  7. 12
      designer_base/src/com/fr/design/mainframe/toolbar/UpdateActionManager.java

1
designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java

@ -19,7 +19,6 @@ import java.util.List;
* Created by XiaXiang on 2017/5/8.
*/
public class AlphaFineHelper {
public static final NoResultModel NO_RESULT_MODEL = new NoResultModel(Inter.getLocText("FR-Designer_AlphaFine_NoResult"));
public static final NoResultModel NO_CONNECTION_MODEL = new NoResultModel(Inter.getLocText("FR-Designer_ConnectionFailed"));
private static AlphaFineDialog alphaFineDialog;

11
designer/src/com/fr/design/mainframe/alphafine/cell/model/ActionModel.java

@ -1,5 +1,6 @@
package com.fr.design.mainframe.alphafine.cell.model;
import com.fr.design.actions.UpdateAction;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.general.FRLogger;
import com.fr.json.JSONException;
@ -11,15 +12,15 @@ import javax.swing.*;
* Created by XiaXiang on 2017/4/20.
*/
public class ActionModel extends AlphaCellModel {
private Action action;
private UpdateAction action;
public ActionModel(String name, String description, Action action, int searchCount) {
public ActionModel(String name, String description, UpdateAction action, int searchCount) {
this(name, description, action);
setSearchCount(searchCount);
}
public ActionModel(String name, String description, Action action) {
public ActionModel(String name, String description, UpdateAction action) {
super(name, null, CellType.ACTION);
this.action = action;
this.setDescription(description);
@ -43,11 +44,11 @@ public class ActionModel extends AlphaCellModel {
return action != null ? action.hashCode() : 0;
}
public Action getAction() {
public UpdateAction getAction() {
return action;
}
public void setAction(Action action) {
public void setAction(UpdateAction action) {
this.action = action;
}

76
designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java

@ -367,7 +367,6 @@ public class AlphaFineDialog extends UIDialog {
* 停止加载状态
*/
private void fireStopLoading() {
searchListModel.resetState();
if (searchResultPane != null) {
removeLeftPane();
}
@ -665,25 +664,18 @@ public class AlphaFineDialog extends UIDialog {
searchTextField.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_DOWN) {
searchResultList.requestFocus();
searchResultList.setSelectedIndex(searchResultList.getSelectedIndex() + 1);
}
}
@Override
public void keyReleased(KeyEvent e) {
int keyCode = e.getKeyCode();
if (keyCode == KeyEvent.VK_ESCAPE) {
if (StringUtils.isBlank(searchTextField.getText()) || ComparatorUtils.equals(searchTextField.getText(), searchTextField.getPlaceHolder())) {
AlphaFineDialog.this.setVisible(false);
} else {
searchTextField.setText(null);
removeSearchResult();
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
if (searchResultList.getModel().getSize() > 1) {
dealWithSearchResult(searchResultList.getSelectedValue());
}
} else if (e.getKeyCode() == KeyEvent.VK_ENTER) {
dealWithSearchResult(searchResultList.getSelectedValue());
}
} else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
if (searchResultList.getSelectedIndex() == searchResultList.getModel().getSize() - 1) {
searchResultList.setSelectedIndex(0);
}
searchResultList.setSelectedIndex(searchResultList.getSelectedIndex() + 1);
} else if (e.getKeyCode() == KeyEvent.VK_UP) {
searchResultList.setSelectedIndex(searchResultList.getSelectedIndex() - 1);
} else escAlphaFine(e);
}
});
@ -754,7 +746,9 @@ public class AlphaFineDialog extends UIDialog {
private void doNavigate() {
AlphaFineDialog.this.dispose();
final AlphaCellModel model = searchResultList.getSelectedValue();
model.doAction();
if (model != null) {
model.doAction();
}
}
/**
@ -888,6 +882,21 @@ public class AlphaFineDialog extends UIDialog {
this.splitLabel = splitLabel;
}
/**
* 键盘退出AlphaFine
*
* @param e
*/
private void escAlphaFine(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
if (StringUtils.isBlank(searchTextField.getText()) || ComparatorUtils.equals(searchTextField.getText(), searchTextField.getPlaceHolder())) {
AlphaFineDialog.this.setVisible(false);
} else {
searchTextField.setText(null);
removeSearchResult();
}
}
}
/**
* +-------------------------------------+
@ -907,7 +916,9 @@ public class AlphaFineDialog extends UIDialog {
*/
@Override
public void setSelectedIndex(int index) {
if (index > 0 && checkSelectedIndex(index)) {
if (index == 0 && getModel().getSize() > 1) {
super.setSelectedIndex(1);
} else if (index > 0 && checkSelectedIndex(index)) {
int previousIndex = getSelectedIndex();
super.setSelectedIndex(index);
AlphaCellModel cellModel = getSelectedValue();
@ -930,21 +941,6 @@ public class AlphaFineDialog extends UIDialog {
}
private void initListListener() {
addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
dealWithSearchResult(getSelectedValue());
} else if (e.getKeyCode() == KeyEvent.VK_UP) {
if (getSelectedIndex() == 1) {
searchTextField.requestFocus();
}
} else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
searchTextField.requestFocus();
}
}
});
addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
@ -968,6 +964,14 @@ public class AlphaFineDialog extends UIDialog {
}
}
});
addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
escAlphaFine(e);
}
});
}
}

3
designer/src/com/fr/design/mainframe/alphafine/component/AlphaFinePane.java

@ -1,5 +1,6 @@
package com.fr.design.mainframe.alphafine.component;
import com.bulenkov.iconloader.IconLoader;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.help.alphafine.AlphaFineContext;
import com.fr.design.actions.help.alphafine.AlphaFineListener;
@ -27,7 +28,7 @@ public class AlphaFinePane extends BasicPane {
Toolkit.getDefaultToolkit().addAWTEventListener(AlphaFineDialog.listener(), AWTEvent.KEY_EVENT_MASK);
}
UIButton refreshButton = new UIButton();
refreshButton.setIcon(IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/smallsearch.png"));
refreshButton.setIcon(IconLoader.getIcon("/com/fr/design/mainframe/alphafine/images/smallsearch.png"));
refreshButton.setToolTipText(Inter.getLocText("FR-Designer_AlphaFine"));
refreshButton.set4ToolbarButton();
refreshButton.setRolloverEnabled(false);

7
designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java

@ -19,7 +19,12 @@ import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import java.io.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

29
designer/src/com/fr/design/mainframe/alphafine/search/manager/RecentSearchManager.java

@ -10,6 +10,7 @@ import com.fr.design.mainframe.alphafine.cell.model.ActionModel;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.toolbar.UpdateActionManager;
import com.fr.file.XMLFileManager;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
@ -26,8 +27,17 @@ import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLTools;
import com.fr.stable.xml.XMLableReader;
import java.io.*;
import java.util.*;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.StringReader;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* Created by XiaXiang on 2017/5/15.
@ -220,21 +230,24 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
recentModelList = recentKVModelMap.get(searchText);
SearchResult resultModelList = recentModelList;
Iterator<AlphaCellModel> modelIterator = resultModelList.iterator();
SearchResult searchResult = new SearchResult();
while (modelIterator.hasNext()) {
AlphaCellModel model = modelIterator.next();
if (model.getType() == CellType.ACTION && !((ActionModel) model).getAction().isEnabled()) {
modelIterator.remove();
if (model.getType() == CellType.ACTION && !UpdateActionManager.getUpdateActionManager().isEnable(((ActionModel) model).getAction())) {
continue;
} else {
searchResult.add(model);
}
}
Collections.sort(resultModelList);
int size = resultModelList.size();
Collections.sort(searchResult);
int size = searchResult.size();
if (size > MAX_SIZE) {
SearchResult result = new SearchResult();
result.addAll(resultModelList.subList(0, MAX_SIZE));
result.addAll(searchResult.subList(0, MAX_SIZE));
return result;
}
return resultModelList;
return searchResult;
}
}
return recentModelList;

12
designer_base/src/com/fr/design/mainframe/toolbar/UpdateActionManager.java

@ -1,5 +1,8 @@
package com.fr.design.mainframe.toolbar;
import com.fr.design.actions.UpdateAction;
import com.fr.general.ComparatorUtils;
import java.util.List;
/**
@ -23,4 +26,13 @@ public class UpdateActionManager {
public void setUpdateActions(List<UpdateActionModel> updateActions) {
this.updateActions = updateActions;
}
public boolean isEnable(UpdateAction updateAction) {
for (UpdateActionModel action : updateActions) {
if (ComparatorUtils.equals(updateAction.getName(), action.getActionName()) && action.getAction().isEnabled()) {
return true;
}
}
return false;
}
}

Loading…
Cancel
Save