285
286
287 /**
288 * If ExecTool have SINGLE_TEST_MANAGER enabled then
289 * this method check SINGLE_TEST_MANAGER in all
290 * loaded tools and return false if such found.
291 *
292 * @param newTool new tool which is added to Desktop
293 * @param d Desktop to add
294 * @return true if there is no conflict with SINGLE_TEST_MANAGER
295 * false otherwise
296 */
297 boolean checkOpenNewTool(ExecTool newTool, Desktop d) {
298 return checkOpenNewTool(d, newTool.getContextManager());
299 }
300
301 public boolean checkOpenNewTool(Desktop d, ContextManager conManager) {
302 if (conManager != null && conManager.getFeatureManager().isEnabled(
303 FeatureManager.SINGLE_TEST_MANAGER)) {
304 Tool[] tools = d.getTools();
305 ArrayList list = new ArrayList();
306 for (int i = 0; i < tools.length; i++) {
307 if (tools[i] instanceof ExecTool) {
308 ExecTool tool = (ExecTool) tools[i];
309 ContextManager cm = tool.getContextManager();
310 if (cm != null) {
311 FeatureManager fm = cm.getFeatureManager();
312 if (fm.isEnabled(FeatureManager.SINGLE_TEST_MANAGER)) {
313 // only single test manager
314 list.add(tools[i]);
315 }
316 }
317 }
318 }
319 if (list.isEmpty()) {
320 return true;
321 }
322 if (list.size() == 1) {
323 if (showCloseQuestion() == JOptionPane.YES_OPTION) {
324 ExecTool old = (ExecTool) list.get(0);
325 old.getDesktop().removeTool(old);
330 }
331 }
332 showError("tse.single");
333 return false;
334 }
335 return true;
336 }
337
338
339 class EmptyTool extends Tool {
340 EmptyTool(ToolManager m, String uiKey) {
341 super(m, uiKey);
342 }
343
344 @Override
345 public JMenuBar getMenuBar() {
346 return new JMenuBar();
347 }
348
349 @Override
350 protected void save(Map m) {
351 }
352
353 @Override
354 protected void restore(Map m) {
355 }
356
357 }
358
359 /**
360 * Shows Quick Configuration Editor if not disabled
361 *
362 * @return null
363 */
364 public Tool startTool() {
365 showQSW();
366 return null;
367 /*
368 Desktop d = getDesktop();
369 Tool[] tools = d.getTools();
370 if (tools != null) {
371 // check to see if there is an empty tool; if so, note it
372 for (Tool tool : tools) {
373 if (tool instanceof EmptyTool) {
374 return tool;
|
285
286
287 /**
288 * If ExecTool have SINGLE_TEST_MANAGER enabled then
289 * this method check SINGLE_TEST_MANAGER in all
290 * loaded tools and return false if such found.
291 *
292 * @param newTool new tool which is added to Desktop
293 * @param d Desktop to add
294 * @return true if there is no conflict with SINGLE_TEST_MANAGER
295 * false otherwise
296 */
297 boolean checkOpenNewTool(ExecTool newTool, Desktop d) {
298 return checkOpenNewTool(d, newTool.getContextManager());
299 }
300
301 public boolean checkOpenNewTool(Desktop d, ContextManager conManager) {
302 if (conManager != null && conManager.getFeatureManager().isEnabled(
303 FeatureManager.SINGLE_TEST_MANAGER)) {
304 Tool[] tools = d.getTools();
305 ArrayList<Tool> list = new ArrayList<>();
306 for (int i = 0; i < tools.length; i++) {
307 if (tools[i] instanceof ExecTool) {
308 ExecTool tool = (ExecTool) tools[i];
309 ContextManager cm = tool.getContextManager();
310 if (cm != null) {
311 FeatureManager fm = cm.getFeatureManager();
312 if (fm.isEnabled(FeatureManager.SINGLE_TEST_MANAGER)) {
313 // only single test manager
314 list.add(tools[i]);
315 }
316 }
317 }
318 }
319 if (list.isEmpty()) {
320 return true;
321 }
322 if (list.size() == 1) {
323 if (showCloseQuestion() == JOptionPane.YES_OPTION) {
324 ExecTool old = (ExecTool) list.get(0);
325 old.getDesktop().removeTool(old);
330 }
331 }
332 showError("tse.single");
333 return false;
334 }
335 return true;
336 }
337
338
339 class EmptyTool extends Tool {
340 EmptyTool(ToolManager m, String uiKey) {
341 super(m, uiKey);
342 }
343
344 @Override
345 public JMenuBar getMenuBar() {
346 return new JMenuBar();
347 }
348
349 @Override
350 protected void save(Map<String, String> m) {
351 }
352
353 @Override
354 protected void restore(Map<String, String> m) {
355 }
356
357 }
358
359 /**
360 * Shows Quick Configuration Editor if not disabled
361 *
362 * @return null
363 */
364 public Tool startTool() {
365 showQSW();
366 return null;
367 /*
368 Desktop d = getDesktop();
369 Tool[] tools = d.getTools();
370 if (tools != null) {
371 // check to see if there is an empty tool; if so, note it
372 for (Tool tool : tools) {
373 if (tool instanceof EmptyTool) {
374 return tool;
|