use of org.eclipse.ui.IWorkbenchWindow in project tdi-studio-se by Talend.
the class CodeGeneratorService method refreshTemplates.
/*
* (non-Javadoc)
*
* @see org.talend.designer.codegen.ICodeGeneratorService#refreshTemplates()
*/
@Override
public Job refreshTemplates() {
Element oldComponent = null;
IComponentSettingsView viewer = null;
if (!CommonUIPlugin.isFullyHeadless()) {
// TDI-25866:In case select a component and sctrl+shift+f3,need clean its componentSetting view
IWorkbenchWindow wwindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (wwindow != null && wwindow.getActivePage() != null) {
viewer = (IComponentSettingsView) wwindow.getActivePage().findView(IComponentSettingsView.ID);
if (viewer != null) {
oldComponent = viewer.getElement();
viewer.cleanDisplay();
}
}
}
ComponentCompilations.deleteMarkers();
ComponentsFactoryProvider.getInstance().resetCache();
ILibraryManagerService librairesManagerService = (ILibraryManagerService) GlobalServiceRegister.getDefault().getService(ILibraryManagerService.class);
librairesManagerService.clearCache();
CorePlugin.getDefault().getLibrariesService().syncLibraries();
Job job = CodeGeneratorEmittersPoolFactory.initialize();
// achen modify to record ctrl+shift+f3 is pressed to fix bug 0006107
IDesignerCoreService designerCoreService = (IDesignerCoreService) GlobalServiceRegister.getDefault().getService(IDesignerCoreService.class);
designerCoreService.getLastGeneratedJobsDateMap().clear();
if (oldComponent != null && viewer != null) {
viewer.setElement(oldComponent);
}
if (!CommonUIPlugin.isFullyHeadless()) {
CorePlugin.getDefault().getDesignerCoreService().synchronizeDesignerUI(new PropertyChangeEvent(this, IComponentConstants.NORMAL, null, null));
}
return job;
}
use of org.eclipse.ui.IWorkbenchWindow in project ACS by ACS-Community.
the class AlarmsView method createFFWidgets.
private void createFFWidgets() {
_updateFaultFamily = new Listener() {
public void handleEvent(Event event) {
TreeItem tmp = _tree.getSelection()[0];
String ff = tmp.getText();
FaultFamily fft = new FaultFamily();
//TODO: Error icon or something similar
if (_ffNameText.getText().isEmpty()) {
_ffErrorMessageLabel.setText("FaultFamily Name Missing!");
return;
}
if (_ffNameText.getText().contains(" ")) {
_ffErrorMessageLabel.setText("Invalid FaultFamily Name. No spaces allowed.");
return;
}
fft.setName(_ffNameText.getText());
if (!_ffHelpURLText.getText().isEmpty()) {
URI hurl;
try {
hurl = new URI(_ffHelpURLText.getText());
} catch (MalformedURIException e1) {
_ffErrorMessageLabel.setText("Malformed URL!");
return;
}
fft.setHelpUrl(hurl.toString());
}
fft.setAlarmSource(_ffSourceCombo.getText());
Contact ct = new Contact();
if (_ffContactNameText.getText().isEmpty()) {
_ffErrorMessageLabel.setText("Contact Name Missing!");
return;
}
ct.setName(_ffContactNameText.getText());
if (!_ffContactMailText.getText().isEmpty())
ct.setEmail(_ffContactMailText.getText());
if (!_ffContactGSMText.getText().isEmpty())
ct.setGsm(_ffContactGSMText.getText());
fft.setContact(ct);
_ffErrorMessageLabel.setText("");
try {
_alarmManager.updateFaultFamily(_alarmManager.getFaultFamily(ff), fft);
tmp.setText(_ffNameText.getText());
IWorkbenchWindow _window = getViewSite().getWorkbenchWindow();
IViewReference[] views = _window.getActivePage().getViewReferences();
IMyViewPart view = ((IMyViewPart) views[2].getView(false));
view.fillWidgets();
if (ff.compareTo(fft.getName()) != 0) {
sortFaultFamilyList();
selectElementFromTree(fft.getName(), null, null);
}
} catch (IllegalOperationException e) {
_ffErrorMessageLabel.setText(e.getMessage());
} catch (NullPointerException e) {
e.printStackTrace();
_ffErrorMessageLabel.setText(e.getMessage());
}
}
};
_addCategory = new Listener() {
public void handleEvent(Event event) {
if (event.type == SWT.KeyUp)
if (!(event.keyCode == SWT.CR || event.keyCode == ' '))
return;
if (event.type == SWT.MouseDoubleClick) {
Point pt = new Point(event.x, event.y);
if (_ffCategoryList.getItem(pt) == null)
return;
}
TreeItem[] tmp1 = _tree.getSelection();
if (tmp1 == null || tmp1.length == 0)
return;
String ff = tmp1[0].getText();
TableItem[] tmp2 = _ffCategoryList.getSelection();
if (tmp2 == null || tmp2.length == 0)
return;
TableItem item = tmp2[0];
Category c = _categoryManager.getCategoryByPath(item.getText());
try {
String[] ffs = c.getAlarms().getFaultFamily();
for (int i = 0; i < ffs.length; i++) {
if (ff.compareTo(ffs[i]) == 0) {
c.getAlarms().removeFaultFamily(ff);
item.setImage((org.eclipse.swt.graphics.Image) null);
IWorkbenchWindow _window = getViewSite().getWorkbenchWindow();
IViewReference[] views = _window.getActivePage().getViewReferences();
IMyViewPart view = ((IMyViewPart) views[2].getView(false));
view.fillWidgets();
return;
}
}
c.getAlarms().addFaultFamily(ff);
item.setImage(Activator.getDefault().getImageRegistry().get(Activator.IMG_TICKET));
} catch (NullPointerException e) {
item.setImage((org.eclipse.swt.graphics.Image) null);
Alarms alarms = new Alarms();
alarms.addFaultFamily(ff.toString());
alarms.setFaultFamily(0, ff.toString());
c.setAlarms(alarms);
item.setImage(Activator.getDefault().getImageRegistry().get(Activator.IMG_TICKET));
}
IWorkbenchWindow _window = getViewSite().getWorkbenchWindow();
IViewReference[] views = _window.getActivePage().getViewReferences();
IMyViewPart view = ((IMyViewPart) views[2].getView(false));
view.fillWidgets();
}
};
_FFgroup = new Group(_compInitial, SWT.SHADOW_ETCHED_IN);
_FFgroup.setText("Fault Family details");
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
_FFgroup.setLayoutData(gd);
GridLayout gl = new GridLayout();
gl.numColumns = 2;
_FFgroup.setLayout(gl);
_ffNameLabel = new Label(_FFgroup, SWT.NONE);
_ffNameLabel.setText("Fault Family name");
_ffNameText = new Text(_FFgroup, SWT.SINGLE | SWT.BORDER);
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
_ffNameText.setLayoutData(gd);
_ffNameText.addListener(SWT.Modify, _updateFaultFamily);
_ffHelpURLLabel = new Label(_FFgroup, SWT.NONE);
_ffHelpURLLabel.setText("Help URL");
_ffHelpURLText = new Text(_FFgroup, SWT.SINGLE | SWT.BORDER);
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
_ffHelpURLText.setLayoutData(gd);
_ffHelpURLText.addListener(SWT.Modify, _updateFaultFamily);
_ffContactNameLabel = new Label(_FFgroup, SWT.NONE);
_ffContactNameLabel.setText("Contact name");
_ffContactNameText = new Text(_FFgroup, SWT.SINGLE | SWT.BORDER);
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
_ffContactNameText.setLayoutData(gd);
_ffContactNameText.addListener(SWT.Modify, _updateFaultFamily);
_ffContactMailLabel = new Label(_FFgroup, SWT.NONE);
_ffContactMailLabel.setText("Contact e-mail");
_ffContactMailText = new Text(_FFgroup, SWT.SINGLE | SWT.BORDER);
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
_ffContactMailText.setLayoutData(gd);
_ffContactMailText.addListener(SWT.Modify, _updateFaultFamily);
_ffContactGSMLabel = new Label(_FFgroup, SWT.NONE);
_ffContactGSMLabel.setText("Contact GSM");
_ffContactGSMText = new Text(_FFgroup, SWT.SINGLE | SWT.BORDER);
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
_ffContactGSMText.setLayoutData(gd);
_ffContactGSMText.addListener(SWT.Modify, _updateFaultFamily);
_ffSourceLabel = new Label(_FFgroup, SWT.NONE);
_ffSourceLabel.setText("Source");
_ffSourceCombo = new Combo(_FFgroup, SWT.DROP_DOWN | SWT.READ_ONLY);
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
_ffSourceCombo.setLayoutData(gd);
_ffSourceCombo.setEnabled(false);
_ffSourceCombo.addListener(SWT.Modify, _updateFaultFamily);
_ffCategoryLabel = new Label(_FFgroup, SWT.NONE);
_ffCategoryLabel.setText("Categories:");
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.horizontalSpan = 2;
_ffCategoryLabel.setLayoutData(gd);
_ffCategoryList = new Table(_FFgroup, SWT.BORDER);
gd = new GridData();
gd.verticalAlignment = SWT.FILL;
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 2;
_ffCategoryList.setLayoutData(gd);
_ffCategoryList.addListener(SWT.KeyUp, _addCategory);
_ffCategoryList.addListener(SWT.MouseDoubleClick, _addCategory);
Menu categoryPopUp = new Menu(_ffCategoryList);
_ffCategoryList.setMenu(categoryPopUp);
categoryPopUp.addListener(SWT.Show, new Listener() {
public void handleEvent(Event e) {
TableItem[] sel = _ffCategoryList.getSelection();
Menu categoryPopUp = _ffCategoryList.getMenu();
MenuItem[] items = categoryPopUp.getItems();
for (int i = 0; i < items.length; i++) items[i].dispose();
if (sel == null || sel.length == 0)
return;
MenuItem mitem;
mitem = new MenuItem(categoryPopUp, SWT.PUSH);
if (sel[0].getImage() == null) {
mitem.setText("Add to Category");
mitem.addListener(SWT.Selection, _addCategory);
} else {
mitem.setText("Remove from Category");
mitem.addListener(SWT.Selection, _addCategory);
}
}
});
_ffErrorMessageLabel = new Label(_FFgroup, SWT.NONE);
_ffErrorMessageLabel.setText("");
_ffErrorMessageLabel.setForeground(getViewSite().getShell().getDisplay().getSystemColor(SWT.COLOR_RED));
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.horizontalSpan = 2;
_ffErrorMessageLabel.setLayoutData(gd);
}
use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.
the class PstmtOneDataDialog method showResultSet.
/**
*
* Open the query editor and show result set
*
* @param parameterList List<PstmtParameter>
*/
private void showResultSet(List<PstmtParameter> parameterList) {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
String querySql = sqlTxt.getText();
close();
IEditorPart editor = window.getActivePage().findEditor(editorInput);
if (editor == null) {
try {
editor = window.getActivePage().openEditor(editorInput, QueryEditorPart.ID);
} catch (PartInitException e) {
editor = null;
}
}
if (editor != null) {
window.getActivePage().bringToTop(editor);
QueryEditorPart queryEditor = ((QueryEditorPart) editor);
if (!queryEditor.isConnected() && database != null) {
queryEditor.connect(database);
}
String allInputSql = getCommentSqlValue(parameterList) + querySql;
List<List<PstmtParameter>> rowParameterList = new ArrayList<List<PstmtParameter>>();
rowParameterList.add(parameterList);
if (queryEditor.isConnected()) {
queryEditor.setQuery(allInputSql, querySql, rowParameterList, true, true, false);
}
}
}
use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.
the class OpenSchemaEditorAction method run.
/**
* Open the selected database Schema Editor. If basing on none-database
* node, open the ERD by a virtual database
*/
public void run() {
// FIXME move this logic to core module
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
Object[] obj = this.getSelectedObj();
CubridDatabase[] cubridDatabases = getDBNodes(obj);
for (int i = 0; i < cubridDatabases.length; i++) {
// multi db nodes
if (cubridDatabases[i].getDatabaseInfo() == null || !cubridDatabases[i].isLogined()) {
cubridDatabases[i] = ERVirtualDatabase.getInstance();
}
}
if (cubridDatabases.length == 0) {
// when right-click not database nodes
cubridDatabases = new CubridDatabase[1];
cubridDatabases[0] = ERVirtualDatabase.getInstance();
}
// Limit max number one time
if (cubridDatabases.length > LayoutUtil.MAX_OPEN_QUERY_EDITOR_NUM) {
CommonUITool.openConfirmBox(Messages.bind("SchemaDesigner max...", LayoutUtil.MAX_OPEN_QUERY_EDITOR_NUM));
List<CubridDatabase> list = new ArrayList<CubridDatabase>(LayoutUtil.MAX_OPEN_QUERY_EDITOR_NUM);
for (int i = 0; i < LayoutUtil.MAX_OPEN_QUERY_EDITOR_NUM; i++) {
list.add(cubridDatabases[i]);
}
cubridDatabases = new CubridDatabase[LayoutUtil.MAX_OPEN_QUERY_EDITOR_NUM];
list.toArray(cubridDatabases);
}
for (CubridDatabase database : cubridDatabases) {
SchemaEditorInput schemaEditorInput = new SchemaEditorInput(database, (provider instanceof TreeViewer) ? (TreeViewer) provider : null);
schemaEditorInput.setDatabase(database);
DatabaseInfo dbInfo = database.getDatabaseInfo();
if (dbInfo == null) {
continue;
}
try {
window.getActivePage().openEditor(schemaEditorInput, ERSchemaEditor.ID);
if (Util.isMac()) {
// refresh for low version mac
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().setEditorAreaVisible(false);
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().setEditorAreaVisible(true);
}
} catch (PartInitException e) {
LOGGER.error(e.getMessage());
}
}
}
use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.
the class SqlPstmtAction method run.
/**
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IEditorPart editor = window.getActivePage().getActiveEditor();
if (editor instanceof QueryEditorPart) {
QueryEditorPart queryEditor = (QueryEditorPart) editor;
PstmtSQLDialog dialog = new PstmtSQLDialog(queryEditor.getSite().getShell(), queryEditor.getSelectedDatabase());
dialog.create();
dialog.setEditorInput((QueryUnit) queryEditor.getEditorInput());
String queries = queryEditor.getCombinedQueryComposite().getSqlEditorComp().getText().getSelectionText();
dialog.setSql(queries);
dialog.open();
}
}
Aggregations