Search in sources :

Example 56 with IWorkbenchWindow

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;
}
Also used : IComponentSettingsView(org.talend.core.views.IComponentSettingsView) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) PropertyChangeEvent(java.beans.PropertyChangeEvent) ILibraryManagerService(org.talend.core.ILibraryManagerService) Element(org.talend.core.model.process.Element) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) Job(org.eclipse.core.runtime.jobs.Job)

Example 57 with IWorkbenchWindow

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);
}
Also used : Group(org.eclipse.swt.widgets.Group) SelectionListener(org.eclipse.swt.events.SelectionListener) Listener(org.eclipse.swt.widgets.Listener) MalformedURIException(org.apache.xerces.util.URI.MalformedURIException) Category(alma.acs.alarmsystem.generated.Category) TreeItem(org.eclipse.swt.widgets.TreeItem) TableItem(org.eclipse.swt.widgets.TableItem) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) URI(org.apache.xerces.util.URI) GridLayout(org.eclipse.swt.layout.GridLayout) Menu(org.eclipse.swt.widgets.Menu) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) Table(org.eclipse.swt.widgets.Table) Alarms(alma.acs.alarmsystem.generated.Alarms) Text(org.eclipse.swt.widgets.Text) MenuItem(org.eclipse.swt.widgets.MenuItem) Point(org.eclipse.swt.graphics.Point) IllegalOperationException(cl.utfsm.acs.acg.core.IllegalOperationException) Contact(alma.acs.alarmsystem.generated.Contact) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 58 with IWorkbenchWindow

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);
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) QueryEditorPart(com.cubrid.common.ui.query.editor.QueryEditorPart) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException)

Example 59 with IWorkbenchWindow

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());
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) SchemaEditorInput(com.cubrid.common.ui.er.SchemaEditorInput) ArrayList(java.util.ArrayList) PartInitException(org.eclipse.ui.PartInitException) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 60 with IWorkbenchWindow

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();
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) QueryEditorPart(com.cubrid.common.ui.query.editor.QueryEditorPart) PstmtSQLDialog(com.cubrid.common.ui.cubrid.table.dialog.PstmtSQLDialog) IEditorPart(org.eclipse.ui.IEditorPart)

Aggregations

IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)363 IEditorPart (org.eclipse.ui.IEditorPart)136 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)102 PartInitException (org.eclipse.ui.PartInitException)81 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)41 QueryEditorPart (com.cubrid.common.ui.query.editor.QueryEditorPart)39 IViewPart (org.eclipse.ui.IViewPart)39 ArrayList (java.util.ArrayList)37 IEditorReference (org.eclipse.ui.IEditorReference)35 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)32 IWorkbench (org.eclipse.ui.IWorkbench)32 IFile (org.eclipse.core.resources.IFile)30 ISelection (org.eclipse.jface.viewers.ISelection)29 XLIFFEditorImplWithNatTable (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable)27 Shell (org.eclipse.swt.widgets.Shell)26 XLFHandler (net.heartsome.cat.ts.core.file.XLFHandler)24 CoreException (org.eclipse.core.runtime.CoreException)23 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)21 IProject (org.eclipse.core.resources.IProject)20 QueryUnit (com.cubrid.common.ui.query.editor.QueryUnit)19