Browse Source

REPORT-51442 菜单栏和数据集面板灰化问题

zheng-1641779399395
hades 4 years ago
parent
commit
15fd3a259d
  1. 26
      designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java
  2. 14
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java
  3. 2
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  4. 17
      designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java
  5. 6
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  6. 14
      designer-base/src/main/java/com/fr/design/menu/MenuDef.java
  7. 25
      designer-base/src/main/java/com/fr/design/menu/ToolBarDef.java

26
designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java

@ -6,7 +6,6 @@ import com.fr.data.TableDataSource;
import com.fr.data.api.StoreProcedureAssist;
import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.design.DesignModelAdapter;
import com.fr.design.actions.ForbiddenUpdateAction;
import com.fr.design.actions.UpdateAction;
import com.fr.design.data.datapane.TableDataCreatorProducer;
import com.fr.design.data.datapane.TableDataNameObjectCreator;
@ -25,16 +24,20 @@ import com.fr.design.gui.ibutton.UIHeadGroup;
import com.fr.design.gui.ibutton.UILockButton;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.i18n.Toolkit;
import com.fr.design.icon.IconPathConstants;
import com.fr.design.mainframe.DockingView;
import com.fr.design.menu.LineSeparator;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.ToolBarDef;
import com.fr.general.ComparatorUtils;
import com.fr.general.NameObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
import java.util.HashSet;
import java.util.Set;
import javax.swing.AbstractButton;
import javax.swing.Action;
import javax.swing.DefaultCellEditor;
@ -61,6 +64,16 @@ import java.util.Objects;
* Time: 16:23
*/
public abstract class BasicTableDataTreePane extends DockingView implements ResponseDataSourceChange {
private static final Set<String> FORBIDDEN_SET = new HashSet<>();
static {
FORBIDDEN_SET.add(Toolkit.i18nText("Fine-Design_Basic_Edit"));
FORBIDDEN_SET.add(Toolkit.i18nText("Fine-Design_Basic_Remove"));
FORBIDDEN_SET.add(Toolkit.i18nText("Fine-Design_Basic_Preview"));
FORBIDDEN_SET.add(Toolkit.i18nText("Fine-Design_Basic_Action_Add"));
}
protected static final int PROCEDURE_NAME_INDEX = 4;
protected static final int TEMPLATE_TABLE_DATA = 0;
protected static final int SERVER_TABLE_DATA = 1;
@ -69,6 +82,7 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp
protected UIHeadGroup buttonGroup;
protected String[] allDSNames;
protected ConnectionTableAction connectionTableAction;
protected ToolBarDef toolbarDef;
private String type = "";
@ -399,7 +413,7 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp
return prefix + count;
}
protected class PreviewTableDataAction extends ForbiddenUpdateAction {
protected class PreviewTableDataAction extends UpdateAction {
private TableDataTree dataTree;
public PreviewTableDataAction(TableDataTree dataTree) {
@ -482,4 +496,12 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp
}
public void refreshToolBar() {
toolbarDef.refreshToolBar(FORBIDDEN_SET);
}
public void checkEnable() {
}
}

14
designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java

@ -1,12 +1,10 @@
package com.fr.design.data.datapane;
import com.fr.base.BaseUtils;
import com.fr.base.TableData;
import com.fr.data.TableDataSource;
import com.fr.data.impl.TableDataSourceDependent;
import com.fr.design.DesignModelAdapter;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.ForbiddenUpdateAction;
import com.fr.design.actions.UpdateAction;
import com.fr.design.constants.UIConstants;
import com.fr.design.data.BasicTableDataTreePane;
@ -102,7 +100,7 @@ public class TableDataTreePane extends BasicTableDataTreePane {
removeAction = new RemoveAction();
previewTableDataAction = new PreviewTableDataAction(dataTree);
connectionTableAction = new ConnectionTableAction();
ToolBarDef toolbarDef = new ToolBarDef();
toolbarDef = new ToolBarDef();
toolbarDef.addShortCut(addMenuDef, SeparatorDef.DEFAULT, editAction, removeAction, SeparatorDef.DEFAULT, previewTableDataAction, connectionTableAction);
UIToolbar toolBar = ToolBarDef.createJToolBar();
toolBar.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.TOOLBAR_BORDER_COLOR));
@ -244,7 +242,7 @@ public class TableDataTreePane extends BasicTableDataTreePane {
dg.setVisible(true);
}
private class EditAction extends ForbiddenUpdateAction {
private class EditAction extends UpdateAction {
public EditAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit"));
this.setMnemonic('E');
@ -261,7 +259,7 @@ public class TableDataTreePane extends BasicTableDataTreePane {
}
}
private class RemoveAction extends ForbiddenUpdateAction {
private class RemoveAction extends UpdateAction {
public RemoveAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remove"));
@ -343,8 +341,10 @@ public class TableDataTreePane extends BasicTableDataTreePane {
dataTree.refresh();
}
@Override
public void checkEnable() {
this.checkButtonEnabled();
}
public void addDataPane(final AbstractTableDataPane<?> uPanel, String paneName) {
final NamePane nPanel = uPanel.asNamePane();

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

@ -12,6 +12,7 @@ import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.constants.UIConstants;
import com.fr.design.data.BasicTableDataTreePane;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.dialog.FineJOptionPane;
@ -821,6 +822,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
((UIToolbar ) toolbarComponent).refreshUIToolBar();
}
combineUp.refreshUIToolBar();
this.ad.updateEnable();
}
public JComponent getToolbarComponent() {

17
designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java

@ -6,12 +6,14 @@ package com.fr.design.mainframe;
import com.fr.base.iofile.attr.DesignBanCopyAttrMark;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.base.mode.DesignerMode;
import com.fr.design.data.BasicTableDataTreePane;
import com.fr.design.dialog.BasicPane;
import com.fr.design.event.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener;
import java.awt.BorderLayout;
import java.awt.Component;
import javax.swing.JComponent;
import javax.swing.JLayeredPane;
@ -97,6 +99,11 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener
DesignerContext.getDesignerFrame().refreshUIToolBar();
DesignerFrameFileDealerPane.getInstance().stateChange();
EastRegionContainerPane.getInstance().updateAllPropertyPane();
JComponent downPane = WestRegionContainerPane.getInstance().getDownPane();
if (downPane instanceof BasicTableDataTreePane) {
BasicTableDataTreePane dataTreePane = (BasicTableDataTreePane) downPane;
dataTreePane.refreshToolBar();
}
checkLoadingPane();
layeredPane.moveToFront(loadingPane);
}
@ -110,12 +117,22 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener
layeredPane.moveToFront(transparentPane);
DesignerContext.getDesignerFrame().refreshUIToolBar();
EastRegionContainerPane.getInstance().updateAllPropertyPane();
JComponent downPane = WestRegionContainerPane.getInstance().getDownPane();
if (downPane instanceof BasicTableDataTreePane) {
BasicTableDataTreePane dataTreePane = (BasicTableDataTreePane) downPane;
dataTreePane.refreshToolBar();
}
}
public void hideCover() {
transparentPane.stop();
layeredPane.moveToFront(component);
EastRegionContainerPane.getInstance().updateAllPropertyPane();
JComponent downPane = WestRegionContainerPane.getInstance().getDownPane();
if (downPane instanceof BasicTableDataTreePane) {
BasicTableDataTreePane dataTreePane = (BasicTableDataTreePane) downPane;
dataTreePane.checkEnable();
}
}
protected JTemplate<?, ?> getSelectedJTemplate() {

6
designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java

@ -169,6 +169,12 @@ public abstract class ToolBarMenuDock {
}
}
public void updateEnable() {
for (int i = 0, count = ArrayUtils.getLength(menus); i < count; i++) {
menus[i].updateEnable();
}
}
/**
* 更新toolbar
*/

14
designer-base/src/main/java/com/fr/design/menu/MenuDef.java

@ -293,6 +293,10 @@ public class MenuDef extends ShortCut {
}
}
public void updateEnable() {
setEnabled(checkEnable());
}
/**
* 更新菜单
*
@ -406,14 +410,13 @@ public class MenuDef extends ShortCut {
toolBar.add(this.createUIButton());
}
private boolean checkEnable(JComponent component) {
if (FORBIDDEN_SET.contains(component.getName())) {
private boolean checkEnable() {
if (FORBIDDEN_SET.contains(this.getName())) {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
boolean flag = true;
if (template != null) {
flag = template.checkEnable();
}
component.setEnabled(flag);
if (!flag) {
return false;
}
@ -442,9 +445,6 @@ public class MenuDef extends ShortCut {
if (!(source instanceof JMenu)) {
return;
}
if (!checkEnable(createJMenu())) {
return;
}
MenuDef.this.updateMenu();
}
};
@ -454,7 +454,7 @@ public class MenuDef extends ShortCut {
public void mouseReleased(MouseEvent evt) {
Object source = evt.getSource();
UIButton button = (UIButton) source;
if (!checkEnable(button)) {
if (!button.isEnabled()) {
return;
}
if (isEastAttr) {

25
designer-base/src/main/java/com/fr/design/menu/ToolBarDef.java

@ -1,7 +1,11 @@
package com.fr.design.menu;
import com.fr.design.actions.UpdateAction;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.itoolbar.UIToolBarUI;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.mainframe.JTemplate;
import java.util.Set;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@ -82,4 +86,25 @@ public class ToolBarDef {
}
}
public void refreshToolBar(Set<String> set) {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
for (int i = 0; i < getShortCutCount(); i++) {
ShortCut shortCut = getShortCut(i);
if (shortCut instanceof MenuDef) {
MenuDef menuDef = (MenuDef) shortCut;
if (set.contains(menuDef.getName())) {
menuDef.setEnabled(template.checkEnable());
}
}
if (shortCut instanceof UpdateAction) {
UpdateAction updateAction = (UpdateAction) shortCut;
if (set.contains(updateAction.getName())) {
updateAction.setEnabled(template.checkEnable());
}
}
}
}
}
}
Loading…
Cancel
Save