forked from fanruan/design
loy
4 years ago
52 changed files with 51 additions and 361 deletions
@ -1,4 +1,4 @@
|
||||
package com.fr.plugin.designer.menu; |
||||
package com.fr.design.actions.file; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.actions.UpdateAction; |
@ -1,4 +1,4 @@
|
||||
package com.fr.plugin.designer.menu; |
||||
package com.fr.design.actions.server; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.actions.UpdateAction; |
@ -1,51 +0,0 @@
|
||||
package com.fr.plugin.designer; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.base.extension.FileExtension; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.fun.impl.AbstractReportSupportedFileUIProvider; |
||||
import com.fr.design.mainframe.JTemplate; |
||||
import com.fr.file.FILEChooserPane; |
||||
import com.fr.file.filter.ChooseFileFilter; |
||||
import com.fr.plugin.designer.toolbar.TemplateTransformer; |
||||
import com.fr.stable.ProductConstants; |
||||
|
||||
import javax.swing.Icon; |
||||
|
||||
|
||||
/** |
||||
* Created by kerry on 2019-10-14 |
||||
*/ |
||||
public class EnginexSupportedFileUIImpl extends AbstractReportSupportedFileUIProvider { |
||||
public static final Icon CPTX_ICON = BaseUtils.readIcon("/com/fr/plugin/designer/cptx_file_icon.png"); |
||||
public static final Icon CPTX_LOCKED_ICON = BaseUtils.readIcon("/com/fr/plugin/designer/cptx_file_icon_locked.png"); |
||||
|
||||
@Override |
||||
public void addChooseFileFilter(FILEChooserPane fileChooser, String suffix) { |
||||
String filterDescription = ProductConstants.APP_NAME + Toolkit.i18nText("Fine-Design_Report_Template_File"); |
||||
ChooseFileFilter cptxChooserFilter = new ChooseFileFilter(FileExtension.CPTX, filterDescription); |
||||
fileChooser.addChooseFILEFilter(cptxChooserFilter); |
||||
} |
||||
|
||||
@Override |
||||
public Icon getFileIcon(String path, boolean isShowLock) { |
||||
if (!FileExtension.CPTX.matchExtension(path)) { |
||||
return null; |
||||
} |
||||
if (isShowLock) { |
||||
return CPTX_LOCKED_ICON; |
||||
} |
||||
return CPTX_ICON; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public boolean saveToNewFile(String targetPath, JTemplate jTemplate) { |
||||
if (FileExtension.CPTX.matchExtension(targetPath)) { |
||||
TemplateTransformer.TO_CPTX.transform(jTemplate); |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
} |
@ -1,29 +0,0 @@
|
||||
package com.fr.plugin.designer; |
||||
|
||||
import com.fr.file.FILE; |
||||
import com.fr.nx.cptx.io.handle.impl.AbstractCptxIOProvider; |
||||
|
||||
import java.io.InputStream; |
||||
import java.io.OutputStream; |
||||
|
||||
/** |
||||
* 读写型模板, 用于设计器端增删改模板 |
||||
*/ |
||||
public class WritableCptx extends AbstractCptxIOProvider { |
||||
|
||||
private FILE file; |
||||
|
||||
public WritableCptx(FILE file) { |
||||
this.file = file; |
||||
} |
||||
|
||||
@Override |
||||
public InputStream open() throws Exception { |
||||
return file.asInputStream(); |
||||
} |
||||
|
||||
@Override |
||||
public OutputStream createTemp() throws Exception { |
||||
return file.asOutputStream(); |
||||
} |
||||
} |
@ -1,36 +0,0 @@
|
||||
package com.fr.plugin.designer.menu; |
||||
|
||||
import com.fr.design.fun.impl.AbstractMenuHandler; |
||||
import com.fr.design.menu.ShortCut; |
||||
|
||||
/** |
||||
* Created by kerry on 2019-12-10 |
||||
*/ |
||||
public class BatchCompileMenu extends AbstractMenuHandler { |
||||
private static final int DEFAULT_INSERT_POSITION = 9; |
||||
|
||||
@Override |
||||
public int insertPosition(int total) { |
||||
return DEFAULT_INSERT_POSITION; |
||||
} |
||||
|
||||
@Override |
||||
public boolean insertSeparatorBefore() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public boolean insertSeparatorAfter() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public String category() { |
||||
return FILE; |
||||
} |
||||
|
||||
@Override |
||||
public ShortCut shortcut() { |
||||
return new BatchCompileAction(); |
||||
} |
||||
} |
@ -1,69 +0,0 @@
|
||||
package com.fr.plugin.designer.menu; |
||||
|
||||
import com.fr.design.fun.impl.AbstractMenuHandler; |
||||
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; |
||||
import com.fr.design.menu.ShortCut; |
||||
import com.fr.plugin.designer.JStreamBook; |
||||
|
||||
public class CalculateAttrMenu extends AbstractMenuHandler { |
||||
|
||||
private static final int DEFAULT_INSERT_POSITION = 7; |
||||
|
||||
/** |
||||
* 插入位置 |
||||
* @param total 插入点 |
||||
* |
||||
* @return 插入位置 |
||||
* |
||||
*/ |
||||
public int insertPosition(int total) { |
||||
return DEFAULT_INSERT_POSITION; |
||||
} |
||||
|
||||
/** |
||||
* 在分隔符前插入 |
||||
* |
||||
* @return 是否在分隔符前插入 |
||||
* |
||||
*/ |
||||
public boolean insertSeparatorBefore() { |
||||
return false; |
||||
} |
||||
|
||||
/** |
||||
* 在分隔符后插入 |
||||
* |
||||
* @return 是否在分隔符后插入 |
||||
* |
||||
*/ |
||||
public boolean insertSeparatorAfter() { |
||||
return false; |
||||
} |
||||
|
||||
/** |
||||
* 分类 |
||||
* |
||||
* @return 菜单分类 |
||||
* |
||||
*/ |
||||
public String category() { |
||||
return TEMPLATE; |
||||
} |
||||
|
||||
/** |
||||
* 获取当前菜单的Action |
||||
* |
||||
* @param plus 当前操作对象 |
||||
* |
||||
* @return 菜单Action |
||||
* |
||||
*/ |
||||
public ShortCut shortcut(ToolBarMenuDockPlus plus) { |
||||
//往ToolBarMenuDockPlus里塞感觉也很糟.
|
||||
if (!(plus instanceof JStreamBook)){ |
||||
return null; |
||||
} |
||||
|
||||
return new CalculateAttrAction((JStreamBook) plus); |
||||
} |
||||
} |
@ -1,37 +0,0 @@
|
||||
package com.fr.plugin.designer.menu; |
||||
|
||||
import com.fr.design.fun.impl.AbstractMenuHandler; |
||||
import com.fr.design.menu.ShortCut; |
||||
|
||||
/** |
||||
* @author Maksim |
||||
* Created in 2020/11/5 11:44 上午 |
||||
*/ |
||||
public class LocalAnalyzerMenu extends AbstractMenuHandler { |
||||
private static final int DEFAULT_INSERT_POSITION = 13; |
||||
|
||||
@Override |
||||
public int insertPosition(int i) { |
||||
return DEFAULT_INSERT_POSITION; |
||||
} |
||||
|
||||
@Override |
||||
public boolean insertSeparatorBefore() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public boolean insertSeparatorAfter() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public String category() { |
||||
return SERVER; |
||||
} |
||||
|
||||
@Override |
||||
public ShortCut shortcut() { |
||||
return new LocalAnalyzerAction(); |
||||
} |
||||
} |
@ -1,20 +0,0 @@
|
||||
package com.fr.plugin.designer.toolbar; |
||||
|
||||
import com.fr.design.fun.impl.AbstractDsinFrameUpButtonProvider; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
|
||||
|
||||
public class TemplateTransformerUIButton extends AbstractDsinFrameUpButtonProvider { |
||||
@Override |
||||
public UIButton[] getUpButtons(int menuState) { |
||||
CompileAction compileAction = new CompileAction(); |
||||
UIButton transBtn = (UIButton) compileAction.createToolBarComponent(); |
||||
return new UIButton[]{transBtn}; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public int currentAPILevel() { |
||||
return CURRENT_LEVEL; |
||||
} |
||||
} |
@ -1,26 +0,0 @@
|
||||
package com.fr.plugin.designer; |
||||
|
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
import javax.swing.Icon; |
||||
|
||||
/** |
||||
* Created by kerry on 2019-10-15 |
||||
*/ |
||||
public class EnginexSupportedFileUIImplTest { |
||||
|
||||
@Test |
||||
public void testGetFileIcon() { |
||||
EnginexSupportedFileUIImpl newFileType = new EnginexSupportedFileUIImpl(); |
||||
Icon icon1 = newFileType.getFileIcon("WorkBook.cpt", false); |
||||
Assert.assertNull(icon1); |
||||
Icon icon2 = newFileType.getFileIcon("WorkBook.cptx", false); |
||||
Assert.assertEquals(EnginexSupportedFileUIImpl.CPTX_ICON, icon2); |
||||
Icon icon3 = newFileType.getFileIcon("WorkBook.cpt", true); |
||||
Assert.assertNull(icon3); |
||||
Icon icon4 = newFileType.getFileIcon("WorkBook.cptx", true); |
||||
Assert.assertEquals(EnginexSupportedFileUIImpl.CPTX_LOCKED_ICON, icon4); |
||||
} |
||||
|
||||
} |
@ -1,42 +0,0 @@
|
||||
package com.fr.plugin.designer.clean; |
||||
|
||||
import com.fr.config.dao.DaoContext; |
||||
import com.fr.config.dao.impl.LocalClassHelperDao; |
||||
import com.fr.config.dao.impl.LocalEntityDao; |
||||
import com.fr.config.dao.impl.LocalXmlEntityDao; |
||||
import com.fr.nx.cptx.clean.CompileCleanManager; |
||||
import com.fr.transaction.Configurations; |
||||
import com.fr.transaction.LocalConfigurationHelper; |
||||
import org.junit.Assert; |
||||
import org.junit.Before; |
||||
import org.junit.Test; |
||||
|
||||
/** |
||||
* @author: Maksim |
||||
* @Date: Created in 2020/4/23 |
||||
* @Description: |
||||
*/ |
||||
public class CompileCleanManagerTest { |
||||
|
||||
@Before |
||||
public void before() { |
||||
DaoContext.setEntityDao(new LocalEntityDao()); |
||||
DaoContext.setClassHelperDao(new LocalClassHelperDao()); |
||||
DaoContext.setXmlEntityDao(new LocalXmlEntityDao()); |
||||
Configurations.setHelper(new LocalConfigurationHelper()); |
||||
} |
||||
|
||||
@Test |
||||
public void clearTest() { |
||||
|
||||
CompileCleanManager manager = CompileCleanManager.getInstance(); |
||||
manager.addRecord("com.cptx"); |
||||
manager.addRecord("abc/com.cptx"); |
||||
manager.addRecord("merge.cptx", "2020-01-01"); |
||||
manager.addRecord("merge.cptx", "2020-02-01"); |
||||
Assert.assertEquals(3, manager.getRecords().size()); |
||||
|
||||
manager.clear(); |
||||
Assert.assertEquals(2, manager.getRecords().size()); |
||||
} |
||||
} |
@ -1,16 +0,0 @@
|
||||
package com.fr.plugin.designer.menu; |
||||
|
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
/** |
||||
* Created by kerry on 2020-01-15 |
||||
*/ |
||||
public class BatchCompileMenuTest { |
||||
|
||||
@Test |
||||
public void testBatchCompileMenuIndex(){ |
||||
BatchCompileMenu menu = new BatchCompileMenu(); |
||||
Assert.assertEquals(9, menu.insertPosition(20)); |
||||
} |
||||
} |
Loading…
Reference in new issue