Search in sources :

Example 21 with PropertyDialog

use of org.eclipse.ui.internal.dialogs.PropertyDialog in project netxms by netxms.

the class SummaryTableManager method createSummaryTable.

/**
 * Create new loyalty program
 */
private void createSummaryTable(boolean isTableSource) {
    // $NON-NLS-1$ //$NON-NLS-2$
    DciSummaryTable t = new DciSummaryTable("", "", isTableSource);
    PropertyDialog dlg = PropertyDialog.createDialogOn(getSite().getShell(), null, t);
    if (dlg != null) {
        dlg.getShell().setText(Messages.get().SummaryTableManager_TitleCreate);
        dlg.open();
        if (t.getId() != 0) {
            // was saved to server
            DciSummaryTableDescriptor d = new DciSummaryTableDescriptor(t);
            descriptors.put(d.getId(), d);
            viewer.setInput(descriptors.values().toArray());
            viewer.setSelection(new StructuredSelection(d));
        }
    }
}
Also used : DciSummaryTable(org.netxms.client.datacollection.DciSummaryTable) PropertyDialog(org.eclipse.ui.internal.dialogs.PropertyDialog) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) DciSummaryTableDescriptor(org.netxms.client.datacollection.DciSummaryTableDescriptor)

Example 22 with PropertyDialog

use of org.eclipse.ui.internal.dialogs.PropertyDialog in project netxms by netxms.

the class ObjectToolsEditor method createTool.

/**
 * Create new tool
 */
private void createTool() {
    final CreateNewToolDialog dlg = new CreateNewToolDialog(getSite().getShell());
    if (dlg.open() == Window.OK) {
        new ConsoleJob(Messages.get().ObjectToolsEditor_JobNewId, this, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {

            @Override
            protected void runInternal(IProgressMonitor monitor) throws Exception {
                final long toolId = session.generateObjectToolId();
                final ObjectToolDetails details = new ObjectToolDetails(toolId, dlg.getType(), dlg.getName());
                session.modifyObjectTool(details);
                runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        PropertyDialog dlg = PropertyDialog.createDialogOn(getSite().getShell(), null, details);
                        dlg.open();
                        if (details.isModified())
                            saveObjectTool(details);
                    }
                });
            }

            @Override
            protected String getErrorMessage() {
                return Messages.get(getDisplay()).ObjectToolsEditor_JobNewIdError;
            }
        }.start();
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) PropertyDialog(org.eclipse.ui.internal.dialogs.PropertyDialog) CreateNewToolDialog(org.netxms.ui.eclipse.objecttools.dialogs.CreateNewToolDialog) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) ObjectToolDetails(org.netxms.client.objecttools.ObjectToolDetails) PartInitException(org.eclipse.ui.PartInitException)

Example 23 with PropertyDialog

use of org.eclipse.ui.internal.dialogs.PropertyDialog in project netxms by netxms.

the class HistoricalGraphView method createActions.

/**
 * Create actions
 */
private void createActions() {
    actionRefresh = new RefreshAction(this) {

        @Override
        public void run() {
            updateChart();
        }
    };
    actionProperties = new Action(Messages.get().HistoricalGraphView_Properties) {

        @Override
        public void run() {
            PropertyDialog dlg = PropertyDialog.createDialogOn(getSite().getShell(), null, settings);
            if (dlg != null) {
                dlg.open();
                configureGraphFromSettings();
                refreshMenuSelection();
            }
        }
    };
    actionAutoRefresh = new Action(Messages.get().HistoricalGraphView_Autorefresh) {

        @Override
        public void run() {
            settings.setAutoRefresh(!settings.isAutoRefresh());
            setChecked(settings.isAutoRefresh());
            refreshController.setInterval(settings.isAutoRefresh() ? settings.getRefreshRate() : -1);
        }
    };
    actionAutoRefresh.setChecked(settings.isAutoRefresh());
    actionLogScale = new Action(Messages.get().HistoricalGraphView_LogScale) {

        @Override
        public void run() {
            try {
                chart.setLogScaleEnabled(!settings.isLogScale());
                settings.setLogScale(!settings.isLogScale());
            } catch (IllegalStateException e) {
                MessageDialogHelper.openError(getSite().getShell(), Messages.get().HistoricalGraphView_Error, String.format(Messages.get().HistoricalGraphView_LogScaleSwitchError, e.getLocalizedMessage()));
                // $NON-NLS-1$
                Activator.logError("Cannot change log scale mode", e);
            }
            setChecked(settings.isLogScale());
        }
    };
    actionLogScale.setChecked(settings.isLogScale());
    actionZoomIn = new Action(Messages.get().HistoricalGraphView_ZoomIn) {

        @Override
        public void run() {
            chart.zoomIn();
        }
    };
    actionZoomIn.setImageDescriptor(SharedIcons.ZOOM_IN);
    actionZoomOut = new Action(Messages.get().HistoricalGraphView_ZoomOut) {

        @Override
        public void run() {
            chart.zoomOut();
        }
    };
    actionZoomOut.setImageDescriptor(SharedIcons.ZOOM_OUT);
    actionAdjustX = createAction(ActionType.ADJUST_X, chart);
    actionAdjustY = createAction(ActionType.ADJUST_Y, chart);
    actionAdjustBoth = createAction(ActionType.ADJUST_BOTH, chart);
    actionShowLegend = new Action(Messages.get().HistoricalGraphView_ShowLegend) {

        @Override
        public void run() {
            settings.setShowLegend(actionShowLegend.isChecked());
            chart.setLegendVisible(settings.isShowLegend());
        }
    };
    actionShowLegend.setChecked(settings.isShowLegend());
    actionExtendedLegend = new Action(Messages.get().HistoricalGraphView_ExtendedLegend) {

        @Override
        public void run() {
            settings.setExtendedLegend(actionExtendedLegend.isChecked());
            chart.setExtendedLegend(settings.isExtendedLegend());
        }
    };
    actionExtendedLegend.setChecked(settings.isExtendedLegend());
    actionLegendLeft = new Action(Messages.get().HistoricalGraphView_PlaceOnLeft, Action.AS_RADIO_BUTTON) {

        @Override
        public void run() {
            settings.setLegendPosition(GraphSettings.POSITION_LEFT);
            chart.setLegendPosition(settings.getLegendPosition());
        }
    };
    actionLegendLeft.setChecked(settings.getLegendPosition() == GraphSettings.POSITION_LEFT);
    actionLegendRight = new Action(Messages.get().HistoricalGraphView_PlaceOnRight, Action.AS_RADIO_BUTTON) {

        @Override
        public void run() {
            settings.setLegendPosition(GraphSettings.POSITION_RIGHT);
            chart.setLegendPosition(settings.getLegendPosition());
        }
    };
    actionLegendRight.setChecked(settings.getLegendPosition() == GraphSettings.POSITION_RIGHT);
    actionLegendTop = new Action(Messages.get().HistoricalGraphView_PlaceOnTop, Action.AS_RADIO_BUTTON) {

        @Override
        public void run() {
            settings.setLegendPosition(GraphSettings.POSITION_TOP);
            chart.setLegendPosition(settings.getLegendPosition());
        }
    };
    actionLegendTop.setChecked(settings.getLegendPosition() == GraphSettings.POSITION_TOP);
    actionLegendBottom = new Action(Messages.get().HistoricalGraphView_PlaceOnBottom, Action.AS_RADIO_BUTTON) {

        @Override
        public void run() {
            settings.setLegendPosition(GraphSettings.POSITION_BOTTOM);
            chart.setLegendPosition(settings.getLegendPosition());
        }
    };
    actionLegendBottom.setChecked(settings.getLegendPosition() == GraphSettings.POSITION_BOTTOM);
    actionSave = new Action(Messages.get().HistoricalGraphView_Save, SharedIcons.SAVE) {

        @Override
        public void run() {
            String initalName = settings.getName().compareTo("noname") == 0 ? settings.getTitle() : settings.getName();
            saveGraph(initalName, null, false, false);
        }
    };
    // TODO: add check that graph uses only one node as source
    actionSaveAsTemplate = new Action("Save as template", SharedIcons.SAVE_AS) {

        @Override
        public void run() {
            String initalName = settings.getName().compareTo("noname") == 0 ? settings.getTitle() : settings.getName();
            saveGraph(initalName, null, false, true);
        }
    };
    actionStacked = new Action(Messages.get().HistoricalGraphView_Stacked, Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            settings.setStacked(actionStacked.isChecked());
            configureGraphFromSettings();
        }
    };
    actionStacked.setChecked(settings.isStacked());
    actionTranslucent = new Action(Messages.get().HistoricalGraphView_Translucent, Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            settings.setTranslucent(actionTranslucent.isChecked());
            configureGraphFromSettings();
        }
    };
    actionTranslucent.setChecked(settings.isTranslucent());
    actionAreaChart = new Action("Area chart", Action.AS_CHECK_BOX) {

        @Override
        public void run() {
            settings.setArea(actionAreaChart.isChecked());
            configureGraphFromSettings();
        }
    };
    actionAreaChart.setChecked(settings.isArea());
    presetActions = createPresetActions(new PresetHandler() {

        @Override
        public void onPresetSelected(int units, int range) {
            settings.setTimeUnits(units);
            settings.setTimeRange(range);
            updateChart();
        }
    });
    actionSaveAsImage = new Action("Save as image", SharedIcons.SAVE_AS_IMAGE) {

        @Override
        public void run() {
            chart.saveAsImage();
        }
    };
}
Also used : RefreshAction(org.netxms.ui.eclipse.actions.RefreshAction) Action(org.eclipse.jface.action.Action) RefreshAction(org.netxms.ui.eclipse.actions.RefreshAction) PropertyDialog(org.eclipse.ui.internal.dialogs.PropertyDialog)

Example 24 with PropertyDialog

use of org.eclipse.ui.internal.dialogs.PropertyDialog in project mdw-designer by CenturyLinkCloud.

the class ProjectSection method setSelection.

@Override
public void setSelection(WorkflowElement selection) {
    if (project != null)
        project.removeElementChangeListener(this);
    project = (WorkflowProject) selection;
    project.addElementChangeListener(this);
    // dispose controls to render dynamically
    if (sourceProjectEditor != null)
        sourceProjectEditor.dispose();
    if (jdbcUrlEditor != null)
        jdbcUrlEditor.dispose();
    if (hostEditor != null)
        hostEditor.dispose();
    if (portEditor != null)
        portEditor.dispose();
    if (webContextRootEditor != null)
        webContextRootEditor.dispose();
    if (updateServerCacheEditor != null)
        updateServerCacheEditor.dispose();
    if (localProjectEditor != null)
        localProjectEditor.dispose();
    if (localProjectInfoEditor != null)
        localProjectInfoEditor.dispose();
    if (mdwVersionEditor != null)
        mdwVersionEditor.dispose();
    if (appVersionEditor != null)
        appVersionEditor.dispose();
    // source project text field
    sourceProjectEditor = new PropertyEditor(project, PropertyEditor.TYPE_TEXT);
    sourceProjectEditor.setLabel("Source Project");
    sourceProjectEditor.setWidth(200);
    sourceProjectEditor.render(composite);
    sourceProjectEditor.setValue(project.getSourceProjectName());
    sourceProjectEditor.setEditable(false);
    if (!project.checkRequiredVersion(6, 0)) {
        // jdbc url text field
        jdbcUrlEditor = new PropertyEditor(project, PropertyEditor.TYPE_TEXT);
        jdbcUrlEditor.setLabel("JDBC URL");
        jdbcUrlEditor.addValueChangeListener(new ValueChangeListener() {

            public void propertyValueChanged(Object newValue) {
                project.getMdwDataSource().setJdbcUrlWithCredentials(((String) newValue).trim());
                project.getMdwDataSource().setEntrySource("projectSection");
                WorkflowProjectManager.updateProject(project);
                project.fireElementChangeEvent(ChangeType.SETTINGS_CHANGE, project.getMdwDataSource());
            }
        });
        jdbcUrlEditor.render(composite);
        jdbcUrlEditor.setValue(project.getMdwDataSource().getJdbcUrlWithMaskedCredentials());
        jdbcUrlEditor.setEditable(!project.isReadOnly());
    }
    // host text field
    hostEditor = new PropertyEditor(project, PropertyEditor.TYPE_TEXT);
    hostEditor.setLabel("Server Host");
    hostEditor.addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            project.getServerSettings().setHost((String) newValue);
            WorkflowProjectManager.updateProject(project);
            project.fireElementChangeEvent(ChangeType.SETTINGS_CHANGE, project.getServerSettings());
        }
    });
    hostEditor.render(composite);
    hostEditor.setValue(project.getServerSettings().getHost());
    hostEditor.setEditable(!project.isReadOnly());
    // port text field
    portEditor = new PropertyEditor(project, PropertyEditor.TYPE_TEXT);
    portEditor.setLabel("Server Port");
    portEditor.addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            project.getServerSettings().setPort(Integer.parseInt(((String) newValue).trim()));
            WorkflowProjectManager.updateProject(project);
            project.fireElementChangeEvent(ChangeType.SETTINGS_CHANGE, project.getServerSettings());
        }
    });
    portEditor.render(composite);
    portEditor.setValue(project.getServerSettings().getPort());
    portEditor.setEditable(!project.isReadOnly());
    // web context root text field
    webContextRootEditor = new PropertyEditor(project, PropertyEditor.TYPE_TEXT);
    webContextRootEditor.setLabel("Web Context Root");
    webContextRootEditor.setWidth(200);
    if (project.isRemote()) {
        webContextRootEditor.addValueChangeListener(new ValueChangeListener() {

            public void propertyValueChanged(Object newValue) {
                project.setWebContextRoot(((String) newValue).trim());
                WorkflowProjectManager.updateProject(project);
                project.fireElementChangeEvent(ChangeType.SETTINGS_CHANGE, project.getServerSettings());
            }
        });
    }
    webContextRootEditor.render(composite);
    webContextRootEditor.setValue(project.getWebContextRoot());
    webContextRootEditor.setEditable(!project.isReadOnly() && project.isRemote());
    // refresh server cache checkbox
    updateServerCacheEditor = new PropertyEditor(project, PropertyEditor.TYPE_CHECKBOX);
    updateServerCacheEditor.setLabel("Update Server Cache");
    updateServerCacheEditor.addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            project.setUpdateServerCache(Boolean.parseBoolean(newValue.toString()));
            WorkflowProjectManager.updateProject(project);
            project.fireElementChangeEvent(ChangeType.SETTINGS_CHANGE, project.isUpdateServerCache());
        }
    });
    updateServerCacheEditor.render(composite);
    updateServerCacheEditor.setValue(project.isUpdateServerCache());
    updateServerCacheEditor.setEditable(!project.isReadOnly());
    // mdw version combo
    if (project.isRemote()) {
        mdwVersionEditor = new PropertyEditor(project, PropertyEditor.TYPE_TEXT);
    } else {
        mdwVersionEditor = new PropertyEditor(project, PropertyEditor.TYPE_COMBO);
        String releaseUrl = mdwSettings.getMdwReleasesUrl();
        if (project.getMdwMajorVersion() < 6)
            mdwSettings.setMdwReleasesUrl(mdwSettings.getInternalRepositoryUrl());
        List<String> versionOptions = mdwSettings.getMdwVersions();
        mdwSettings.setMdwReleasesUrl(releaseUrl);
        if (!versionOptions.contains(project.getMdwVersion()))
            versionOptions.add(project.getMdwVersion());
        mdwVersionEditor.setValueOptions(versionOptions);
        mdwVersionEditor.addValueChangeListener(new ValueChangeListener() {

            public void propertyValueChanged(Object newValue) {
                if (!project.isRemote() && !newValue.equals("")) {
                    project.setMdwVersion((String) newValue);
                    WorkflowProjectManager.updateProject(project);
                    if (MessageDialog.openQuestion(getShell(), "Update Framework Libraries", "Download updated framework libraries to match MDW Version selection?")) {
                        ProjectUpdater updater = new ProjectUpdater(getProject(), MdwPlugin.getSettings());
                        try {
                            updater.updateFrameworkJars(null);
                            ExtensionModulesUpdater modulesUpdater = new ExtensionModulesUpdater(getProject());
                            modulesUpdater.doUpdate(getShell());
                        } catch (Exception ex) {
                            PluginMessages.uiError(getShell(), ex, "Update Framework Libraries", getProject());
                        }
                    }
                    if (getProject().isOsgi())
                        MessageDialog.openInformation(getShell(), "MDW Version Changed", "The MDW version has been updated in the plug-in settings file.  Please update any MDW dependencies in your pom.xml build file.");
                }
            }
        });
    }
    mdwVersionEditor.setLabel("MDW Version");
    mdwVersionEditor.setWidth(100);
    mdwVersionEditor.render(composite);
    mdwVersionEditor.setValue(project.getMdwVersion());
    mdwVersionEditor.setEditable(!project.isReadOnly() && !project.isRemote());
    // app version
    if (!project.isCloudProject() && !"Unknown".equals(project.getAppVersion())) {
        appVersionEditor = new PropertyEditor(project, PropertyEditor.TYPE_TEXT);
        appVersionEditor.setLabel("App Version");
        appVersionEditor.setWidth(200);
        appVersionEditor.render(composite);
        appVersionEditor.setValue(project.getAppVersion());
        appVersionEditor.setEditable(false);
    }
    if (!project.isRemote()) {
        // local project text field
        localProjectEditor = new PropertyEditor(project, PropertyEditor.TYPE_TEXT);
        localProjectEditor.setLabel("Workspace Project");
        localProjectEditor.setWidth(200);
        localProjectEditor.setReadOnly(true);
        localProjectEditor.render(composite);
        if (project.isCloudProject())
            localProjectEditor.setValue(project.getSourceProjectName());
        else
            localProjectEditor.setValue(project.getEarProjectName());
        if (!project.isOsgi()) {
            // local project info field
            localProjectInfoEditor = new PropertyEditor(project, PropertyEditor.TYPE_LINK);
            localProjectInfoEditor.setLabel("Workspace Project Settings");
            localProjectInfoEditor.addValueChangeListener(new ValueChangeListener() {

                public void propertyValueChanged(Object newValue) {
                    final IProject proj = project.isCloudProject() ? project.getSourceProject() : project.getEarProject();
                    PropertyDialog dialog = PropertyDialog.createDialogOn(getShell(), "mdw.workflow.mdwServerConnectionsPropertyPage", proj);
                    if (dialog != null)
                        dialog.open();
                }
            });
            localProjectInfoEditor.render(composite);
        }
    }
    composite.layout(true);
}
Also used : ValueChangeListener(com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener) PropertyDialog(org.eclipse.ui.internal.dialogs.PropertyDialog) ProjectUpdater(com.centurylink.mdw.plugin.project.assembly.ProjectUpdater) PropertyEditor(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor) ExtensionModulesUpdater(com.centurylink.mdw.plugin.project.assembly.ExtensionModulesUpdater) IProject(org.eclipse.core.resources.IProject)

Aggregations

PropertyDialog (org.eclipse.ui.internal.dialogs.PropertyDialog)24 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)10 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)5 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)5 PartInitException (org.eclipse.ui.PartInitException)4 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)3 DashboardElementConfig (org.netxms.ui.eclipse.dashboard.widgets.internal.DashboardElementConfig)3 DciSummaryTable (org.netxms.client.datacollection.DciSummaryTable)2 DciSummaryTableDescriptor (org.netxms.client.datacollection.DciSummaryTableDescriptor)2 GraphSettings (org.netxms.client.datacollection.GraphSettings)2 NetworkMapDCIContainer (org.netxms.client.maps.elements.NetworkMapDCIContainer)2 NetworkMapDCIImage (org.netxms.client.maps.elements.NetworkMapDCIImage)2 NetworkMapTextBox (org.netxms.client.maps.elements.NetworkMapTextBox)2 AlarmCategoryEditor (org.netxms.ui.eclipse.alarmviewer.editors.AlarmCategoryEditor)2 PropertyEditor (com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor)1 ValueChangeListener (com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener)1 ExtensionModulesUpdater (com.centurylink.mdw.plugin.project.assembly.ExtensionModulesUpdater)1 ProjectUpdater (com.centurylink.mdw.plugin.project.assembly.ProjectUpdater)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 HashMap (java.util.HashMap)1