/** * Create an image descriptor for the given image property in the text.properties file. * * @param propertyName * @return */ public static ImageDescriptor getDescriptor(String propertyName) { try { if (propertyName == null) { return null; } // get image path String path = Messages.getString(propertyName); if (path == null || path.trim().length() == 0) { SqlBuilderPlugin.log( Messages.getString("ImageUtil.logMessage2", propertyName), null); // $NON-NLS-1$ return null; } // create image URL url = URLUtil.getResourceURL(path); return ImageDescriptor.createFromURL(url); } catch (Exception e) { SqlBuilderPlugin.log( Messages.getString("ImageUtil.logMessage3", propertyName), e); // $NON-NLS-1$ return null; } }
/* * (non-Java) * * @see org.talend.sqlbuilder.actions.AbstractEditorAction#getText() */ @Override public String getText() { if (isDesigner) { return Messages.getString("GUIModificationQueryAction.TextDialog.TitleText"); // $NON-NLS-1$ } return Messages.getString("GUIModificationQueryAction.ButtonText"); // $NON-NLS-1$ }
/** * OpenNewEditorAction constructor. * * @param selectionProvider * @param editorComposite * @param connParam * @param isQuery */ public OpenNewEditorAction( TreeViewer selectionProvider, ISQLBuilderDialog dialog, ConnectionParameters connParam, boolean isQuery) { super( selectionProvider, Messages.getString("OpenNewEditorAction.textNewEditor")); // $NON-NLS-1$ setText(Messages.getString("DBStructureComposite.NewEditor")); // $NON-NLS-1$ setToolTipText(Messages.getString("DBStructureComposite.NewEditor")); // $NON-NLS-1$ this.dialog = dialog; this.selectionProvider = selectionProvider; this.connParam = connParam; this.isQuery = isQuery; init(); }
/** * Dispose of an image in cache. Once there are no more open handles to the image it will be * disposed of. */ @SuppressWarnings("unchecked") // $NON-NLS-1$ public static void disposeImage(String propertyName) { try { Image image = (Image) pimages.get(propertyName); if (image == null) { return; } image.dispose(); pimages.remove(propertyName); // decrease image handle count by one Integer handleCount = (Integer) pimageCount.get(propertyName); if (handleCount == null) { handleCount = new Integer(0); } else { handleCount = new Integer(handleCount.intValue() - 1); } pimageCount.put(propertyName, handleCount); } catch (Throwable e) { SqlBuilderPlugin.log(Messages.getString("ImageUtil.logMessage1"), e); // $NON-NLS-1$ } }
public static ImageDescriptor getFragmentDescriptor(String fragmentId, String path) { try { if (path == null || path.trim().length() == 0) { return null; } // create image URL url = URLUtil.getFragmentResourceURL(fragmentId, path); return ImageDescriptor.createFromURL(url); } catch (Exception e) { SqlBuilderPlugin.log( Messages.getString("ImageUtil.logMessage3") + fragmentId + ": " + path, e); //$NON-NLS-1$ //$NON-NLS-2$ return null; } }
/* * (non-Java) * * @see org.talend.sqlbuilder.actions.AbstractEditorAction#run() */ @Override public void run() { currentSql = getEditor().getSQLToBeExecuted(); // QueryTokenizer qt = new QueryTokenizer(currentSql, queryDelimiter, alternateDelimiter, // commentDelimiter); // List<String> queryStrings = new ArrayList<String>(); // while (qt.hasQuery()) { // String querySql = qt.nextQuery(); // // ignore commented lines. // if (!querySql.startsWith("--")) { //$NON-NLS-1$ // queryStrings.add(querySql); // } // } // if (queryStrings.size() < 1) { // MessageDialog.openError(new Shell(), "Notice", "You must input one Sql Statement!"); // return; // } // if (queryStrings.size() > 1) { // isForce = MessageDialog.openQuestion(new Shell(), "Notice", // "You only modify first Sql Statement by GUI, Would you like to continue?"); // } // String string = queryStrings.get(0).toLowerCase().replaceAll("\n", " "); // string.replaceAll("\t", " "); // if (!string.startsWith("select ")) { // MessageDialog.openError(new Shell(), "Notice", "GUI Sql Editor only use for 'select' // Statement !"); // return; // } // if (isForce != null && !isForce.booleanValue()) { // return; // } if (dialog instanceof SQLBuilderDialog) { SQLBuilderDialog d = (SQLBuilderDialog) dialog; final CTabItem selection = d.getEditorComposite().getTabFolder().getSelection(); if (selection.getData("KEY") instanceof MultiPageSqlBuilderEditor) { // $NON-NLS-1$ MultiPageSqlBuilderEditor editor = (MultiPageSqlBuilderEditor) selection.getData("KEY"); // $NON-NLS-1$ switch (editor.getActivePage()) { case 1: isDesigner = true; break; default: isDesigner = false; break; } } } String query = null; if (isDesigner) { SqlEditDialog textDialog = new SqlEditDialog( dialog.getShell(), Messages.getString("GUIModificationQueryAction.TextDialog.TitleText"), currentSql, currentNode); //$NON-NLS-1$ if (Window.OK == textDialog.open()) { query = textDialog.getSql(); } } else { List<IRepositoryNode> selectedNodes = null; try { selectedNodes = EMFRepositoryNodeManager.getInstance().parseSqlStatement(currentSql, currentNode); } catch (Exception e) { MessageDialog.openError( new Shell(), Messages.getString("GUIModificationQueryAction.Error.Notice"), Messages.getString( "GUIModificationQueryAction.SqlStatement.ErrorMsg")); //$NON-NLS-1$ //$NON-NLS-2$ } if (selectedNodes == null) { return; } // String info = Messages.getString("MultiPageSqlBuilderEditor.Notice.InformationNotFull"); // MessageDialog.openInformation(new Shell(), // Messages.getString("GUIModificationQueryAction.Information.Msg"), info); //$NON-NLS-1$ ErDiagramDialog erDiagramDialog = new ErDiagramDialog( dialog.getShell(), Messages.getString("GUIModificationQueryAction.Dialog.TitleText"), currentNode); //$NON-NLS-1$ erDiagramDialog.setDialog(dialog); erDiagramDialog.setNodes(selectedNodes); erDiagramDialog.setSqlText(currentSql); EMFRepositoryNodeManager.getInstance().setRoot(currentNode); if (Window.OK == erDiagramDialog.open()) { query = erDiagramDialog.getSql(); } } if (query == null) { return; } if (!query.endsWith(";\n") && !query.endsWith(";")) { // $NON-NLS-1$ //$NON-NLS-2$ query += ";\n"; // $NON-NLS-1$ } String targetSql = ""; // $NON-NLS-1$ boolean isfirst = true; QueryTokenizer qt = new QueryTokenizer(currentSql, queryDelimiter, alternateDelimiter, commentDelimiter); while (qt.hasQuery()) { String querySql = qt.nextQuery(); if (querySql.startsWith("--") || !isfirst) { // $NON-NLS-1$ targetSql += querySql + ";\n"; // $NON-NLS-1$ } else { targetSql += query; isfirst = false; } } if (!qt.hasQuery()) { targetSql = query; } // currentSql = currentSql.replaceFirst(queryStrings.get(0), query); getEditor().setEditorContent(targetSql); }
/* * (non-Javadoc) * * @see org.talend.sqlbuilder.actions.AbstractEditorAction#getToolTipText() */ public String getToolTipText() { return Messages.getString("SQLEditor.Actions.SaveSQLToolTip"); // $NON-NLS-1$ }
public String getStatusMessage() { return Messages.getString( "DatabaseDetailView.Tab.ColumnInfo.status", getNode().getQualifiedName()); // $NON-NLS-1$ }
public String getLabelText() { return Messages.getString("DatabaseDetailView.Tab.ColumnInfo"); // $NON-NLS-1$ }