use of com.cubrid.common.ui.query.control.CombinedQueryEditorComposite in project cubrid-manager by CUBRID.
the class CheckQueryEditorTask method doSave.
public void doSave() {
ApplicationPersistUtil.getInstance().clearAllEditorStatus();
Display.getDefault().syncExec(new Runnable() {
public void run() {
Date createTime = new Date();
List<QueryEditorPart> editorPartList = QueryEditorUtil.getAllQueryEditorPart();
for (QueryEditorPart editor : editorPartList) {
ArrayList<RestorableQueryEditorInfo> sqlTabItemList = new ArrayList<RestorableQueryEditorInfo>();
for (CombinedQueryEditorComposite combinedQueryEditorComposite : editor.getAllCombinedQueryEditorComposite()) {
StyledText text = combinedQueryEditorComposite.getSqlEditorComp().getText();
if (text == null) {
LOGGER.warn("The editor.getSqlTextEditor() is a null.");
continue;
}
if (StringUtil.isEmpty(text.getText())) {
LOGGER.warn("The text.getText() is a null.");
continue;
}
CubridDatabase cubridDatabase = editor.getSelectedDatabase();
RestorableQueryEditorInfo editorStatus = new RestorableQueryEditorInfo();
if (cubridDatabase != null) {
DatabaseInfo dbInfo = cubridDatabase.getDatabaseInfo();
if (dbInfo != null) {
editorStatus.setDatabaseName(dbInfo.getDbName());
}
CubridServer cubridServer = cubridDatabase.getServer();
if (cubridServer != null) {
editorStatus.setServerName(cubridServer.getId());
}
}
editorStatus.setQueryContents(text.getText());
editorStatus.setCreatedTime(createTime);
sqlTabItemList.add(editorStatus);
}
ApplicationPersistUtil.getInstance().addEditorStatus(sqlTabItemList);
}
}
});
ApplicationPersistUtil.getInstance().save();
}
use of com.cubrid.common.ui.query.control.CombinedQueryEditorComposite in project cubrid-manager by CUBRID.
the class QueryEditorPart method getAllCombinedQueryEditorComposite.
public List<CombinedQueryEditorComposite> getAllCombinedQueryEditorComposite() {
List<CombinedQueryEditorComposite> combinedQueryEditorCompositeList = new ArrayList<CombinedQueryEditorComposite>();
CTabItem[] items = combinedQueryEditortabFolder.getItems();
for (CTabItem item : items) {
if (item instanceof SubQueryEditorTabItem) {
CombinedQueryEditorComposite combinedQueryEditorComposite = ((SubQueryEditorTabItem) item).getControl();
combinedQueryEditorCompositeList.add(combinedQueryEditorComposite);
}
}
return combinedQueryEditorCompositeList;
}
use of com.cubrid.common.ui.query.control.CombinedQueryEditorComposite in project cubrid-manager by CUBRID.
the class QueryEditorPart method refreshQueryOptions.
// /**
// * Set query connection
// *
// * @param queryConn Connection
// */
// public void setQueryConn(Connection queryConn) {
// this.queryConn = queryConn;
// }
/**
* When query options change or database and server refresh, refresh this
* query style
*/
public void refreshQueryOptions() {
CubridDatabase database = getSelectedDatabase();
boolean enabled = (database != DatabaseNavigatorMenu.NULL_DATABASE);
if (enabled && !connection.hasConnection()) {
this.initConnection(database);
}
enabled = enabled && connection.hasConnection();
if (enabled) {
for (CombinedQueryEditorComposite combinedQueryEditorComposite : getAllCombinedQueryEditorComposite()) {
combinedQueryEditorComposite.getMultiDBQueryComp().setMainDatabase(database);
}
}
queryPlanItem.setEnabled(enabled);
setPstmtParaItem.setEnabled(enabled);
ServerInfo serverInfo = getSelectedServer() == null ? null : getSelectedServer().getServerInfo();
String fontString = QueryOptions.getFontString(serverInfo);
Font font = ResourceManager.getFont(fontString);
if (font == null) {
String[] fontData = QueryOptions.getDefaultFont();
font = ResourceManager.getFont(fontData[0], Integer.valueOf(fontData[1]), Integer.valueOf(fontData[2]));
}
int[] fontColor = QueryOptions.getFontColor(serverInfo);
final Color color = ResourceManager.getColor(fontColor[0], fontColor[1], fontColor[2]);
// Change SQL editor font
if (font != null) {
getSqlTextEditor().setFont(font);
}
getSqlTextEditor().setForeground(color);
for (CombinedQueryEditorComposite combinedQueryEditorComposite : getAllCombinedQueryEditorComposite()) {
combinedQueryEditorComposite.getSqlEditorComp().getTextViewer().refresh();
// Change the table result font
QueryResultComposite queryResultComp = combinedQueryComposite.getQueryResultComp();
if (queryResultComp == null || queryResultComp.isDisposed()) {
return;
}
Table resultTable = queryResultComp.getResultTable();
if (resultTable != null && !resultTable.isDisposed()) {
resultTable.setFont(font);
resultTable.setForeground(color);
}
// Update editor config
if (database != null) {
DatabaseEditorConfig editorConfig = QueryOptions.getEditorConfig(database, isCMMode);
if (editorConfig != null && editorConfig.getBackGround() != null) {
setEditorBackground(ResourceManager.getColor(editorConfig.getBackGround()));
} else {
setEditorBackground(ResourceManager.getColor(EditorConstance.getDefaultBackground()));
}
}
//query plan
combinedQueryComposite.getQueryPlanResultComp().fillPlanHistory();
//sql history
combinedQueryComposite.getRecentlyUsedSQLComposite().fillRecentlyUsedSQLList();
/*Fire database changed*/
combinedQueryComposite.fireDatabaseChanged(database);
}
}
use of com.cubrid.common.ui.query.control.CombinedQueryEditorComposite in project cubrid-manager by CUBRID.
the class InformationWindow method updateLocation.
/**
* Update the location
*/
public void updateLocation() {
int x = 0, y = 0;
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null || window.getActivePage() == null) {
return;
}
Shell windowShell = this.getShell();
if (windowShell == null) {
InfoWindowManager.dispose();
return;
}
IEditorPart editPart = window.getActivePage().getActiveEditor();
if (editPart != null && editPart instanceof QueryEditorPart) {
QueryEditorPart queryEditorPart = (QueryEditorPart) editPart;
CombinedQueryEditorComposite combinedComposite = queryEditorPart.getCombinedQueryComposite();
if (combinedComposite != null && !combinedComposite.isDisposed()) {
Rectangle compositeBounds = combinedComposite.getBounds();
if (compositeBounds.width < width + horizonalMargin || compositeBounds.height < height + verticalMargin) {
windowShell.setVisible(false);
return;
}
Point size = infoText.computeSize(SWT.DEFAULT, SWT.DEFAULT);
width = size.x;
height = size.y;
Point endLocation = Display.getCurrent().map(combinedComposite, null, new Point(compositeBounds.width, compositeBounds.height));
x = endLocation.x - width - horizonalMargin;
y = endLocation.y - height - verticalMargin;
windowShell.setBounds(x, y, width, height);
if (StringUtil.isEmpty(infoText.getText())) {
windowShell.setVisible(false);
} else {
windowShell.setVisible(true);
}
}
}
}
use of com.cubrid.common.ui.query.control.CombinedQueryEditorComposite in project cubrid-manager by CUBRID.
the class QueryEditorPart method addEditorTab.
public CombinedQueryEditorComposite addEditorTab() {
final SubQueryEditorTabItem subQueryEditorTabItem = new SubQueryEditorTabItem(combinedQueryEditortabFolder, SWT.NONE);
subQueryEditorTabItem.setTabIndex(sqlEditorCounter++);
updateTabName(subQueryEditorTabItem, false);
subQueryEditorTabItem.setToolTipText(Messages.queryEditorTabItemTooltip);
subQueryEditorTabItem.setShowClose(true);
// When clicking the close button on a tab
subQueryEditorTabItem.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
if (!willClose && combinedQueryEditortabFolder.getItemCount() == 0) {
sqlEditorCounter = 1;
addEditorTab();
}
}
});
combinedQueryComposite = new CombinedQueryEditorComposite(combinedQueryEditortabFolder, SWT.None, this, subQueryEditorTabItem);
subQueryEditorTabItem.setControl(combinedQueryComposite);
combinedQueryComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
combinedQueryComposite.setTopSashWidth();
combinedQueryComposite.refreshEditorComposite();
dragController.registerDropTarget(combinedQueryComposite);
combinedQueryEditortabFolder.setSelection(subQueryEditorTabItem);
if (combinedQueryEditortabFolder.getItemCount() > 1) {
InfoWindowManager.getInstance().updateContent(QueryEditorPart.this);
}
refreshQueryOptions();
return combinedQueryComposite;
}
Aggregations