提交 18f245d3 编写于 作者: A Alexander Fedorov

#3118 extract PgSqlLaunchShortcut messages to common part

上级 136355e1
......@@ -42,8 +42,16 @@ public class DebugUIMessages extends NLS {
public static String DatabaseTab_name;
public static String LaunchShortcut_e_launch;
public static String LaunchShortcut_select_cobfiguration_title;
public static String DatabaseLaunchShortcut_e_launch;
public static String DatabaseLaunchShortcut_select_configuration_title;
public static String DatabaseLaunchShortcut_select_configuration_message;
public static String DatabaseLaunchShortcut_e_editor_empty;
public static String DatabaseLaunchShortcut_e_selection_empty;
public static String DatabaseLaunchShortcut_select_message;
public static String DatabaseLaunchShortcut_select_title;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, DebugUIMessages.class);
......
......@@ -32,5 +32,13 @@ DatabaseTab_script_execute_text=Execute script
DatabaseTab_name=&Main
LaunchShortcut_e_launch=Launch error
LaunchShortcut_select_cobfiguration_title=&Select existing configuration:
DatabaseLaunchShortcut_e_launch=Launch error
DatabaseLaunchShortcut_select_configuration_title=Select Configuration
DatabaseLaunchShortcut_select_configuration_message=&Select existing configuration:
DatabaseLaunchShortcut_e_editor_empty=Editor does not contain {0} procedure
DatabaseLaunchShortcut_e_selection_empty=Selection does not contain {0} procedure
DatabaseLaunchShortcut_select_message=Select {0} procedure (? = any character, * = any String):
DatabaseLaunchShortcut_select_title=Select {0} Procedure
......@@ -40,6 +40,7 @@ import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchWindow;
......@@ -51,6 +52,14 @@ import org.jkiss.dbeaver.debug.internal.ui.DebugUIMessages;
import org.jkiss.dbeaver.model.struct.DBSObject;
public abstract class DatabaseLaunchShortcut implements ILaunchShortcut2 {
private final String configurationTypeId;
private final String launchObjectName;
public DatabaseLaunchShortcut(String typeId, String objectName) {
this.configurationTypeId = typeId;
this.launchObjectName = objectName;
}
@Override
public void launch(ISelection selection, String mode) {
......@@ -76,13 +85,25 @@ public abstract class DatabaseLaunchShortcut implements ILaunchShortcut2 {
}
protected abstract String getSelectionEmptyMessage();
protected String getSelectionEmptyMessage() {
String message = DebugUIMessages.DatabaseLaunchShortcut_e_selection_empty;
return NLS.bind(message, launchObjectName);
}
protected abstract String getEditorEmptyMessage();
protected String getEditorEmptyMessage() {
String message = DebugUIMessages.DatabaseLaunchShortcut_e_editor_empty;
return NLS.bind(message, launchObjectName);
}
protected abstract String getLaunchableSelectionTitle(String mode);
protected String getLaunchableSelectionTitle(String mode) {
String message = DebugUIMessages.DatabaseLaunchShortcut_select_title;
return NLS.bind(message, launchObjectName);
}
protected abstract String getLaunchableSelectionMessage(String mode);
protected String getLaunchableSelectionMessage(String mode) {
String message = DebugUIMessages.DatabaseLaunchShortcut_select_message;
return NLS.bind(message, launchObjectName);
}
protected ILabelProvider getLaunchableSelectionRenderer() {
return WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider();
......@@ -100,7 +121,7 @@ public abstract class DatabaseLaunchShortcut implements ILaunchShortcut2 {
List<DBSObject> extracted = DebugCore.extractLaunchable(scope);
DBSObject launchable = null;
if (extracted.size() == 0) {
MessageDialog.openError(getShell(), DebugUIMessages.LaunchShortcut_e_launch, emptyMessage);
MessageDialog.openError(getShell(), DebugUIMessages.DatabaseLaunchShortcut_e_launch, emptyMessage);
} else if (extracted.size() > 1) {
launchable = selectLaunchable(getShell(), extracted, mode);
} else {
......@@ -130,7 +151,7 @@ public abstract class DatabaseLaunchShortcut implements ILaunchShortcut2 {
} catch (CoreException e) {
IStatus status = e.getStatus();
DebugUI.log(status);
MessageDialog.openError(getShell(), DebugUIMessages.LaunchShortcut_e_launch, status.getMessage());
MessageDialog.openError(getShell(), DebugUIMessages.DatabaseLaunchShortcut_e_launch, status.getMessage());
return;
}
}
......@@ -146,7 +167,13 @@ public abstract class DatabaseLaunchShortcut implements ILaunchShortcut2 {
return lm.getLaunchConfigurationType(configurationTypeId);
}
protected abstract String getConfigurationTypeId();
protected String getConfigurationTypeId() {
return configurationTypeId;
}
protected String getLaunchObjectName() {
return launchObjectName;
}
protected DBSObject selectLaunchable(Shell shell, List<DBSObject> launchables, String mode) {
String title = getLaunchableSelectionTitle(mode);
......@@ -189,8 +216,8 @@ public abstract class DatabaseLaunchShortcut implements ILaunchShortcut2 {
IDebugModelPresentation labelProvider = DebugUITools.newDebugModelPresentation();
ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider);
dialog.setElements(configList.toArray());
dialog.setTitle(getLaunchableSelectionTitle(mode));
dialog.setMessage(DebugUIMessages.LaunchShortcut_select_cobfiguration_title);
dialog.setTitle(DebugUIMessages.DatabaseLaunchShortcut_select_configuration_title);
dialog.setMessage(DebugUIMessages.DatabaseLaunchShortcut_select_configuration_message);
dialog.setMultipleSelection(false);
int result = dialog.open();
labelProvider.dispose();
......
......@@ -26,29 +26,8 @@ import org.jkiss.dbeaver.model.struct.DBSObject;
public abstract class PgSqlBaseLaunchShortcut extends DatabaseLaunchShortcut {
@Override
protected String getSelectionEmptyMessage() {
return PostgreDebugUIMessages.PgSqlLaunchShortcut_e_selection_empty;
}
@Override
protected String getEditorEmptyMessage() {
return PostgreDebugUIMessages.PgSqlLaunchShortcut_e_editor_empty;
}
@Override
protected String getLaunchableSelectionTitle(String mode) {
return PostgreDebugUIMessages.PgSqlLaunchShortcut_select_procedure_title;
}
@Override
protected String getLaunchableSelectionMessage(String mode) {
return PostgreDebugUIMessages.PgSqlLaunchShortcut_select_procedure_message;
}
@Override
protected String getConfigurationTypeId() {
return PostgreSqlDebugCore.CONFIGURATION_TYPE;
public PgSqlBaseLaunchShortcut() {
super(PostgreSqlDebugCore.CONFIGURATION_TYPE, PostgreDebugUIMessages.PgSqlLaunchShortcut_name);
}
@Override
......
......@@ -23,10 +23,7 @@ public class PostgreDebugUIMessages extends NLS {
private static final String BUNDLE_NAME = "org.jkiss.dbeaver.ext.postgresql.debug.ui.internal.PostgreDebugUIMessages"; //$NON-NLS-1$
public static String PgSqlLaunchShortcut_e_editor_empty;
public static String PgSqlLaunchShortcut_e_selection_empty;
public static String PgSqlLaunchShortcut_select_procedure_message;
public static String PgSqlLaunchShortcut_select_procedure_title;
public static String PgSqlLaunchShortcut_name;
static {
// initialize resource bundle
......
......@@ -14,7 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
PgSqlLaunchShortcut_e_editor_empty=Editor does not containt PostgreSQL procedure
PgSqlLaunchShortcut_e_selection_empty=Selection does not containt PostgreSQL procedure
PgSqlLaunchShortcut_select_procedure_message=Select &PostgreSQL Procedure (? = any character, * = any String):
PgSqlLaunchShortcut_select_procedure_title=Select PostgreSQL Procedure
PgSqlLaunchShortcut_name=PL/pgSQL
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册