zpc 8 years ago
parent
commit
0ecf91b36f
  1. 10
      designer/src/com/fr/design/webattr/EditToolBar.java
  2. 3
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java
  3. 7
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java
  4. 50
      designer_form/src/com/fr/design/mainframe/EditingMouseListener.java
  5. 7
      designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java
  6. 15
      sonar-project.properties
  7. 1
      start.bat

10
designer/src/com/fr/design/webattr/EditToolBar.java

@ -63,16 +63,8 @@ public class EditToolBar extends BasicPane {
private ListSelectionListener listSelectionListener = new ListSelectionListener() { private ListSelectionListener listSelectionListener = new ListSelectionListener() {
public void valueChanged(ListSelectionEvent evt) { public void valueChanged(ListSelectionEvent evt) {
if (lastButton != null && lastButton.getWidget() instanceof Button) { if (lastButton != null) {
if (!((list.getSelectedValue() instanceof ToolBarButton)
&& ((ToolBarButton)(list.getSelectedValue())).getWidget() instanceof CustomToolBarButton)) {
lastButton.setWidget(bp.update()); lastButton.setWidget(bp.update());
} else {
((Button) lastButton.getWidget()).setShowIcon(bp.icon.isSelected());
((Button) lastButton.getWidget()).setShowText(bp.text.isSelected());
((Button) lastButton.getWidget()).setText(bp.nameField.getText());
((Button) lastButton.getWidget()).setIconName(bp.iconPane.update());
}
} }
if (list.getSelectedValue() instanceof ToolBarButton) { if (list.getSelectedValue() instanceof ToolBarButton) {
lastButton = (ToolBarButton) list.getSelectedValue(); lastButton = (ToolBarButton) list.getSelectedValue();

3
designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java

@ -219,8 +219,7 @@ public class XWCardLayout extends XLayoutContainer {
* *
*/ */
protected void setWrapperName(XLayoutContainer parentPanel, String widgetName) { protected void setWrapperName(XLayoutContainer parentPanel, String widgetName) {
//先随便set一个, 以后还是要隐藏的 parentPanel.toData().setWidgetName("tablayout" + widgetName.replaceAll(createDefaultName(),""));
parentPanel.toData().setWidgetName("border_card_" + widgetName);
} }
/** /**

7
designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java

@ -11,6 +11,7 @@ import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWBorderLayout; import com.fr.design.designer.creator.XWBorderLayout;
import com.fr.design.icon.IconPathConstants; import com.fr.design.icon.IconPathConstants;
@ -263,6 +264,12 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
*/ */
@Override @Override
public XLayoutContainer getTopLayout() { public XLayoutContainer getTopLayout() {
XLayoutContainer xTopLayout = XCreatorUtils.getParentXLayoutContainer(this).getTopLayout();
if (xTopLayout != null && !xTopLayout.isEditable()){
return xTopLayout;
}
else{
return this; return this;
} }
}
} }

50
designer_form/src/com/fr/design/mainframe/EditingMouseListener.java

@ -1,9 +1,6 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import java.awt.Color; import java.awt.*;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.Rectangle;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import javax.swing.*; import javax.swing.*;
@ -326,10 +323,12 @@ public class EditingMouseListener extends MouseInputAdapter {
if (designer.getCursor().getType() == Cursor.HAND_CURSOR) { if (designer.getCursor().getType() == Cursor.HAND_CURSOR) {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
} }
if (e.getX() > (parent.getX() + parent.getWidth() / 2 - EDIT_BTN_WIDTH / 2 - GAP) int minX = getParentPositionX(parent, parent.getX()) + parent.getWidth() / 2;
&& e.getX() < (parent.getX() + parent.getWidth() / 2 + EDIT_BTN_WIDTH / 2 + GAP)) { int minY = getParentPositionY(parent, parent.getY()) + parent.getHeight() / 2;
if (e.getY() > (parent.getY() + parent.getHeight() / 2 - EDIT_BTN_HEIGHT / 2 - GAP) int offsetX = EDIT_BTN_WIDTH / 2 + GAP;
&& e.getY() < (parent.getY() + parent.getHeight() / 2 + EDIT_BTN_HEIGHT / 2 + GAP + designer.getParaHeight())) { int offsetY = EDIT_BTN_HEIGHT / 2 + GAP;
if (e.getX() > (minX - offsetX) && e.getX() < (minX + offsetX)) {
if (e.getY() > (minY - offsetY) && e.getY() < (minY + offsetY + designer.getParaHeight())) {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
} }
} }
@ -417,11 +416,43 @@ public class EditingMouseListener extends MouseInputAdapter {
designer.repaint(); designer.repaint();
} }
//当前编辑的组件是在布局中,鼠标点击布局外部,需要一次性将布局及其父布局都置为不可编辑
private void setTopLayoutUnEditable(XLayoutContainer clickedTopLayout, XLayoutContainer clickingTopLayout){
//双击的前后点击click为相同对象,过滤掉
if (clickedTopLayout == null || clickedTopLayout == clickingTopLayout){
return;
}
//位于同一层级的控件,父布局相同,过滤掉
if (clickingTopLayout != null && clickedTopLayout.getParent() == clickingTopLayout.getParent()){
return;
}
//前后点击的位于不同层级,要置为不可编辑
XLayoutContainer xLayoutContainer = (XLayoutContainer)clickedTopLayout.getParent();
if (xLayoutContainer == clickingTopLayout){
return;
}
if (xLayoutContainer != null){
xLayoutContainer.setEditable(false);
setTopLayoutUnEditable((XLayoutContainer) clickedTopLayout.getParent(), clickingTopLayout);
}
}
private boolean isCreatorInLayout(XCreator creator, XCreator layout){
if (creator == layout){
return true;
}
if(layout.getParent() != null){
return isCreatorInLayout(creator, (XCreator)layout.getParent());
}
return false;
}
private XCreator processTopLayoutMouseClick(XCreator creator){ private XCreator processTopLayoutMouseClick(XCreator creator){
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(creator).getTopLayout(); XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(creator).getTopLayout();
if(topLayout != null){ if(topLayout != null){
if (clickTopLayout != null && clickTopLayout != topLayout){ if (clickTopLayout != null && clickTopLayout != topLayout && !isCreatorInLayout(clickTopLayout, topLayout)){
clickTopLayout.setEditable(false); clickTopLayout.setEditable(false);
setTopLayoutUnEditable(clickTopLayout, topLayout);
} }
clickTopLayout = topLayout; clickTopLayout = topLayout;
if(!topLayout.isEditable()) { if(!topLayout.isEditable()) {
@ -431,6 +462,7 @@ public class EditingMouseListener extends MouseInputAdapter {
else{ else{
if(clickTopLayout != null){ if(clickTopLayout != null){
clickTopLayout.setEditable(false); clickTopLayout.setEditable(false);
setTopLayoutUnEditable(clickTopLayout, null);
} }
} }

7
designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java

@ -9,6 +9,7 @@ import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDragEvent; import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent; import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent; import java.awt.dnd.DropTargetEvent;
import java.util.ArrayList;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JWindow; import javax.swing.JWindow;
@ -85,8 +86,12 @@ public class FormCreatorDropTarget extends DropTarget {
if (success) { if (success) {
// 如果添加成功,则触发相应事件 // 如果添加成功,则触发相应事件
XCreator xCreator = container.acceptType(XWParameterLayout.class) ? designer.getParaComponent() : designer.getRootComponent(); XCreator xCreator = container.acceptType(XWParameterLayout.class) ? designer.getParaComponent() : designer.getRootComponent();
//SetSelection时要确保选中的是最顶层的布局
//tab布局添加的时候是初始化了XWCardLayout,实际上最顶层的布局是XWCardMainBorderLayout
XCreator addingXCreator = addingModel.getXCreator();
Widget widget = (addingXCreator.getTopLayout() != null) ? (addingXCreator.getTopLayout().toData()) : addingXCreator.toData();
designer.getSelectionModel().setSelectedCreators( designer.getSelectionModel().setSelectedCreators(
FormSelectionUtils.rebuildSelection(xCreator, new Widget[]{addingModel.getXCreator().toData()})); FormSelectionUtils.rebuildSelection(xCreator, new Widget[]{widget}));
designer.getEditListenerTable().fireCreatorModified(addingModel.getXCreator(), DesignerEvent.CREATOR_ADDED); designer.getEditListenerTable().fireCreatorModified(addingModel.getXCreator(), DesignerEvent.CREATOR_ADDED);
} else { } else {
Toolkit.getDefaultToolkit().beep(); Toolkit.getDefaultToolkit().beep();

15
sonar-project.properties

@ -0,0 +1,15 @@
# must be unique in a given SonarQube instance
sonar.projectKey=finereport.design
# this is the name displayed in the SonarQube UI
sonar.projectName=finereport.design
sonar.projectVersion=1.0
sonar.branch=dev
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# Since SonarQube 4.2, this property is optional if sonar.modules is set.
# If not set, SonarQube starts looking for source code from the directory containing
# the sonar-project.properties file.
sonar.sources=.
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8

1
start.bat

@ -0,0 +1 @@
sonar-scanner
Loading…
Cancel
Save