org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor Java Examples

The following examples show how to use org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestRenameDiagram.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testRenameMenu() {
    SWTBotTestUtil.createNewDiagram(bot);

    bot.menu("File").menu("Save").click();

    final SWTBotEditor botEditor = bot.activeEditor();
    final SWTBotGefEditor gmfEditor = bot.gefEditor(botEditor.getTitle());
    final MainProcess diagram = (MainProcess) ((IGraphicalEditPart) gmfEditor.mainEditPart().part())
            .resolveSemanticElement();
    final String originalName = diagram.getName();
    bot.menu("File").menu("Rename diagram...").click();
    bot.waitUntil(Conditions.shellIsActive(org.bonitasoft.studio.common.Messages.openNameAndVersionDialogTitle));

    assertTrue("OK should be enabled", bot.button(IDialogConstants.OK_LABEL).isEnabled());

    final String newName = originalName + " renamed" + System.currentTimeMillis();
    bot.textWithLabel(org.bonitasoft.studio.common.Messages.name, 0).setText(newName);

    bot.button(IDialogConstants.OK_LABEL).click();
    assertEquals(newName + " (1.0)", bot.activeEditor().getTitle());
    assertFalse("Editor is dirty", bot.activeEditor().isDirty());
}
 
Example #2
Source File: TestThrowCatchMessage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testCathMessageNotAllowed() throws IOException {
    new BotApplicationWorkbenchWindow(bot).importBOSArchive()
            .setArchive(
                    TestThrowCatchMessage.class.getResource("TestCatchMessageSelectionTest-1.0.bos"))
            .finish();

    final SWTBotEditor botEditor = bot.activeEditor();
    final SWTBotGefEditor gmfEditor = bot.gefEditor(botEditor.getTitle());

    SWTBotTestUtil.selectEventOnProcess(bot, gmfEditor, "Message2");
    bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_PROCESS_GENERAL).show();
    bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_PROCESS_GENERAL)
            .setFocus();

    final SWTBotCombo combo = bot
            .comboBoxWithLabel(Messages.selectMessageEventLabel);

    for (final String s : combo.items()) {
        Assert.assertFalse(
                "The message throw from the same pool should not be available in the combo.",
                s.equals("theMessage"));
    }
}
 
Example #3
Source File: ExportToTsvTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test full export
 *
 * @throws IOException
 *             File not found or such
 */
@Test
public void testExport() throws IOException {
    SWTBotEditor editorBot = fEditorBot;
    assertNotNull(editorBot);
    final SWTBotTable tableBot = editorBot.bot().table();

    tableBot.getTableItem(1).contextMenu(EXPORT_TO_TSV).click();
    File file = new File(fAbsolutePath);
    fBot.waitUntil(new FileLargerThanZeroCondition(file));
    try (BufferedReader br = new BufferedReader(new FileReader(file))) {
        long lines = br.lines().count();
        assertEquals("Line count", 23, lines);
    } finally {
        new File(fAbsolutePath).delete();
    }
}
 
Example #4
Source File: BotGefBaseEditor.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public BotGefBaseEditor(final SWTGefBot bot) {
      super(bot);
      WorkbenchContentsFinder workbenchContentsFinder = new WorkbenchContentsFinder();
      bot.waitUntil(new DefaultCondition() {
	
	@Override
	public boolean test() throws Exception {
		return workbenchContentsFinder.findActiveEditor() != null;
	}
	
	@Override
	public String getFailureMessage() {
		return "There is no active editor";
	}
},10000,500);
      final SWTBotEditor botEditor = bot.activeEditor();
      gmfEditor = bot.gefEditor(botEditor.getTitle());
  }
 
Example #5
Source File: TestWebPurchase.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testWebPurchase() throws Exception {
    SWTBotTestUtil.createNewDiagram(bot);
    final SWTBotEditor botEditor = bot.activeEditor();
    diagramTitle = botEditor.getTitle();
    final SWTBotGefEditor gmfEditor = bot.gefEditor(botEditor.getTitle());

    final SWTBotGefEditPart element = gmfEditor.getEditPart("Step1");
    element.click();
    gmfEditor.clickContextMenu("Delete");
    gmfEditor.click(200, 200);
    gmfEditor.clickContextMenu("Delete");
    gmfEditor.click(200, 200);
    configurePool(gmfEditor);
    stepGateWayXor(gmfEditor);
    stepSalesReview(gmfEditor);
    stepMoreInfo(gmfEditor);
    stepPay(gmfEditor);
    stepReject(gmfEditor);
    stepExpressDelivery(gmfEditor);
    stepArchive(gmfEditor);
    finalEvent(gmfEditor);
    bot.toolbarButtonWithId(SWTBotConstants.SWTBOT_ID_SAVE_EDITOR).click();
    configureProcess(gmfEditor);
    runProcess(gmfEditor);
}
 
Example #6
Source File: ConditionHelpers.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public boolean test() throws Exception {
    List<SWTBotEditor> editors = fWorkbenchBot.editors(WidgetMatcherFactory.withPartId(TmfEventsEditor.ID));
    for (SWTBotEditor e : editors) {
        // We are careful not to call e.getWidget() here because it actually forces the editor to show.
        // This is especially a problem for cases where we wait until there is no active editor.
        if (e.isActive()) {
            if (fEditorTitle != null && !fEditorTitle.equals(e.getTitle())) {
                return false;
            }
            fEditor = e;
            return true;
        }
    }
    return false;
}
 
Example #7
Source File: DataWizardIT.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testCreateData() throws Exception {
    SWTBotTestUtil.createNewDiagram(bot);
    final SWTBotEditor botEditor = bot.activeEditor();
    final SWTBotGefEditor gmfEditor = bot.gefEditor(botEditor.getTitle());

    final IGraphicalEditPart part = (IGraphicalEditPart) gmfEditor.mainEditPart().part();
    final MainProcess model = (MainProcess) part.resolveSemanticElement();
    final Pool pool = (Pool) model.getElements().get(0);

    gmfEditor.getEditPart(pool.getName()).parent().select();
    bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_PROCESS_GENERAL).show();
    addDataOnSelectedElementWithName("newData", SWTBotConstants.VIEWS_PROPERTIES_POOL_DATA_VARIABLES);

    assertTrue("no data added", pool.getData().size() == 1);
    assertTrue("wrong data added", pool.getData().get(0).getName().equals("newData"));
}
 
Example #8
Source File: BookmarksViewTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test bookmarking an experiment
 *
 * @throws IOException
 *             if an error occurs during the file URL -> path conversion
 */
@Test
@Ignore
public void testExperiment() throws IOException {
    /**
     * Create Experiment with 2 LTTng CTF Kernel traces in it and open
     * experiment. Verify that an Events editor is opened showing LTTng
     * Kernel specific columns.
     */
    SWTBotUtils.openTrace(PROJECT_NAME, FileLocator.toFileURL(TmfTraceStub.class.getResource("/testfiles/A-Test-10K")).getPath(), TRACE_TYPE);
    SWTBotUtils.openTrace(PROJECT_NAME, FileLocator.toFileURL(TmfTraceStub.class.getResource("/testfiles/A-Test-10K-2")).getPath(), TRACE_TYPE);
    WaitUtils.waitForJobs();
    SWTBotUtils.createExperiment(fBot, PROJECT_NAME, EXPERIMENT_NAME);
    SWTBotTreeItem project = SWTBotUtils.selectProject(fBot, PROJECT_NAME);
    SWTBotTreeItem experiment = SWTBotUtils.getTraceProjectItem(fBot, project, "Experiments", EXPERIMENT_NAME);
    experiment.contextMenu("Select Traces...").click();
    SWTBotShell selectTracesShell = fBot.shell("Select Traces");
    selectTracesShell.bot().button("Select All").click();
    selectTracesShell.bot().button("Finish").click();
    experiment.select();
    experiment.doubleClick();
    SWTBotEditor editor = SWTBotUtils.activeEventsEditor(fBot, EXPERIMENT_NAME);
    assertEquals("Event editor is displaying the wrong trace/experiment", EXPERIMENT_NAME, editor.getTitle());

    bookmarkTest(EXPERIMENT_NAME);
}
 
Example #9
Source File: AddProjectNatureTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test adding and configuring tracing nature on a C-Project.
 */
@Test
public void testConfigureTracingNature() {
    SWTBotTreeItem projectItem = SWTBotUtils.selectProject(fBot, SOME_PROJECT_NAME);
    projectItem.contextMenu().menu(CONTEXT_MENU_CONFIGURE, CONTEXT_MENU_CONFIGURE_TRACING_NATURE).click();
    WaitUtils.waitForJobs();

    SWTBotTreeItem projectRoot = SWTBotUtils.getTraceProjectItem(fBot, projectItem, TRACING_PROJECT_ROOT_NAME);
    assertEquals(TRACING_PROJECT_ROOT_NAME, projectRoot.getText());
    SWTBotUtils.getTraceProjectItem(fBot, projectRoot, TRACES_FOLDER_NAME);
    SWTBotUtils.getTraceProjectItem(fBot, projectRoot, EXPERIMENTS_FOLDER_NAME);

    SWTBotUtils.openTrace(SOME_PROJECT_NAME, fTestFile.getAbsolutePath(), TRACE_TYPE);
    SWTBotEditor editorBot = SWTBotUtils.activateEditor(fBot, fTestFile.getName());
    SWTBotTable tableBot = editorBot.bot().table();
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, FIRST_EVENT_TIME, 1, 1));
    assertEquals("Timestamp", FIRST_EVENT_TIME, tableBot.cell(1, 1));
    fBot.closeAllEditors();
}
 
Example #10
Source File: PDFHandlerThreadingTest.java    From tlaplus with MIT License 6 votes vote down vote up
@Test @Ignore("not ready yet")
public void producePDFInNonUIThread() throws InterruptedException {
	
	// Open specA 
	SWTBotMenu fileMenu = bot.menu("File");
	SWTBotMenu openSpecMenu = fileMenu.menu("Open Spec");
	SWTBotMenu addNewSpecMenu = openSpecMenu.menu("Add New Spec...");
	addNewSpecMenu.click();

	bot.textWithLabel("Root-module file:").setText(specA);
	bot.button("Finish").click();
	
	// generate PDF
	SWTBotMenu pdfMenu = fileMenu.menu("Produce PDF Version");
	pdfMenu.click();
	
	// wait for the browser to show up with the generated PDF
	SWTBotEditor swtBotEditor = bot.editorById(OpenSpecHandler.TLA_EDITOR);
	Assert.assertNotNull(swtBotEditor);
	
	assertNoBackendCodeInUIThread();
}
 
Example #11
Source File: ConfigurationDialogIT.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    SWTBotTestUtil.createNewDiagram(bot);
    final SWTBotEditor botEditor = bot.activeEditor();
    final SWTBotGefEditor gmfEditor = bot.gefEditor(botEditor.getTitle());
    final List<SWTBotGefEditPart> runnableEPs = gmfEditor.editParts(new BaseMatcher<EditPart>() {

        @Override
        public boolean matches(final Object item) {
            return item instanceof PoolEditPart;
        }

        @Override
        public void describeTo(final Description description) {

        }
    });
    Assert.assertFalse(runnableEPs.isEmpty());
    gmfEditor.select(runnableEPs.get(0));
}
 
Example #12
Source File: FilterColorEditorTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Bring up the table
 */
@Before
public void setup() {
    SWTBotUtils.createProject(TRACE_PROJECT_NAME);

    // Open the actual trace
    SWTBotUtils.openTrace(TRACE_PROJECT_NAME, fTestFile.getAbsolutePath(), COLUMN_TRACE_TYPE);
    SWTBotEditor editorBot = SWTBotUtils.activateEditor(fBot, fTestFile.getName());

    fTableBot = editorBot.bot().table();
    fBackground = fTableBot.backgroundColor().getRGB();
    fForeground = fTableBot.foregroundColor().getRGB();

    SWTBotUtils.maximize(editorBot.getReference(), fTableBot);
}
 
Example #13
Source File: DataWizardIT.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private Pool createProcessWithData() {
    SWTBotTestUtil.createNewDiagram(bot);
    final SWTBotEditor botEditor = bot.activeEditor();
    final SWTBotGefEditor gmfEditor = bot.gefEditor(botEditor.getTitle());

    final IGraphicalEditPart part = (IGraphicalEditPart) gmfEditor.mainEditPart().part();
    final MainProcess model = (MainProcess) part.resolveSemanticElement();
    final Pool pool = (Pool) model.getElements().get(0);

    gmfEditor.getEditPart(pool.getName()).parent().select();
    final String dataName = "newData";
    addDataOnSelectedElementWithName(dataName, SWTBotConstants.VIEWS_PROPERTIES_POOL_DATA_VARIABLES);
    return pool;
}
 
Example #14
Source File: ProjectExplorerTracesFolderTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static void verifyTrace(TestTraceInfo traceInfo, int importOptionFlags, String traceName, String traceType, String projectName) {
    String[] tracePath = new Path(traceName).segments();
    SWTBotTreeItem traceItem = SWTBotUtils.getTraceProjectItem(fBot, SWTBotUtils.selectTracesFolder(fBot, projectName), tracePath);
    checkTraceType(traceItem, traceType);
    openTrace(traceItem);
    if (traceType != null && !traceType.isEmpty()) {
        SWTBotImportWizardUtils.testEventsTable(fBot, traceName, traceInfo.getNbEvents(), traceInfo.getFirstEventTimestamp());
    } else {
        // If there is no trace type, make sure it can be opened with the text editor
        fBot.waitUntil(ConditionHelpers.isEditorOpened(fBot, traceName));
        SWTBotEditor editor = fBot.editorByTitle(traceName);
        assertEquals(TEXT_EDITOR_ID, editor.getReference().getId());
    }
    checkTraceLinked(traceItem, (importOptionFlags & ImportTraceWizardPage.OPTION_CREATE_LINKS_IN_WORKSPACE) != 0);
}
 
Example #15
Source File: SwtWorkbenchBot.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Checks if a {@link SWTBotEditor} is available.
 *
 * @param swtBotEditor
 *          the {@link SWTBotEditor}
 * @return {@code true} if the editor was found open, {@code false} otherwise
 */
public boolean hasEditor(final SWTBotEditor swtBotEditor) {
  for (SWTBotEditor editor : editors()) {
    if (editor.getReference().equals(swtBotEditor.getReference())) {
      return true;
    }
  }
  return false;
}
 
Example #16
Source File: TestUndoRedoStackLimit.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private int retrieveLimit(SWTBotEditor botEditor) {
    IEditorPart editor = botEditor.getReference().getEditor(false);
    IOperationHistory history = editor.getAdapter(IOperationHistory.class);
    IUndoContext context = editor.getAdapter(IUndoContext.class);

    if (history != null && context != null) {
        return history.getLimit(context);
    }
    return -1;
}
 
Example #17
Source File: PinAndCloneTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test the follow time updates functionality
 */
@Test
public void testFollow() {
    TmfTraceManager traceManager = TmfTraceManager.getInstance();
    ITmfTrace ust = traceManager.getActiveTrace();
    assertNotNull(ust);
    ITmfTrace kernelTest = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.CONTEXT_SWITCHES_KERNEL);
    SWTBotUtils.openTrace(TRACE_PROJECT_NAME, kernelTest.getPath(), TRACETYPE_ID);
    /* Finish waiting for the trace to index */
    WaitUtils.waitForJobs();
    SWTBotEditor kernelEditor = SWTBotUtils.activateEditor(fBot, kernelTest.getName());
    // wait for the editor to be ready.
    fBot.editorByTitle(kernelTest.getName());
    ITmfTrace kernel = traceManager.getActiveTrace();
    assertNotNull(kernel);

    SWTBotTable kernelEventTable = kernelEditor.bot().table();
    SWTBotTableItem kernelEvent = kernelEventTable.getTableItem(5);
    kernelEvent.contextMenu(FOLLOW_TIME_UPDATES_FROM_OTHER_TRACES).click();
    SWTBotUtils.activateEditor(fBot, ust.getName());
    TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, RANGE, ust));

    // assert that the kernel trace followed the ust trace's range
    IWorkbenchPart part = fOriginalViewBot.getViewReference().getPart(false);
    assertTrue(part instanceof AbstractTimeGraphView);
    AbstractTimeGraphView abstractTimeGraphView = (AbstractTimeGraphView) part;
    fBot.waitUntil(ConditionHelpers.timeGraphRangeCondition(abstractTimeGraphView, ust, RANGE));

    SWTBotUtils.activateEditor(fBot, kernel.getName());
    fBot.waitUntil(ConditionHelpers.timeGraphRangeCondition(abstractTimeGraphView, kernel, RANGE));

    // unfollow (don't use context menu on table item to avoid updating selection)
    kernelEventTable.contextMenu(FOLLOW_TIME_UPDATES_FROM_OTHER_TRACES).click();
    TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, ust.getInitialTimeRange(), ust));
    fBot.waitUntil(ConditionHelpers.timeGraphRangeCondition(abstractTimeGraphView, kernel, RANGE));

    kernelTest.dispose();
}
 
Example #18
Source File: BPMNExportTests.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testBPMN2MenuPresentAfterOepningAnotherEditor() {
    final String id = "testBPMN2MenuPresentAfterOpeningAnotherEditor";
    final String className = "MyConnectorImpl" + System.currentTimeMillis();
    final String packageName = "org.bonita.connector.test";
    SWTBotConnectorTestUtil.createConnectorDefAndImpl(bot, id, "1.0.0", className, packageName);

    bot.waitUntil(Conditions.waitForEditor(new BaseMatcher<IEditorReference>() {

        @Override
        public boolean matches(final Object item) {
            return "org.eclipse.jdt.ui.CompilationUnitEditor".equals(((IEditorReference) item).getId());
        }

        @Override
        public void describeTo(final Description description) {

        }

    }), 10000);
    final SWTBotEditor activeEditor = bot.activeEditor();
    assertEquals("org.eclipse.jdt.ui.CompilationUnitEditor", activeEditor.getReference().getId());

    final SWTBotMenu processMenu = bot.menu("File");

    final SWTBotMenu exportAsMenu = processMenu.menu("Export as").click();
    final MenuItem mi = exportAsMenu.widget;
    Display.getDefault().syncExec(() -> {
        mi.getMenu().notifyListeners(SWT.Show, new Event());
        final MenuItem[] mis = mi.getMenu().getItems();

        for (final MenuItem menuItem : mis) {
            final String menuText = menuItem.getText();
            menuBPMN2found = menuBPMN2found || "BPMN 2.0...".equals(menuText);
        }
    });

    assertTrue("BPMN 2.0 menu is not present", menuBPMN2found);
}
 
Example #19
Source File: DataWizardIT.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testMoveData() throws Exception {
    final Pool pool = createProcessWithData();
    final Lane lane = (Lane) pool.getElements().get(0);
    final SWTBotEditor botEditor = bot.activeEditor();
    final SWTBotGefEditor gmfEditor = bot.gefEditor(botEditor.getTitle());

    final SWTBotGefEditPart parent = gmfEditor.getEditPart("Step1").parent();
    final Activity step = (Activity) ((IGraphicalEditPart) parent.part()).resolveSemanticElement();
    final SWTBotGefEditPart poolPart = gmfEditor.getEditPart(pool.getName()).parent();
    poolPart.select();
    poolPart.click();
    addDataOnSelectedElementWithName("dataToMove", SWTBotConstants.VIEWS_PROPERTIES_POOL_DATA_VARIABLES);
    final int nbPoolData = pool.getData().size();
    final int nbStepData = step.getData().size();
    bot.tableWithId(SWTBotConstants.SWTBOT_ID_PROCESS_DATA_LIST).select("dataToMove -- Text");
    // button("Move...")
    bot.button(Messages.moveData).click();
    bot.tree().getTreeItem("Pool " + pool.getName()).getNode("Lane " + lane.getName()).select("Task Step1");
    bot.button(IDialogConstants.FINISH_LABEL).click();
    SWTBotTestUtil.waitUntilRootShellIsActive(bot);
    bot.menu("File").menu("Save").click();
    bot.waitUntil(new DefaultCondition() {

        @Override
        public boolean test() throws Exception {
            return nbStepData + 1 == step.getData().size();
        }

        @Override
        public String getFailureMessage() {
            return "data not removed";
        }
    });

    assertEquals("data not added", nbPoolData - 1, pool.getData().size());
}
 
Example #20
Source File: DataWizardIT.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testRemoveData() throws Exception {

    SWTBotTestUtil.createNewDiagram(bot);

    final SWTBotEditor botEditor = bot.activeEditor();
    final SWTBotGefEditor gmfEditor = bot.gefEditor(botEditor.getTitle());

    final IGraphicalEditPart part = (IGraphicalEditPart) gmfEditor.mainEditPart().part();
    final MainProcess model = (MainProcess) part.resolveSemanticElement();
    final Pool pool = (Pool) model.getElements().get(0);

    gmfEditor.getEditPart(pool.getName()).parent().select();

    addDataOnSelectedElementWithName("newData", SWTBotConstants.VIEWS_PROPERTIES_POOL_DATA_VARIABLES);
    addDataOnSelectedElementWithName("dataToNotBeRemoved", SWTBotConstants.VIEWS_PROPERTIES_POOL_DATA_VARIABLES);

    final int nbData = pool.getData().size();
    final Data firstData = pool.getData().get(0);
    bot.tableWithId(SWTBotConstants.SWTBOT_ID_PROCESS_DATA_LIST)
            .select(firstData.getName() + " -- " + firstData.getDataType().getName());
    // button("Remove")
    bot.buttonWithId(SWTBotConstants.SWTBOT_ID_REMOVE_PROCESS_DATA).click();
    bot.button(IDialogConstants.OK_LABEL).click();

    SWTBotTestUtil.waitUntilRootShellIsActive(bot);
    bot.menu("File");
    final BotApplicationWorkbenchWindow applicationWorkbenchWindow = new BotApplicationWorkbenchWindow(bot);
    applicationWorkbenchWindow.save();

    assertEquals("data not removed", nbData - 1, pool.getData().size());
    assertFalse("the wrong data was removed", firstData.equals(pool.getData().get(0)));
}
 
Example #21
Source File: ProjectTreeItem.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 合并打开当前项目中的所有 XLIFF
 */
public void ctxMenuOpenProjectFiles() {
	ptn.select();
	SWTBotMenu openProjectFiles = ptv.ctxMenuOpenProjectFiles();
	openProjectFiles.isEnabled(); // 确认右键菜单中的打开项目功能可用
	openProjectFiles.click(); // 点击该菜单项
	// 确认文件被成功打开
	SWTBotEditor editor = HSBot.bot().editorByTitle(prjName);
	HSBot.bot().waitUntil(new IsEditorOpened(editor));
}
 
Example #22
Source File: ProjectTreeItem.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 打开当前项目中的一个 XLIFF 文件
 * @param xlfFileName
 *            要打开的 XLIFF 文件名称
 */
public void ctxMenuOpenFile(final String xlfFileName) {
	selectFile("XLIFF", xlfFileName);
	SWTBotMenu openFiles = ptv.ctxMenuOpenFile();
	openFiles.isEnabled();
	openFiles.click();

	SWTBotEditor editor = HSBot.bot().editorByTitle(xlfFileName);
	HSBot.bot().waitUntil(new IsEditorOpened(editor));
}
 
Example #23
Source File: OpenFileDialog.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 在打开文件对话框中输入指定文件名称或路径
 * @param filePath
 *            要打开的文件名称或路径
 * @param isValid
 *            是否为有效文件名称或路径
 * @param isFile
 *            true 表示输入的是文件名称,false 表示文件路径
 */
public static void openFile(String filePath, boolean isValid, boolean isFile) {
	OsUtil.typePath(filePath); // typePath 方法处理了多种操作系统的情况

	String fileName = new Path(filePath).lastSegment(); // 从路径中取出文件名

	if (isValid) {
		// 确认编辑器成功打开
		HsSWTWorkbenchBot bot = HSBot.bot();
		final SWTBotEditor editor = bot.editorByTitle(fileName);
		bot.waitUntil(new IsEditorOpened(editor));
	} else {
		if (isFile) {
			// 弹出信息对话框
			InfoFileNotFound fnf = new InfoFileNotFound(filePath);
			fnf.msgFileNotFound().isVisible(); // 文件未找到
			fnf.btnOK().click();
		} else {
			try {
				OsUtil.typeEnter(); // 在系统对话框的信息提示框上点确认
				OsUtil.typeEsc(); // 按 Esc 取消打开文件
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
}
 
Example #24
Source File: TS.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 激活或打开编辑器,仅限合并打开的指定项目中的 XLIFF 文件
 * 
 * @param prjName
 *            要打开的项目名称
 */
public void setCurrentFile(String prjName) {
	SWTBotEditor editor = bot.editorByTitle(prjName);
	if (editor != null) {
		editor.show();
	} else {
		ProjectTreeItem.getInstance(prjName).ctxMenuOpenProjectFiles();
	}
	// TODO: 需要完善对同名编辑器的判断和处理
}
 
Example #25
Source File: TS.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 激活或打开编辑器,仅限项目 XLIFF 目录中的 XLIFF 文件
 * 
 * @param prjName
 *            XLIFF 文件所在的项目名称
 * @param xlfFileName
 *            要打开的 XLIFF 文件名称
 */
public void setCurrentFile(String prjName, String xlfFileName) {
	SWTBotEditor editor = bot.editorByTitle(xlfFileName);
	if (editor != null) {
		editor.show();
	} else {
		ProjectTreeView.doubleClickXlfFile(prjName, xlfFileName);
	}
	// TODO: 需要完善对同名编辑器的判断和处理
}
 
Example #26
Source File: ProjectTreeItem.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 打开当前项目中的一个 XLIFF 文件
 * @param xlfFileName
 *            要打开的 XLIFF 文件名称
 */
public void ctxMenuOpenFile(final String xlfFileName) {
	selectFile("XLIFF", xlfFileName);
	SWTBotMenu openFiles = ptv.ctxMenuOpenFile();
	openFiles.isEnabled();
	openFiles.click();

	SWTBotEditor editor = HSBot.bot().editorByTitle(xlfFileName);
	HSBot.bot().waitUntil(new IsEditorOpened(editor));
}
 
Example #27
Source File: OpenFileDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 在打开文件对话框中输入指定文件名称或路径
 * @param filePath
 *            要打开的文件名称或路径
 * @param isValid
 *            是否为有效文件名称或路径
 * @param isFile
 *            true 表示输入的是文件名称,false 表示文件路径
 */
public static void openFile(String filePath, boolean isValid, boolean isFile) {
	OsUtil.typePath(filePath); // typePath 方法处理了多种操作系统的情况

	String fileName = new Path(filePath).lastSegment(); // 从路径中取出文件名

	if (isValid) {
		// 确认编辑器成功打开
		HsSWTWorkbenchBot bot = HSBot.bot();
		final SWTBotEditor editor = bot.editorByTitle(fileName);
		bot.waitUntil(new IsEditorOpened(editor));
	} else {
		if (isFile) {
			// 弹出信息对话框
			InfoFileNotFound fnf = new InfoFileNotFound(filePath);
			fnf.msgFileNotFound().isVisible(); // 文件未找到
			fnf.btnOK().click();
		} else {
			try {
				OsUtil.typeEnter(); // 在系统对话框的信息提示框上点确认
				OsUtil.typeEsc(); // 按 Esc 取消打开文件
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
}
 
Example #28
Source File: TS.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 激活或打开编辑器,仅限合并打开的指定项目中的 XLIFF 文件
 * 
 * @param prjName
 *            要打开的项目名称
 */
public void setCurrentFile(String prjName) {
	SWTBotEditor editor = bot.editorByTitle(prjName);
	if (editor != null) {
		editor.show();
	} else {
		ProjectTreeItem.getInstance(prjName).ctxMenuOpenProjectFiles();
	}
	// TODO: 需要完善对同名编辑器的判断和处理
}
 
Example #29
Source File: TS.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 激活或打开编辑器,仅限项目 XLIFF 目录中的 XLIFF 文件
 * 
 * @param prjName
 *            XLIFF 文件所在的项目名称
 * @param xlfFileName
 *            要打开的 XLIFF 文件名称
 */
public void setCurrentFile(String prjName, String xlfFileName) {
	SWTBotEditor editor = bot.editorByTitle(xlfFileName);
	if (editor != null) {
		editor.show();
	} else {
		ProjectTreeView.doubleClickXlfFile(prjName, xlfFileName);
	}
	// TODO: 需要完善对同名编辑器的判断和处理
}
 
Example #30
Source File: RemoteWorkbenchBot.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean isEditorOpen(String fileName) throws RemoteException {
  for (SWTBotEditor editor : swtWorkBenchBot.editors()) {
    if (editor.getTitle().equals(fileName)) return true;
  }
  return false;
}