private void displayError(String msg, Throwable caught) { CoreGUI.getErrorHandler().handleError(msg, caught); String rootCause = ErrorHandler.getRootCauseMessage(caught); // JSch returns very bad error messages, transform them here before returning to the customer String fullMsg = null; if (rootCause != null && msg != null) { String runtimeException = "java.lang.RuntimeException"; if ("com.jcraft.jsch.JSchException:Auth cancel".equals(rootCause)) { fullMsg = MSG.view_remoteAgentInstall_error_authFailed(); } else if (rootCause.indexOf("java.net.UnknownHostException") != -1) { fullMsg = MSG.view_remoteAgentInstall_error_unknownHost(); } else if ("java.net.ConnectException:Connection refused".equals(rootCause)) { fullMsg = MSG.view_remoteAgentInstall_error_connRefused(); } else if (rootCause.indexOf(runtimeException) != -1) { int exceptionEnd = rootCause.indexOf(runtimeException) + runtimeException.length() + 1; // remove : also fullMsg = rootCause.substring(exceptionEnd); } } // Fallback if (fullMsg == null) { fullMsg = (rootCause == null) ? msg : msg + ": " + rootCause; } SC.warn(fullMsg); }
@Override public ListGridRecord copyValues(AlertDefinition from) { // in order to support sorting our list grid on the parent and resource columns, // we have to assign these to something that is sortable ListGridRecord record = super.copyValues(from); Resource resource = from.getResource(); record.setAttribute(FIELD_RESOURCE, resource.getName()); Integer parentId = from.getParentId(); // a valid non-zero number means the alert def came from a template AlertDefinition groupAlertDefinition = from.getGroupAlertDefinition(); if (parentId != null && parentId.intValue() > 0) { record.setAttribute(FIELD_PARENT, "<b>" + MSG.view_alert_definition_for_type() + "</b>"); } else if (groupAlertDefinition != null) { record.setAttribute(FIELD_PARENT, "<b>" + MSG.view_alert_definition_for_group() + "</b>"); } // for ancestry handling record.setAttribute(AncestryUtil.RESOURCE_ID, resource.getId()); record.setAttribute(AncestryUtil.RESOURCE_NAME, resource.getName()); record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, resource.getAncestry()); record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, resource.getResourceType().getId()); return record; }
private Tab createRecipeTab() { Tab tab = new Tab(MSG.view_bundle_recipe()); DynamicForm form = new DynamicForm(); TextAreaItem recipeCanvas = new TextAreaItem("recipe", MSG.view_bundle_recipe()); recipeCanvas.setShowTitle(false); recipeCanvas.setColSpan(2); recipeCanvas.setWidth("100%"); recipeCanvas.setHeight("100%"); recipeCanvas.setValue(version.getRecipe()); recipeCanvas.addChangeHandler( new ChangeHandler() { @Override public void onChange(ChangeEvent event) { // makes this read-only; however, since its not disabled, user can still select/copy the // text event.cancel(); } }); form.setHeight100(); form.setWidth100(); form.setItems(recipeCanvas); tab.setPane(form); return tab; }
private void createAgentStatusTextItem() { agentStatusText = new StaticTextItem("agentStatus", MSG.view_remoteAgentInstall_agentStatus()); agentStatusText.setDefaultValue(MSG.view_remoteAgentInstall_agentStatusDefault()); agentStatusText.setRedrawOnChange(true); agentStatusText.setStartRow(true); agentStatusText.setEndRow(false); }
private void setDashboard(Dashboard dashboard) { Canvas[] members = getMembers(); removeMembers(members); // pass in the resource information dashboardView = new DashboardView( extendLocatorId(dashboard.getName()), this, dashboard, EntityContext.forResource(resourceComposite.getResource().getId()), resourceComposite); addMember(dashboardView); footer = new LocatableToolStrip(extendLocatorId("Footer")); footer.setPadding(5); footer.setWidth100(); footer.setMembersMargin(15); editButton = new LocatableIButton( footer.extendLocatorId("Mode"), editMode ? MSG.common_title_view_mode() : MSG.common_title_edit_mode()); editButton.setAutoFit(true); editButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent clickEvent) { editMode = !editMode; editButton.setTitle( editMode ? MSG.common_title_view_mode() : MSG.common_title_edit_mode()); dashboardView.setEditMode(editMode); } }); resetButton = new LocatableIButton(footer.extendLocatorId("Reset"), MSG.common_button_reset()); resetButton.setAutoFit(true); resetButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent clickEvent) { String message = MSG.view_summaryDashboard_resetConfirm(); SC.ask( message, new BooleanCallback() { public void execute(Boolean confirmed) { if (confirmed) { dashboardView.delete(); setDashboard(getDefaultDashboard()); markForRedraw(); } } }); } }); footer.addMember(editButton); footer.addMember(resetButton); addMember(footer); }
private List<WizardStep> init() { setWindowTitle(MSG.view_bundle_deployWizard_title()); setTitle(MSG.view_bundle_bundleDeployment()); ArrayList<WizardStep> steps = new ArrayList<WizardStep>(); setSteps(steps); return steps; }
@Override protected void configureTable() { ListGridField idField = new ListGridField(FIELD_ID, MSG.common_title_id()); ListGridField versionField = new ListGridField(BundleVersionDataSource.FIELD_VERSION, MSG.common_title_version()); versionField.setCellFormatter( new CellFormatter() { public String format(Object o, ListGridRecord listGridRecord, int i, int i1) { Integer _bundleId = listGridRecord.getAttributeAsInt("bundleId"); Integer _bvId = listGridRecord.getAttributeAsInt("id"); return "<a href=\"" + LinkManager.getBundleVersionLink(_bundleId, _bvId) + "\">" + o + "</a>"; } }); ListGridField nameField = new ListGridField(BundleVersionDataSource.FIELD_NAME, MSG.common_title_name()); ListGridField descriptionField = new ListGridField( BundleVersionDataSource.FIELD_DESCRIPTION, MSG.common_title_description()); ListGridField fileCountField = new ListGridField(BundleVersionDataSource.FIELD_FILECOUNT, MSG.view_bundle_bundleFiles()); idField.setWidth(50); versionField.setWidth("20%"); nameField.setWidth("25%"); descriptionField.setWidth("*"); fileCountField.setWidth("10%"); setListGridFields(idField, versionField, nameField, descriptionField, fileCountField); setListGridDoubleClickHandler( new DoubleClickHandler() { @Override public void onDoubleClick(DoubleClickEvent event) { ListGrid listGrid = (ListGrid) event.getSource(); ListGridRecord[] selectedRows = listGrid.getSelectedRecords(); if (selectedRows != null && selectedRows.length == 1) { String selectedId = selectedRows[0].getAttribute(BundleVersionDataSource.FIELD_BUNDLE_ID); String selectedVersionId = selectedRows[0].getAttribute(BundleVersionDataSource.FIELD_ID); CoreGUI.goToView( LinkManager.getBundleVersionLink( Integer.valueOf(selectedId), Integer.valueOf(selectedVersionId))); } } }); }
public void onSuccess(Subject subject) { String m; if (refreshInterval > 0) { m = MSG.view_dashboards_portlets_refresh_success1(); } else { m = MSG.view_dashboards_portlets_refresh_success2(); } CoreGUI.getMessageCenter().notify(new Message(m, Message.Severity.Info)); updateRefreshMenu(); save(); }
public void onFailure(Throwable throwable) { String m; if (refreshInterval > 0) { m = MSG.view_dashboards_portlets_refresh_fail1(); } else { m = MSG.view_dashboards_portlets_refresh_fail2(); } CoreGUI.getMessageCenter().notify(new Message(m, Message.Severity.Error)); // Revert back to our original favorite status, since the server update failed. updateRefreshMenu(); }
protected Canvas defaultView() { EnhancedVLayout vLayout = new EnhancedVLayout(); vLayout.setWidth100(); // TODO: Help icon. TitleBar titleBar = new TitleBar(MSG.view_testTop_title()); vLayout.addMember(titleBar); Label label = new Label(MSG.view_testTop_description()); label.setPadding(10); vLayout.addMember(label); return vLayout; }
/** * This is a static utility method that is package protected so the message center view and the * message bar can pop up a dialog showing a message's details. * * @param message the message whose details are to be shown */ static void showDetails(Message message) { if (message == null) { return; } DynamicForm form = new LocatableDynamicForm("MessageCenterDetailsForm"); form.setWrapItemTitles(false); form.setAlign(Alignment.LEFT); StaticTextItem title = new StaticTextItem("theMessage", MSG.common_title_message()); title.setValue(message.conciseMessage); StaticTextItem severity = new StaticTextItem("severity", MSG.view_messageCenter_messageSeverity()); FormItemIcon severityIcon = new FormItemIcon(); severityIcon.setSrc(getSeverityIcon(message.severity)); severity.setIcons(severityIcon); severity.setValue(message.severity.name()); StaticTextItem date = new StaticTextItem("time", MSG.view_messageCenter_messageTime()); date.setValue( TimestampCellFormatter.format(message.fired, TimestampCellFormatter.DATE_TIME_FORMAT_FULL)); StaticTextItem detail = new StaticTextItem("detail", MSG.view_messageCenter_messageDetail()); detail.setTitleVAlign(VerticalAlignment.TOP); detail.setValue(message.detailedMessage); form.setItems(title, severity, date, detail); final Window dialogWin = new LocatableWindow("MessageCenterDetailsWindow"); dialogWin.setTitle(MSG.common_title_message()); dialogWin.setWidth(600); dialogWin.setHeight(400); dialogWin.setIsModal(true); dialogWin.setShowModalMask(true); dialogWin.setCanDragResize(true); dialogWin.setShowMaximizeButton(true); dialogWin.setShowMinimizeButton(false); dialogWin.centerInPage(); dialogWin.addItem(form); dialogWin.show(); dialogWin.addCloseClickHandler( new CloseClickHandler() { @Override public void onCloseClick(CloseClientEvent event) { dialogWin.destroy(); } }); }
@Override protected LocatableVLayout defaultView() { LocatableVLayout vLayout = new LocatableVLayout(this.extendLocatorId("Default")); vLayout.setWidth100(); // TODO: Help icon. TitleBar titleBar = new TitleBar(this, MSG.common_title_help()); vLayout.addMember(titleBar); Label label = new Label(MSG.view_helpTop_description()); label.setPadding(10); vLayout.addMember(label); return vLayout; }
private void uninstallAgent() { disableButtons(true); createWaitingWindow(MSG.view_remoteAgentInstall_uninstallingPleaseWait(), true); remoteInstallService.uninstallAgent( getRemoteAccessInfo(), getAgentInstallPath(), new AsyncCallback<String>() { public void onFailure(Throwable caught) { displayError(MSG.view_remoteAgentInstall_error_7(), caught); setAgentStatusText(MSG.view_remoteAgentInstall_error_7()); doneProcessing(); } public void onSuccess(String result) { if (result != null) { setAgentStatusText(MSG.view_remoteAgentInstall_uninstallSuccess()); displayMessage(MSG.view_remoteAgentInstall_uninstallAgentResults(result)); agentStatusCheck(); // we are relying on this to call doneProcessing(), we shouldn't // do it here // tell the success handler invokeSuccessHandler(Type.UNINSTALL); } else { setAgentStatusText(MSG.view_remoteAgentInstall_error_7()); doneProcessing(); } } }); }
private void findAgentInstallPath() { disableButtons(true); final String parentPath = getAgentInstallPath(); createWaitingWindow(MSG.view_remoteAgentInstall_findAgentWait(), true); remoteInstallService.findAgentInstallPath( getRemoteAccessInfo(), parentPath, new AsyncCallback<String>() { public void onFailure(Throwable caught) { displayError(MSG.view_remoteAgentInstall_error_1(), caught); doneProcessing(); } public void onSuccess(String result) { if (result != null) { agentInstallPath.setValue(result); agentStatusCheck(); // we are relying on this to call doneProcessing(), we shouldn't // do it here } else { String err; if (parentPath == null || parentPath.length() == 0) { err = MSG.view_remoteAgentInstall_error_2(); } else { err = MSG.view_remoteAgentInstall_error_3(parentPath); } displayError(err, null); setAgentStatusText(MSG.view_remoteAgentInstall_agentStatusDefault()); doneProcessing(); } } }); }
@Override public void onFailure(Throwable caught) { disableButtons(false); // if this failure was because the SSH connection wanted to ask a security question // (one of two things - either the host fingerprint is not known and we should add it // or the host fingerprint has changed and we should change it), then ask the question // (which jsch has provided us and we put in the SSHSecurityException) and if the user // answers "yes" then do the work as we originally were asked to do. if (caught instanceof SSHSecurityException) { SC.ask( caught.getMessage(), new BooleanCallback() { @Override public void execute(Boolean value) { if (value != null && value.booleanValue()) { hostAuthorized = true; // the user has just authorized the host doActualWork(); } } }); } else { displayError(MSG.view_remoteAgentInstall_error_connError(), caught); } }
private Tab createLiveDeploymentsTab() { Tab tab = new Tab(MSG.view_bundle_deployments()); Criteria criteria = new Criteria(); criteria.setAttribute("bundleVersionId", version.getId()); tab.setPane(new BundleDeploymentListView(criteria, this.canDeploy)); return tab; }
private ArrayList<LocatableHLayout> createTagLayouts() { ArrayList<LocatableHLayout> tagLayouts = new ArrayList<LocatableHLayout>(tags.size()); for (final Tag tag : tags) { LocatableHLayout tagLayout = new LocatableHLayout(extendLocatorId(tag.getName())); tagLayout.setHeight(18); tagLayout.setHeight(16); HTMLFlow tagString = new HTMLFlow( "<nobr><a href=\"" + LinkManager.getTagLink(tag.toString()) + "\">" + tag.toString() + "</a></nobr>"); tagString.setAutoWidth(); tagLayout.addMember(tagString); if (!readOnly) { final LayoutSpacer spacer = new LayoutSpacer(); spacer.setHeight(16); spacer.setWidth(16); final Img remove = new LocatableImg( tagLayout.extendLocatorId("Remove"), "[skin]/images/actions/remove.png", 16, 16); remove.setTooltip(MSG.view_tags_tooltip_1()); remove.addClickHandler( new ClickHandler() { public void onClick(ClickEvent clickEvent) { tags.remove(tag); save(); } }); tagLayout.addMember(remove); tagLayout.addMember(spacer); remove.hide(); tagLayout.addMouseOverHandler( new MouseOverHandler() { public void onMouseOver(MouseOverEvent mouseOverEvent) { remove.show(); spacer.hide(); } }); tagLayout.addMouseOutHandler( new MouseOutHandler() { public void onMouseOut(MouseOutEvent mouseOutEvent) { spacer.show(); remove.hide(); } }); } tagLayouts.add(tagLayout); } return tagLayouts; }
private Tab buildBundlesTab(TabSet tabSet) { Tab tab = new Tab(MSG.common_title_bundles(), ImageManager.getBundleIcon()); // NOTE: We will set the tab content to the bundle selector later, once the Bundle Group has // been fetched. return tab; }
public static ResourceCompositeSearchView getChildrenOf( ResourceComposite parentResourceComposite) { return new ResourceCompositeSearchView( parentResourceComposite, new Criteria("parentId", String.valueOf(parentResourceComposite.getResource().getId())), MSG.view_tabs_common_child_resources(), null); }
public CarouselFilter(Carousel carousel) { super(carousel.extendLocatorId("CarouselFilter")); setIsGroup(true); setGroupTitle(MSG.common_label_filters()); setWidth100(); setPadding(5); this.carousel = carousel; }
private void createWaitingWindow(String text, boolean show) { dialog = new Dialog(); dialog.setMessage(text); dialog.setIcon("[SKIN]notify.png"); dialog.draw(); dialog.setTitle(MSG.view_remoteAgentInstall_dialogTitle()); dialog.setShowCloseButton(false); }
@Override protected List<DataSourceField> addDataSourceFields() { List<DataSourceField> fields = super.addDataSourceFields(); DataSourceField idDataField = new DataSourceTextField("id", MSG.common_title_id()); idDataField.setPrimaryKey(true); fields.add(idDataField); DataSourceTextField nameDataField = new DataSourceTextField("name", MSG.common_title_name()); nameDataField.setCanEdit(false); fields.add(nameDataField); DataSourceTextField parentIdField = new DataSourceTextField("parentId", MSG.dataSource_ContentRepoTree_field_parentId()); parentIdField.setForeignKey("id"); fields.add(parentIdField); return fields; }
public MessageCenterView(String locatorId) { super( locatorId, MSG.view_messageCenter_messageTitle(), null, new SortSpecifier[] {new SortSpecifier(FIELD_TIME, SortDirection.DESCENDING)}, null, false); CoreGUI.getMessageCenter().addMessageListener(this); }
private void prepareHelpSection(SectionStack stack, ServerPlugin plugin) { if (plugin.getHelp() != null && plugin.getHelp().length() > 0) { SectionStackSection section = new SectionStackSection(MSG.common_title_help()); section.setExpanded(true); Label help = new Label(plugin.getHelp()); section.setItems(help); helpSection = section; } ++initSectionCount; return; }
public TagEditorView( String locatorId, Set<Tag> tags, boolean readOnly, TagsChangedCallback callback, boolean vertical) { super(locatorId); setVertical(vertical); setAutoWidth(); if (!vertical) { setMembersMargin(8); } if (tags != null) { this.tags.addAll(tags); } this.readOnly = readOnly; this.callback = callback; // create the following widgets once and re-use as needed tagTitleLabel = new HTMLFlow("<nobr><b>" + MSG.view_tags_tags() + ":</b></nobr>"); tagTitleLabel.setAutoWidth(); if (!this.readOnly) { tagInputDialog = new TagInputDialog(extendLocatorId("tagInputDialog")); addImg = new LocatableImg(extendLocatorId("addImg"), "[skin]/images/actions/add.png", 16, 16); addImg.setTooltip(MSG.view_tags_tooltip_2()); addImg.addClickHandler( new ClickHandler() { public void onClick(ClickEvent clickEvent) { showTagInput(); } }); } }
@Override protected void configureTable() { updateSelectionStyle(); getListGrid() .addCellClickHandler( new CellClickHandler() { public void onCellClick(CellClickEvent event) { updateSelectionStyle(); } }); List<ListGridField> fields = createFields(); setListGridFields(fields.toArray(new ListGridField[fields.size()])); addTableAction(extendLocatorId("New"), MSG.common_button_new(), createNewAction()); addTableAction( extendLocatorId("Delete"), MSG.common_button_delete(), getDeleteConfirmMessage(), createDeleteAction()); super.configureTable(); }
private Canvas getActionLayout() { EnhancedVLayout actionLayout = new EnhancedVLayout(10); IButton deleteButton = new EnhancedIButton(MSG.common_button_delete(), ButtonColor.RED); // deleteButton.setIcon("subsystems/bundle/BundleVersionAction_Delete_16.png"); deleteButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent clickEvent) { SC.ask( MSG.view_bundle_version_deleteConfirm(), new BooleanCallback() { public void execute(Boolean aBoolean) { if (aBoolean) { bundleManager.deleteBundleVersion( version.getId(), false, new AsyncCallback<Void>() { public void onFailure(Throwable caught) { CoreGUI.getErrorHandler() .handleError( MSG.view_bundle_version_deleteFailure(version.getVersion()), caught); } public void onSuccess(Void result) { CoreGUI.getMessageCenter() .notify( new Message( MSG.view_bundle_version_deleteSuccessful( version.getVersion()), Message.Severity.Info)); // Bundle version is deleted, go back to main bundle view CoreGUI.goToView( LinkManager.getBundleVersionLink(version.getBundle().getId(), 0), true); } }); } } }); } }); actionLayout.addMember(deleteButton); if (!canDelete) { deleteButton.setDisabled(true); } return actionLayout; }
private DynamicForm createSummaryForm() { DynamicForm form = new DynamicForm(); form.setWidth100(); form.setColWidths("20%", "40%", "40%"); form.setNumCols(3); form.setAutoHeight(); form.setWrapItemTitles(false); form.setExtraSpace(10); form.setIsGroup(true); form.setGroupTitle(MSG.common_title_summary()); form.setPadding(5); CanvasItem actionItem = new CanvasItem("actions"); actionItem.setColSpan(1); actionItem.setRowSpan(4); actionItem.setShowTitle(false); actionItem.setCanvas(getActionLayout()); StaticTextItem versionItem = new StaticTextItem("version", MSG.common_title_version()); versionItem.setValue(version.getVersion()); StaticTextItem liveDeploymentsItem = new StaticTextItem("deployments", MSG.view_bundle_deployments()); liveDeploymentsItem.setValue(version.getBundleDeployments().size()); StaticTextItem filesItems = new StaticTextItem("files", MSG.view_bundle_files()); filesItems.setValue(version.getBundleFiles().size()); StaticTextItem descriptionItem = new StaticTextItem("description", MSG.common_title_description()); descriptionItem.setValue(version.getDescription()); form.setFields(versionItem, actionItem, liveDeploymentsItem, filesItems, descriptionItem); return form; }
public SystemSettingsView(String locatorId) { super(locatorId); setHeight100(); setWidth100(); TitleBar titleBar = new TitleBar( this, MSG.view_adminConfig_systemSettings(), "subsystems/configure/Configure_24.png"); addMember(titleBar); canvas = new LocatableVLayout("innerLayout"); canvas.setHeight100(); canvas.setWidth100(); canvas.setMargin(15); addMember(canvas); }
@Override protected Canvas buildResultsSection(GroupOperationHistory operationHistory) { EnhancedVLayout resultsSection = new EnhancedVLayout(); Label title = new Label("<h4>" + MSG.view_operationHistoryDetails_results() + "</h4>"); title.setHeight(27); resultsSection.addMember(title); GroupMemberResourceOperationHistoryListView memberHistoryListView = new GroupMemberResourceOperationHistoryListView( this.groupComposite, getOperationHistory().getId()); memberHistoryListView.setOverflow(Overflow.VISIBLE); memberHistoryListView.setHeight(200); resultsSection.addMember(memberHistoryListView); return resultsSection; }