ju 7 years ago
parent
commit
a33416fb4c
  1. 6
      designer-base/src/com/fr/design/DesignState.java
  2. 2
      designer-base/src/com/fr/design/DesignerEnvManager.java
  3. 10
      designer-base/src/com/fr/design/mainframe/DesignerFrame.java
  4. 121
      designer-base/src/com/fr/design/mainframe/TemplatePane.java
  5. 4
      designer-base/src/com/fr/file/FileNodeFILE.java
  6. 15
      designer-realize/src/com/fr/start/EnvSwitcher.java

6
designer-base/src/com/fr/design/DesignState.java

@ -39,9 +39,9 @@ public class DesignState {
public DesignState(ToolBarMenuDockPlus plus) {
designState = plus.getMenuState();
if (WorkContext.getCurrent().isLocal()) {
designState += REMOTE;
}
// if (WorkContext.getCurrent().isLocal()) {
// designState += REMOTE;
// }
// isRoot = env != null && env.isRoot();
isAuthority = BaseUtils.isAuthorityEditing();
}

2
designer-base/src/com/fr/design/DesignerEnvManager.java

@ -190,7 +190,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
return;
}
String installHome = StableUtils.getInstallHome();
if (installHome != null) {
if (installHome != null && !".".equals(installHome)) {
String name = Inter.getLocText("FR-Engine_DEFAULT");
String envPath = StableUtils.pathJoin(new String[]{installHome, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME});
designerEnvManager.putEnv(name, DesignerWorkspaceInfo.createLocal(name, envPath));

10
designer-base/src/com/fr/design/mainframe/DesignerFrame.java

@ -13,7 +13,6 @@ import com.fr.design.actions.core.ActionFactory;
import com.fr.design.constants.UIConstants;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.event.DesignerOpenedListener;
import com.fr.design.event.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener;
@ -54,6 +53,7 @@ import com.fr.stable.StableUtils;
import com.fr.stable.image4j.codec.ico.ICODecoder;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import javax.swing.*;
import javax.swing.border.MatteBorder;
@ -650,15 +650,15 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
defaultTitleSB.append(" ");
// james:标识登录的用户和登录的ENV
String envName = DesignerEnvManager.getEnvManager().getCurEnvName();
DesignerWorkspaceInfo env = DesignerEnvManager.getEnvManager().getWorkspaceInfo(envName);
if (env != null) {
defaultTitleSB.append(WorkContext.getCurrent().getDescription());
Workspace workspace = WorkContext.getCurrent();
if (workspace != null) {
defaultTitleSB.append(workspace.getDescription());
if (editingTemplate != null) {
String path = editingTemplate.getEditingFILE().getPath();
if (!editingTemplate.getEditingFILE().exists()) {
path = FILEFactory.MEM_PREFIX + path;
} else if (path.startsWith(ProjectConstants.REPORTLETS_NAME)) {
path = env.getPath() + File.separator + path;
path = workspace.getPath() + File.separator + path;
}
defaultTitleSB.append(" " + path);
}

121
designer-base/src/com/fr/design/mainframe/TemplatePane.java

@ -29,49 +29,63 @@ import java.awt.event.MouseListener;
//TODO: august TemplatePane和TemplateTreePane最好合并成一个类
public class TemplatePane extends JPanel implements MouseListener {
private static final long NUM = 1L;
private static int NUM200 = 200;
public static TemplatePane getInstance() {
return HOLDER.singleton;
}
private static class HOLDER {
private static TemplatePane singleton = new TemplatePane();
}
private static final long serialVersionUID = 2108412478281713143L;
public static final int HEIGHT = 23;// 最好和日志的高度统一 用同一个变量
private static javax.swing.Icon leftIcon = BaseUtils.readIcon("/com/fr/design/images/docking/left.png");
;
private static javax.swing.Icon rightIcon = BaseUtils.readIcon("/com/fr/design/images/docking/right.png");
;
private boolean isExpanded = false;
private UIButton editButton;
private UILabel envLabel;
private TemplatePane() {
super();
this.initComponents();
this.setFocusable(true);
this.addMouseListener(this);
isExpanded = DesignerEnvManager.getEnvManager().isTemplateTreePaneExpanded();
// TemplateTreePane.getInstance().setVisible(isExpanded);
TemplateTreePane.getInstance().setVisible(isExpanded);
TemplateTreePane.getInstance().setVisible(true);
}
private void initComponents() {
GeneralContext.addEnvChangedListener(new EnvChangedListener() {
public void envChanged() {
setJLabel(DesignerEnvManager.getEnvManager().getCurEnvName());
}
});
this.setLayout(new BorderLayout(25, 0));
editButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/control/control-center2.png")) {
private static final long serialVersionUID = NUM;
@Override
public Point getToolTipLocation(MouseEvent event) {
return new Point(25, 2);
}
};
@ -83,7 +97,9 @@ public class TemplatePane extends JPanel implements MouseListener {
this.add(new UILabel(" "), BorderLayout.WEST);
this.add(editButton, BorderLayout.EAST);
editButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
editItems();
}
});
@ -92,35 +108,41 @@ public class TemplatePane extends JPanel implements MouseListener {
setJLabel(DesignerEnvManager.getEnvManager().getCurEnvName());
this.add(envLabel, BorderLayout.CENTER);
}
/**
* 是否可扩展
*
* @return 同上
*/
public boolean IsExpanded() {
return this.isExpanded;
}
public void setExpand(boolean b) {
this.isExpanded = b;
this.repaint();
}
private boolean envListOkAction(EnvListPane envListPane) {
final String selectedName = envListPane.updateEnvManager();
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(selectedName);
GeneralContext.fireEnvWillChangeListener();
try {
WorkContext.switchTo(DesignerWorkspaceGenerator.generate(selectedEnv), new WorkContextCallback() {
@Override
public void fail() {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"}));
}
@Override
public void success() {
DesignUtils.refreshDesignerFrame();
}
});
@ -140,61 +162,71 @@ public class TemplatePane extends JPanel implements MouseListener {
}
return true;
}
private String getDesignerVersion(DesignerWorkspaceInfo selectedEnv) {
// return selectedEnv.getDesignerVersion();
throw new UnsupportedOperationException("unsupport now");
}
/**
* 编辑items
*/
public void editItems() {
final EnvListPane envListPane = new EnvListPane();
final BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame()));
envListPane.populateEnvManager(envLabel.getText());
envListDialog.addDialogActionListener(new DialogActionAdapter() {
public void doOk() {
envListOkAction(envListPane);
}
public void doCancel() {
envListDialog.setVisible(false);
}
});
envListDialog.setVisible(true);
}
private void setJLabel(String name) {
private void setJLabel(String name) {
DesignerWorkspaceInfo config = DesignerEnvManager.getEnvManager().getWorkspaceInfo(name);
switch (config.getType()) {
case Remote: {
envLabel.setIcon(IOUtils.readIcon("com/fr/design/images/data/bind/localconnect.png"));
break;
}
case Local: {
envLabel.setIcon(IOUtils.readIcon("com/fr/design/images/data/bind/distanceconnect.png"));
break;
if (config != null) {
switch (config.getType()) {
case Remote: {
envLabel.setIcon(IOUtils.readIcon("com/fr/design/images/data/bind/localconnect.png"));
break;
}
case Local: {
envLabel.setIcon(IOUtils.readIcon("com/fr/design/images/data/bind/distanceconnect.png"));
break;
}
}
}
envLabel.setText(name);
envLabel.repaint();
}
@Override
public Dimension getPreferredSize() {
return new Dimension(250, HEIGHT);
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
paintBackgroundIcon(g);
}
private void paintBackgroundIcon(Graphics g) {
int w = this.getWidth();
int h = this.getHeight();
Graphics2D g2d = (Graphics2D) g;
@ -209,9 +241,9 @@ public class TemplatePane extends JPanel implements MouseListener {
g2d.drawLine(w - 1, 2, w - 1, h - 1);
Icon icon = !isExpanded ? leftIcon : rightIcon;
icon.paintIcon(this, g2d, 4, 4);
}
/**
* 鼠标点击
*
@ -219,8 +251,9 @@ public class TemplatePane extends JPanel implements MouseListener {
*/
@Override
public void mouseClicked(MouseEvent e) {
}
/**
* 鼠标按下
*
@ -228,6 +261,7 @@ public class TemplatePane extends JPanel implements MouseListener {
*/
@Override
public void mousePressed(MouseEvent e) {
if (e.getX() < NUM200) {
isExpanded = !isExpanded;
TemplateTreePane.getInstance().setVisible(isExpanded);
@ -235,7 +269,7 @@ public class TemplatePane extends JPanel implements MouseListener {
DesignerEnvManager.getEnvManager().setTemplateTreePaneExpanded(isExpanded);
}
}
/**
* 鼠标放开
*
@ -243,8 +277,9 @@ public class TemplatePane extends JPanel implements MouseListener {
*/
@Override
public void mouseReleased(MouseEvent e) {
}
/**
* 鼠标进入
*
@ -252,8 +287,9 @@ public class TemplatePane extends JPanel implements MouseListener {
*/
@Override
public void mouseEntered(MouseEvent e) {
}
/**
* 鼠标离开
*
@ -261,28 +297,33 @@ public class TemplatePane extends JPanel implements MouseListener {
*/
@Override
public void mouseExited(MouseEvent e) {
}
/**
* 处理异常
*/
public void dealEvnExceptionWhenStartDesigner() {
final EnvListPane envListPane = new EnvListPane();
envListPane.populateEnvManager(envLabel.getText());
BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame()));
envListDialog.addDialogActionListener(new DialogActionAdapter() {
public void doOk() {
if (!envListOkAction(envListPane)) {
System.exit(0);
}
}
public void doCancel() {
System.exit(0);
}
});
envListDialog.setVisible(true);
}
}

4
designer-base/src/com/fr/file/FileNodeFILE.java

@ -200,7 +200,7 @@ public class FileNodeFILE implements FILE {
}
try {
return WorkContext.getWorkResource().create(StableUtils.pathJoin(node.getEnvPath(), name));
return WorkContext.getWorkResource().createFile(StableUtils.pathJoin(node.getEnvPath(), name));
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false;
@ -267,7 +267,7 @@ public class FileNodeFILE implements FILE {
}
try {
return WorkContext.getWorkResource().create(node.getEnvPath());
return WorkContext.getWorkResource().createFile(node.getEnvPath());
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false;

15
designer-realize/src/com/fr/start/EnvSwitcher.java

@ -13,14 +13,25 @@ import com.fr.workspace.Workspace;
public class EnvSwitcher {
public void switch2LastEnv() {
try {
String current = DesignerEnvManager.getEnvManager().getCurEnvName();
Workspace workspace = DesignerWorkspaceGenerator.generate(DesignerEnvManager.getEnvManager().getWorkspaceInfo(current));
if (workspace == null) {
TemplatePane.getInstance().dealEvnExceptionWhenStartDesigner();
}
WorkContext.switchTo(workspace);
} catch (Exception e) {
} catch (Throwable e) {
TemplatePane.getInstance().dealEvnExceptionWhenStartDesigner();
}
}
/**
* 找不到默认的工作空间时让用户手动选择一个
*/
private Workspace chooseWorkspace() {
return null;
}
}

Loading…
Cancel
Save