use of org.eclipse.swt.widgets.Display in project cubrid-manager by CUBRID.
the class ConnectDatabaseExecutor method internalConnect.
private boolean internalConnect(String brokerIP, String brokerPort, String dbName, String userName, String password, String charset, String jdbcAttrs, String driverVersion, boolean autoCommit, boolean isShard) {
Display display = Display.getDefault();
CUBRIDConnectionProxy connection = null;
try {
connection = (CUBRIDConnectionProxy) JDBCConnectionManager.getConnection(brokerIP, brokerPort, dbName, userName, password, charset, jdbcAttrs, driverVersion, autoCommit, isShard);
if (connection == null) {
display.syncExec(new Runnable() {
public void run() {
CommonUITool.openErrorBox(Messages.msgConnectBrokerFailure);
}
});
return false;
}
String jdbcVersion = connection.getJdbcVersion();
jdbcVersion = jdbcVersion == null ? "" : jdbcVersion.replaceAll("CUBRID-JDBC-", "");
if (jdbcVersion.lastIndexOf(".") > 0) {
jdbcVersion = jdbcVersion.substring(0, jdbcVersion.lastIndexOf("."));
}
String dbVersion = connection.getMetaData().getDatabaseProductVersion();
dbVersion = dbVersion == null ? "" : dbVersion;
String minorDbVersion = dbVersion;
if (minorDbVersion.lastIndexOf(".") > 0) {
minorDbVersion = minorDbVersion.substring(0, minorDbVersion.lastIndexOf("."));
}
if (CompatibleUtil.compareVersion(jdbcVersion, minorDbVersion) == 0) {
return true;
} else {
final String finalDbVersion = dbVersion;
display.syncExec(new Runnable() {
public void run() {
isConnectSuccess = CommonUITool.openConfirmBox(Messages.bind(Messages.tipNoSupportJdbcVersion, finalDbVersion));
}
});
return isConnectSuccess;
}
} catch (final SQLException e) {
LOGGER.error(e.getMessage(), e);
display.syncExec(new Runnable() {
public void run() {
CommonUITool.openErrorBox(Messages.bind(Messages.errCommonTip, e.getErrorCode(), e.getMessage()));
}
});
return false;
} catch (final Exception e) {
display.syncExec(new Runnable() {
public void run() {
CommonUITool.openErrorBox(e.getMessage());
}
});
return false;
} finally {
if (connection != null) {
try {
connection.close();
} catch (SQLException e) {
LOGGER.error(e.getMessage());
}
}
}
}
use of org.eclipse.swt.widgets.Display in project cubrid-manager by CUBRID.
the class StartDatabaseAction method doRun.
public void doRun(ISchemaNode[] schemaArray) {
if (schemaArray == null || schemaArray.length == 0) {
return;
}
List<ISchemaNode> startList = new ArrayList<ISchemaNode>();
/*Judge start job is running*/
for (ISchemaNode node : schemaArray) {
if (!isSupported(node)) {
setEnabled(false);
return;
}
CubridDatabase database = node.getDatabase();
final JobFamily jobFamily = new JobFamily();
String serverName = database.getServer().getName();
String dbName = database.getName();
jobFamily.setServerName(serverName);
jobFamily.setDbName(dbName);
Job[] jobs = Job.getJobManager().find(jobFamily);
if (jobs.length > 0) {
CommonUITool.openWarningBox(Messages.bind(Messages.msgStartDbWithJob, dbName));
continue;
}
startList.add(database);
}
CubridNavigatorView navigationView = CubridNavigatorView.findNavigationView();
if (navigationView != null && startList.size() > 0) {
final TreeViewer treeViewer = navigationView.getViewer();
TaskExecutor taskExcutor = new TaskExecutor() {
public boolean exec(final IProgressMonitor monitor) {
Display display = Display.getDefault();
if (monitor.isCanceled()) {
return false;
}
for (int i = 0; i < taskList.size(); i++) {
ITask task = taskList.get(i);
final CubridDatabase database = (CubridDatabase) task.getData("dbName");
if (!isSupported(database)) {
continue;
}
monitor.subTask(Messages.bind(Messages.startDbTaskName, database.getName()));
task.execute();
if (openErrorBox(shell, task.getErrorMsg(), monitor) || monitor.isCanceled()) {
return false;
}
openWarningBox(shell, task.getWarningMsg(), monitor);
if (monitor.isCanceled()) {
return false;
}
database.removeAllChild();
if (database.getLoader() != null) {
database.getLoader().setLoaded(false);
}
database.setRunningType(DbRunningType.CS);
display.syncExec(new Runnable() {
public void run() {
treeViewer.refresh(database, true);
}
});
if (monitor.isCanceled()) {
return false;
}
}
return true;
}
};
for (ISchemaNode schemaNode : startList) {
CubridDatabase database = schemaNode.getDatabase();
if (!isSupported(database)) {
setEnabled(false);
return;
}
ServerInfo serverInfo = database.getServer().getServerInfo();
CommonUpdateTask task = new CommonUpdateTask(CommonTaskName.START_DB_TASK_NAME, serverInfo, CommonSendMsg.getCommonDatabaseSendMsg());
task.setDbName(database.getLabel());
task.putData("dbName", database);
taskExcutor.addTask(task);
}
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
ActionManager.getInstance().fireSelectionChanged(getSelection());
}
}
use of org.eclipse.swt.widgets.Display in project dbeaver by serge-rider.
the class DBeaverIcons method getViewMenuImage.
public static synchronized Image getViewMenuImage() {
if (viewMenuImage == null) {
Display d = Display.getCurrent();
Image viewMenu = new Image(d, 16, 16);
Image viewMenuMask = new Image(d, 16, 16);
Display display = Display.getCurrent();
GC gc = new GC(viewMenu);
GC maskgc = new GC(viewMenuMask);
gc.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
gc.setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));
int[] shapeArray = new int[] { 6, 3, 15, 3, 11, 7, 10, 7 };
gc.fillPolygon(shapeArray);
gc.drawPolygon(shapeArray);
Color black = display.getSystemColor(SWT.COLOR_BLACK);
Color white = display.getSystemColor(SWT.COLOR_WHITE);
maskgc.setBackground(black);
maskgc.fillRectangle(0, 0, 16, 16);
maskgc.setBackground(white);
maskgc.setForeground(white);
maskgc.fillPolygon(shapeArray);
maskgc.drawPolygon(shapeArray);
gc.dispose();
maskgc.dispose();
ImageData data = viewMenu.getImageData();
data.transparentPixel = data.getPixel(0, 0);
viewMenuImage = new Image(d, viewMenu.getImageData(), viewMenuMask.getImageData());
viewMenu.dispose();
viewMenuMask.dispose();
}
return viewMenuImage;
}
use of org.eclipse.swt.widgets.Display in project cubrid-manager by CUBRID.
the class RecordAction method runWithEvent.
/**
* Shifting the recordFlag and return the the interface of Recordable.
*
* @param event the SWT event which triggered this action being run
*/
public void runWithEvent(final Event event) {
recordFlag = recorder.getRecordFlag();
recordFlag = !recordFlag;
recorder.setRecordFlag(recordFlag);
final Display display = Display.getDefault();
Runnable runnable = new Runnable() {
boolean state = false;
public void run() {
if (state) {
((ToolItem) (event.widget)).setImage(CubridManagerUIPlugin.getImage("icons/monitor/record_bright.png"));
} else {
((ToolItem) (event.widget)).setImage(CubridManagerUIPlugin.getImage("icons/monitor/record_dim.png"));
}
state = !state;
if (recordFlag) {
display.timerExec(800, this);
} else {
display.timerExec(-1, this);
((ToolItem) (event.widget)).setImage(CubridManagerUIPlugin.getImage("icons/monitor/prepare_record.png"));
}
}
};
if (recordFlag) {
this.setImageDescriptor(CubridManagerUIPlugin.getImageDescriptor("icons/monitor/record_bright.png"));
this.setToolTipText(recordTooltip);
display.timerExec(20, runnable);
} else {
this.setImageDescriptor(CubridManagerUIPlugin.getImageDescriptor("icons/monitor/prepare_record.png"));
this.setToolTipText(prepareTooltip);
}
}
use of org.eclipse.swt.widgets.Display in project cubrid-manager by CUBRID.
the class FontGroup method updateColorImage.
/**
* Update the image being displayed on the button using the current color
* setting.
*/
private void updateColorImage() {
Display display = fontColorLbl.getDisplay();
Color fColor = new Color(display, chosenRgb);
fontColorLbl.setBackground(fColor);
}
Aggregations