Project

General

Profile

Task #4793

duplicate code

Added by Alexey Demakov over 6 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Category:
-
Target version:
Start date:
03/25/2014
Due date:
% Done:

100%

Estimated time:
Detected in build:
svn
Published in build:
0.15.197

Description

методы isEnabled в
requality\src\java\com\unitesk\requality\eclipse\handlers\copypaste\EclipseCopyHandler.java
requality\src\java\com\unitesk\requality\eclipse\handlers\copypaste\EclipsePasteHandler.java

отличаются только константами "org.eclipse.ui.edit.copy" и "org.eclipse.ui.edit.paste". Эти же константы используются при создании хэндлеров в классах ReqMarker, JSEditor и ReportViewer:

handlerService
.activateHandler("org.eclipse.ui.edit.copy", new EclipseCopyHandler());
handlerService
.activateHandler("org.eclipse.ui.edit.paste", new EclipsePasteHandler());

Предлагаю:
1. Добавить в классы EclipseCopyHandler и EclipsePasteHandler публичные именованные константы для этих строк и именно их использовать в проекте.
2. Создать общий базовый класс, где объявить абстрактный виртуальный метод типа getCommandId(), который в наследниках возвращает необходимое значение.
3. Перенести метод isEnabled в общий базовый класс, заменив использование констант на вызов getCommandId()

Associated revisions

Revision 3510 (diff)
Added by Denis Kildishev over 6 years ago

fixes: #4793; solves code duplication in way mentioned in task - new superclass is created with abstract getCommandId() method and all functionality

Revision f30294be (diff)
Added by Denis Kildishev over 6 years ago

fixes: #4793; solves code duplication in way mentioned in task - new superclass is created with abstract getCommandId() method and all functionality

git-svn-id: https://forge.ispras.ru/svn/reqdb/trunk/requality@3510 f558eac1-05b1-4da7-9ed5-5050e8a619d6

Revision 3510 (diff)
Added by Denis Kildishev over 6 years ago

fixes: #4793; solves code duplication in way mentioned in task - new superclass is created with abstract getCommandId() method and all functionality

History

#1

Updated by Denis Kildishev over 6 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

Applied in changeset r3510.

#2

Updated by Denis Kildishev over 6 years ago

  • Published in build set to 0.15.197
#3

Updated by Alexey Khoroshilov over 6 years ago

  • Target version set to 0.16
#4

Updated by Alexey Khoroshilov over 5 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF