use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.
the class BrokerEnvStatusView method createTable.
/**
* This method initializes table
*
*/
private void createTable() {
tableViewer = new TableViewer(composite, SWT.FULL_SELECTION);
tableViewer.getTable().setHeaderVisible(true);
tableViewer.getTable().setLinesVisible(true);
BrokerTblColumnSetHelp bcsh = BrokerTblColumnSetHelp.getInstance();
bcsh.loadSetting(BrokerTblColumnSetHelp.StatusColumn.BrokerEnvStatusColumn, BrokerEnvStatusColumn.values());
TableLayout tlayout = new TableLayout();
for (BrokerEnvStatusColumn column : BrokerEnvStatusColumn.values()) {
if (column.getValue() == -1) {
tlayout.addColumnData(new ColumnWeightData(0, 0, false));
} else {
tlayout.addColumnData(new ColumnWeightData(10, 40, true));
}
}
tableViewer.getTable().setLayout(tlayout);
tableViewer.getTable().addMouseListener(new MouseAdapter() {
public void mouseDoubleClick(MouseEvent event) {
int index = -1;
if ((index = tableViewer.getTable().getSelectionIndex()) >= 0) {
TableItem tableItem = tableViewer.getTable().getItem(index);
String brokename = tableItem.getText(0).trim();
ICubridNode input = null;
for (ICubridNode node : cubridNode.getChildren()) {
if (node.getLabel().equalsIgnoreCase(brokename)) {
input = node;
break;
}
}
LayoutManager.getInstance().setCurrentSelectedNode(input);
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (null == window) {
return;
}
IWorkbenchPage activePage = window.getActivePage();
IViewPart viewPart = window.getActivePage().findView(BrokerStatusView.ID);
if (null != viewPart) {
activePage.hideView(viewPart);
}
try {
activePage.showView(BrokerStatusView.ID);
} catch (PartInitException e1) {
LOGGER.error(e1.getMessage(), e1);
}
}
}
});
makeTableColumn();
tableViewer.setContentProvider(new BrokersStatusContentProvider());
ServerInfo serverInfo = cubridNode.getServer().getServerInfo();
BrokersStatusLabelProvider brokersStatusLabelProvider = new BrokersStatusLabelProvider();
brokersStatusLabelProvider.setServerInfo(serverInfo);
tableViewer.setLabelProvider(brokersStatusLabelProvider);
}
use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.
the class QueryNewCustomAction method run.
/**
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
Object[] selected = getSelectedObj();
LoginQueryEditDialog dialog = new LoginQueryEditDialog(getShell());
if (selected != null && selected.length == 1 && selected[0] instanceof ISchemaNode) {
dialog.setSelServerName(((ISchemaNode) selected[0]).getServer().getServerName());
dialog.setSelDatabaseName(((ISchemaNode) selected[0]).getDatabase().getName());
} else if (selected != null && selected.length == 1 && selected[0] instanceof CubridServer) {
dialog.setSelServerName(((CubridServer) selected[0]).getName());
} else {
dialog.setSelServerName(DatabaseNavigatorMenu.SELF_DATABASE_SELECTED_LABEL);
}
if (dialog.open() == IDialogConstants.OK_ID) {
try {
IEditorInput input = new QueryUnit();
IEditorPart editor = window.getActivePage().openEditor(input, QueryEditorPart.ID);
((QueryEditorPart) editor).connect(DatabaseNavigatorMenu.SELF_DATABASE);
} catch (PartInitException e) {
LOGGER.error(e.getMessage());
}
}
}
use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.
the class EditBrokerConfigAction method run.
public void run() {
final Object[] obj = this.getSelectedObj();
if (obj == null || obj.length <= 0) {
setEnabled(false);
return;
}
CubridServer server = null;
if (obj[0] instanceof CubridServer) {
server = (CubridServer) obj[0];
} else if (obj[0] instanceof CubridBrokerFolder) {
server = ((CubridBrokerFolder) obj[0]).getServer();
}
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null || server == null) {
return;
}
ConfEditInput editorInput = new ConfEditInput();
String id = ConfigType.CUBRID_BROKER.getValue() + "&" + server.getId();
editorInput.setId(id);
editorInput.setServerInfo(server.getServerInfo());
editorInput.setName(server.getName());
editorInput.setServerName(server.getServerName());
editorInput.setServerPort(server.getMonPort());
String[] tipMsg = new String[] { ConfigType.CUBRID_BROKER.getValue(), server.getName(), server.getServerName(), server.getMonPort() };
String toolTipText = Messages.bind(Messages.msgEditorTooltip, tipMsg);
editorInput.setToolTipText(toolTipText);
try {
window.getActivePage().openEditor(editorInput, EditCMCubridBrokerConfPart.ID);
} catch (Exception ex) {
LOGGER.error("", ex);
}
}
use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.
the class HostDashboardAction method getOpenedEditorPart.
/**
* Get all opened query editor
*
* @return
*/
private HostDashboardEditor getOpenedEditorPart(String serverName) {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return null;
}
IEditorReference[] editorReferences = window.getActivePage().getEditorReferences();
for (IEditorReference reference : editorReferences) {
if (reference.getId().equals(HostDashboardEditor.ID)) {
HostDashboardEditor editor = (HostDashboardEditor) reference.getEditor(false);
if (editor != null && editor.getServerInfo() != null && editor.getServerInfo().getServerName().equals(serverName)) {
return editor;
}
}
}
return null;
}
use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.
the class HostDashboardAction method doRun.
public void doRun(ServerInfo serverInfo) {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (null == window) {
return;
}
// Check it open same editor
HostDashboardEditor editorPart = getOpenedEditorPart(serverInfo.getServerName());
if (editorPart == null) {
HostDashboardEditorInput editorInput = new HostDashboardEditorInput(serverInfo);
editorInput.setName(serverInfo.getServerName());
editorInput.setToolTipText(serverInfo.getServerName());
try {
editorPart = (HostDashboardEditor) window.getActivePage().openEditor(editorInput, HostDashboardEditor.ID);
} catch (PartInitException ex) {
LOGGER.error(ex.getMessage());
}
} else {
window.getActivePage().activate(editorPart);
editorPart.loadAllData();
}
}
Aggregations