yaoh.wu
6 years ago
23 changed files with 327 additions and 97 deletions
@ -0,0 +1,60 @@ |
|||||||
|
package com.fr.base.vcs; |
||||||
|
|
||||||
|
import com.fr.design.base.mode.DesignModeContext; |
||||||
|
|
||||||
|
/** |
||||||
|
* 兼容 |
||||||
|
* |
||||||
|
* @deprecated user {@link com.fr.design.base.mode.DesignerMode} and {@link DesignModeContext} instead |
||||||
|
*/ |
||||||
|
@Deprecated |
||||||
|
public enum DesignerMode { |
||||||
|
|
||||||
|
NORMAL, |
||||||
|
VCS, |
||||||
|
AUTHORITY; |
||||||
|
|
||||||
|
|
||||||
|
public static boolean isVcsMode() { |
||||||
|
return DesignModeContext.isVcsMode(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public static void setMode(DesignerMode mode) { |
||||||
|
|
||||||
|
switch (mode) { |
||||||
|
case AUTHORITY: |
||||||
|
DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.AUTHORITY); |
||||||
|
break; |
||||||
|
case VCS: |
||||||
|
DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.VCS); |
||||||
|
break; |
||||||
|
case NORMAL: |
||||||
|
default: |
||||||
|
DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.NORMAL); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static DesignerMode getMode() { |
||||||
|
switch (DesignModeContext.getMode()) { |
||||||
|
case VCS: |
||||||
|
return VCS; |
||||||
|
case AUTHORITY: |
||||||
|
return AUTHORITY; |
||||||
|
case NORMAL: |
||||||
|
default: |
||||||
|
return NORMAL; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 是否为权限编辑 |
||||||
|
* |
||||||
|
* @return 是否为权限编辑 |
||||||
|
*/ |
||||||
|
public static boolean isAuthorityEditing() { |
||||||
|
return DesignModeContext.isAuthorityEditing(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,42 @@ |
|||||||
|
package com.fr.design.base.mode; |
||||||
|
|
||||||
|
import static com.fr.design.base.mode.DesignerMode.AUTHORITY; |
||||||
|
|
||||||
|
public class DesignModeContext { |
||||||
|
|
||||||
|
private static DesignerMode mode = DesignerMode.NORMAL; |
||||||
|
|
||||||
|
public static void switchTo(DesignerMode mode) { |
||||||
|
DesignModeContext.mode = mode; |
||||||
|
} |
||||||
|
|
||||||
|
public static DesignerMode getMode() { |
||||||
|
return mode; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 是否是版本控制模式 |
||||||
|
* |
||||||
|
* @return 是否是版本控制模式 |
||||||
|
*/ |
||||||
|
public static boolean isVcsMode() { |
||||||
|
return mode == DesignerMode.VCS; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @return 是否是禁止拷贝剪切模式 |
||||||
|
*/ |
||||||
|
public static boolean isBanCopyAndCut() { |
||||||
|
return mode == DesignerMode.BAN_COPY_AND_CUT; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 是否为权限编辑 |
||||||
|
* |
||||||
|
* @return 是否为权限编辑 |
||||||
|
*/ |
||||||
|
public static boolean isAuthorityEditing() { |
||||||
|
return mode == AUTHORITY; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,8 @@ |
|||||||
|
package com.fr.design.base.mode; |
||||||
|
|
||||||
|
public enum DesignerMode { |
||||||
|
NORMAL, |
||||||
|
BAN_COPY_AND_CUT, |
||||||
|
VCS, |
||||||
|
AUTHORITY |
||||||
|
} |
@ -1,33 +1,33 @@ |
|||||||
package com.fr.design.designer.beans.actions; |
package com.fr.design.designer.beans.actions; |
||||||
|
|
||||||
import java.awt.event.KeyEvent; |
|
||||||
|
|
||||||
import javax.swing.KeyStroke; |
|
||||||
|
|
||||||
import com.fr.base.BaseUtils; |
import com.fr.base.BaseUtils; |
||||||
|
import com.fr.design.base.mode.DesignModeContext; |
||||||
import com.fr.design.designer.beans.actions.behavior.ComponentEnable; |
import com.fr.design.designer.beans.actions.behavior.ComponentEnable; |
||||||
|
|
||||||
import com.fr.design.mainframe.FormDesigner; |
import com.fr.design.mainframe.FormDesigner; |
||||||
|
|
||||||
|
import javax.swing.KeyStroke; |
||||||
|
import java.awt.event.KeyEvent; |
||||||
|
|
||||||
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; |
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; |
||||||
|
|
||||||
public class CutAction extends FormWidgetEditAction { |
public class CutAction extends FormWidgetEditAction { |
||||||
|
|
||||||
public CutAction(FormDesigner t) { |
public CutAction(FormDesigner t) { |
||||||
super(t); |
super(t); |
||||||
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_M_Edit_Cut")); |
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_M_Edit_Cut")); |
||||||
this.setMnemonic('T'); |
this.setMnemonic('T'); |
||||||
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/cut.png")); |
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/cut.png")); |
||||||
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER)); |
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER)); |
||||||
this.setUpdateBehavior(new ComponentEnable()); |
this.setUpdateBehavior(new ComponentEnable()); |
||||||
} |
this.setEnabled(!DesignModeContext.isBanCopyAndCut()); |
||||||
|
} |
||||||
@Override |
|
||||||
public boolean executeActionReturnUndoRecordNeeded() { |
@Override |
||||||
FormDesigner editPane = getEditingComponent(); |
public boolean executeActionReturnUndoRecordNeeded() { |
||||||
if (editPane == null) { |
FormDesigner editPane = getEditingComponent(); |
||||||
return false; |
if (editPane == null) { |
||||||
} |
return false; |
||||||
return editPane.cut(); |
} |
||||||
} |
return editPane.cut(); |
||||||
|
} |
||||||
} |
} |
Loading…
Reference in new issue